diff --git a/app/models.py b/app/models.py index 1f506a38..e545e9e2 100644 --- a/app/models.py +++ b/app/models.py @@ -109,7 +109,7 @@ class User(db.Model, ModelMixin, UserMixin): db.session.flush() # create a first alias mail to show user how to use when they login - GenEmail.create_custom_alias(user.id, prefix="my-first-alias") + GenEmail.create_new(user.id, prefix="my-first-alias") db.session.flush() return user @@ -158,7 +158,7 @@ class User(db.Model, ModelMixin, UserMixin): all_gen_emails = [ge.email for ge in GenEmail.filter_by(user_id=self.id)] if self.can_create_new_alias(): - suggested_gen_email = GenEmail.create_custom_alias( + suggested_gen_email = GenEmail.create_new( self.id, prefix=website_name ).email else: @@ -393,7 +393,7 @@ class GenEmail(db.Model, ModelMixin): user = db.relationship(User) @classmethod - def create_custom_alias(cls, user_id, prefix): + def create_new(cls, user_id, prefix): if not prefix: raise Exception("alias prefix cannot be empty") diff --git a/server.py b/server.py index b2bae7af..cc2d1e39 100644 --- a/server.py +++ b/server.py @@ -115,9 +115,9 @@ def fake_data(): api_key = ApiKey.create(user_id=user.id, name="Chrome") api_key.code = "code" - GenEmail.create_custom_alias(user.id, "e1@") - GenEmail.create_custom_alias(user.id, "e2@") - GenEmail.create_custom_alias(user.id, "e3@") + GenEmail.create_new(user.id, "e1@") + GenEmail.create_new(user.id, "e2@") + GenEmail.create_new(user.id, "e3@") CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True) CustomDomain.create( diff --git a/tests/api/test_alias_options.py b/tests/api/test_alias_options.py index 3d9dc54c..6f14901e 100644 --- a/tests/api/test_alias_options.py +++ b/tests/api/test_alias_options.py @@ -39,7 +39,7 @@ def test_different_scenarios(flask_client): assert r.json["custom"]["suggestion"] == "test" # <<< with recommendation >>> - alias = GenEmail.create_custom_alias(user.id, prefix="test") + alias = GenEmail.create_new(user.id, prefix="test") db.session.commit() AliasUsedOn.create(gen_email_id=alias.id, hostname="www.test.com") db.session.commit() diff --git a/tests/api/test_new_custom_alias.py b/tests/api/test_new_custom_alias.py index bff09d9c..36622be8 100644 --- a/tests/api/test_new_custom_alias.py +++ b/tests/api/test_new_custom_alias.py @@ -36,9 +36,9 @@ def test_out_of_quota(flask_client): db.session.commit() # create 3 custom alias to run out of quota - GenEmail.create_custom_alias(user.id, prefix="test") - GenEmail.create_custom_alias(user.id, prefix="test") - GenEmail.create_custom_alias(user.id, prefix="test") + GenEmail.create_new(user.id, prefix="test") + GenEmail.create_new(user.id, prefix="test") + GenEmail.create_new(user.id, prefix="test") r = flask_client.post( url_for("api.new_custom_alias", hostname="www.test.com"), diff --git a/tests/test_models.py b/tests/test_models.py index b3497c22..66cbb72e 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -27,7 +27,7 @@ def test_suggested_emails_for_user_who_cannot_create_new_email(flask_client): # make sure user runs out of quota to create new email for i in range(MAX_NB_EMAIL_FREE_PLAN): - GenEmail.create_custom_alias(user_id=user.id, prefix="test") + GenEmail.create_new(user_id=user.id, prefix="test") db.session.commit() suggested_email, other_emails = user.suggested_emails(website_name="test")