rename can_create_new_custom_alias -> can_create_new_alias
This commit is contained in:
parent
873133838d
commit
8f04f8ae0f
|
@ -31,7 +31,7 @@ def options():
|
||||||
|
|
||||||
ret = {
|
ret = {
|
||||||
"existing": [ge.email for ge in GenEmail.query.filter_by(user_id=user.id)],
|
"existing": [ge.email for ge in GenEmail.query.filter_by(user_id=user.id)],
|
||||||
"can_create_custom": user.can_create_new_custom_alias(),
|
"can_create_custom": user.can_create_new_alias(),
|
||||||
}
|
}
|
||||||
|
|
||||||
# recommendation alias if exist
|
# recommendation alias if exist
|
||||||
|
|
|
@ -26,7 +26,7 @@ def new_custom_alias():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
user = g.user
|
user = g.user
|
||||||
if not user.can_create_new_custom_alias():
|
if not user.can_create_new_alias():
|
||||||
LOG.d("user %s cannot create custom alias", user)
|
LOG.d("user %s cannot create custom alias", user)
|
||||||
return (
|
return (
|
||||||
jsonify(
|
jsonify(
|
||||||
|
|
|
@ -13,7 +13,7 @@ from app.utils import convert_to_id, random_word
|
||||||
@login_required
|
@login_required
|
||||||
def custom_alias():
|
def custom_alias():
|
||||||
# check if user has the right to create custom alias
|
# check if user has the right to create custom alias
|
||||||
if not current_user.can_create_new_custom_alias():
|
if not current_user.can_create_new_alias():
|
||||||
# notify admin
|
# notify admin
|
||||||
LOG.error("user %s tries to create custom alias", current_user)
|
LOG.error("user %s tries to create custom alias", current_user)
|
||||||
flash("ony premium user can choose custom alias", "warning")
|
flash("ony premium user can choose custom alias", "warning")
|
||||||
|
|
|
@ -50,7 +50,7 @@ def index():
|
||||||
)
|
)
|
||||||
|
|
||||||
elif request.form.get("form-name") == "create-custom-email":
|
elif request.form.get("form-name") == "create-custom-email":
|
||||||
if current_user.can_create_new_custom_alias():
|
if current_user.can_create_new_alias():
|
||||||
return redirect(url_for("dashboard.custom_alias"))
|
return redirect(url_for("dashboard.custom_alias"))
|
||||||
else:
|
else:
|
||||||
flash(
|
flash(
|
||||||
|
|
|
@ -130,7 +130,7 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def can_create_new_custom_alias(self):
|
def can_create_new_alias(self):
|
||||||
if self.is_premium():
|
if self.is_premium():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
website_name = convert_to_id(website_name)
|
website_name = convert_to_id(website_name)
|
||||||
|
|
||||||
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_custom_alias():
|
if self.can_create_new_alias():
|
||||||
suggested_gen_email = GenEmail.create_custom_alias(
|
suggested_gen_email = GenEmail.create_custom_alias(
|
||||||
self.id, prefix=website_name
|
self.id, prefix=website_name
|
||||||
).email
|
).email
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
{% if current_user.can_create_new_custom_alias() %}
|
{% if current_user.can_create_new_alias() %}
|
||||||
<div class="mt-2">OR</div>
|
<div class="mt-2">OR</div>
|
||||||
<div style="display: flex; align-items: center" class="mt-2">
|
<div style="display: flex; align-items: center" class="mt-2">
|
||||||
<input class="form-control"
|
<input class="form-control"
|
||||||
|
|
|
@ -152,7 +152,7 @@ def authorize():
|
||||||
gen_email = None
|
gen_email = None
|
||||||
if custom_email_prefix:
|
if custom_email_prefix:
|
||||||
# check if user can generate custom email
|
# check if user can generate custom email
|
||||||
if not current_user.can_create_new_custom_alias():
|
if not current_user.can_create_new_alias():
|
||||||
raise Exception(f"User {current_user} cannot create custom email")
|
raise Exception(f"User {current_user} cannot create custom email")
|
||||||
|
|
||||||
email = f"{convert_to_id(custom_email_prefix)}.{email_suffix}@{EMAIL_DOMAIN}"
|
email = f"{convert_to_id(custom_email_prefix)}.{email_suffix}@{EMAIL_DOMAIN}"
|
||||||
|
|
Loading…
Reference in a new issue