rename create_custom_alias -> create_new
This commit is contained in:
parent
55bccf8f84
commit
084f835bfe
|
@ -109,7 +109,7 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
db.session.flush()
|
db.session.flush()
|
||||||
|
|
||||||
# create a first alias mail to show user how to use when they login
|
# 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()
|
db.session.flush()
|
||||||
|
|
||||||
return user
|
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)]
|
all_gen_emails = [ge.email for ge in GenEmail.filter_by(user_id=self.id)]
|
||||||
if self.can_create_new_alias():
|
if self.can_create_new_alias():
|
||||||
suggested_gen_email = GenEmail.create_custom_alias(
|
suggested_gen_email = GenEmail.create_new(
|
||||||
self.id, prefix=website_name
|
self.id, prefix=website_name
|
||||||
).email
|
).email
|
||||||
else:
|
else:
|
||||||
|
@ -393,7 +393,7 @@ class GenEmail(db.Model, ModelMixin):
|
||||||
user = db.relationship(User)
|
user = db.relationship(User)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_custom_alias(cls, user_id, prefix):
|
def create_new(cls, user_id, prefix):
|
||||||
if not prefix:
|
if not prefix:
|
||||||
raise Exception("alias prefix cannot be empty")
|
raise Exception("alias prefix cannot be empty")
|
||||||
|
|
||||||
|
|
|
@ -115,9 +115,9 @@ def fake_data():
|
||||||
api_key = ApiKey.create(user_id=user.id, name="Chrome")
|
api_key = ApiKey.create(user_id=user.id, name="Chrome")
|
||||||
api_key.code = "code"
|
api_key.code = "code"
|
||||||
|
|
||||||
GenEmail.create_custom_alias(user.id, "e1@")
|
GenEmail.create_new(user.id, "e1@")
|
||||||
GenEmail.create_custom_alias(user.id, "e2@")
|
GenEmail.create_new(user.id, "e2@")
|
||||||
GenEmail.create_custom_alias(user.id, "e3@")
|
GenEmail.create_new(user.id, "e3@")
|
||||||
|
|
||||||
CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True)
|
CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True)
|
||||||
CustomDomain.create(
|
CustomDomain.create(
|
||||||
|
|
|
@ -39,7 +39,7 @@ def test_different_scenarios(flask_client):
|
||||||
assert r.json["custom"]["suggestion"] == "test"
|
assert r.json["custom"]["suggestion"] == "test"
|
||||||
|
|
||||||
# <<< with recommendation >>>
|
# <<< with recommendation >>>
|
||||||
alias = GenEmail.create_custom_alias(user.id, prefix="test")
|
alias = GenEmail.create_new(user.id, prefix="test")
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
AliasUsedOn.create(gen_email_id=alias.id, hostname="www.test.com")
|
AliasUsedOn.create(gen_email_id=alias.id, hostname="www.test.com")
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
|
@ -36,9 +36,9 @@ def test_out_of_quota(flask_client):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
# create 3 custom alias to run out of quota
|
# create 3 custom alias to run out of quota
|
||||||
GenEmail.create_custom_alias(user.id, prefix="test")
|
GenEmail.create_new(user.id, prefix="test")
|
||||||
GenEmail.create_custom_alias(user.id, prefix="test")
|
GenEmail.create_new(user.id, prefix="test")
|
||||||
GenEmail.create_custom_alias(user.id, prefix="test")
|
GenEmail.create_new(user.id, prefix="test")
|
||||||
|
|
||||||
r = flask_client.post(
|
r = flask_client.post(
|
||||||
url_for("api.new_custom_alias", hostname="www.test.com"),
|
url_for("api.new_custom_alias", hostname="www.test.com"),
|
||||||
|
|
|
@ -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
|
# make sure user runs out of quota to create new email
|
||||||
for i in range(MAX_NB_EMAIL_FREE_PLAN):
|
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()
|
db.session.commit()
|
||||||
|
|
||||||
suggested_email, other_emails = user.suggested_emails(website_name="test")
|
suggested_email, other_emails = user.suggested_emails(website_name="test")
|
||||||
|
|
Loading…
Reference in a new issue