black formatted
This commit is contained in:
parent
3811bb6880
commit
f3719aa0f0
|
@ -9,7 +9,14 @@ from app.config import HIGHLIGHT_GEN_EMAIL_ID
|
||||||
from app.dashboard.base import dashboard_bp
|
from app.dashboard.base import dashboard_bp
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import GenEmail, ClientUser, ForwardEmail, ForwardEmailLog, DeletedAlias, AliasGeneratorEnum
|
from app.models import (
|
||||||
|
GenEmail,
|
||||||
|
ClientUser,
|
||||||
|
ForwardEmail,
|
||||||
|
ForwardEmailLog,
|
||||||
|
DeletedAlias,
|
||||||
|
AliasGeneratorEnum,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -57,10 +64,14 @@ def index():
|
||||||
|
|
||||||
elif request.form.get("form-name") == "create-random-email":
|
elif request.form.get("form-name") == "create-random-email":
|
||||||
if current_user.can_create_new_alias():
|
if current_user.can_create_new_alias():
|
||||||
scheme = int(request.form.get("generator_scheme") or current_user.alias_generator)
|
scheme = int(
|
||||||
|
request.form.get("generator_scheme") or current_user.alias_generator
|
||||||
|
)
|
||||||
if not scheme or not AliasGeneratorEnum.has_value(scheme):
|
if not scheme or not AliasGeneratorEnum.has_value(scheme):
|
||||||
scheme = current_user.alias_generator
|
scheme = current_user.alias_generator
|
||||||
gen_email = GenEmail.create_new_random(user_id=current_user.id, scheme=scheme)
|
gen_email = GenEmail.create_new_random(
|
||||||
|
user_id=current_user.id, scheme=scheme
|
||||||
|
)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
LOG.d("generate new email %s for user %s", gen_email, current_user)
|
LOG.d("generate new email %s for user %s", gen_email, current_user)
|
||||||
|
@ -102,9 +113,9 @@ def index():
|
||||||
|
|
||||||
client_users = (
|
client_users = (
|
||||||
ClientUser.filter_by(user_id=current_user.id)
|
ClientUser.filter_by(user_id=current_user.id)
|
||||||
.options(joinedload(ClientUser.client))
|
.options(joinedload(ClientUser.client))
|
||||||
.options(joinedload(ClientUser.gen_email))
|
.options(joinedload(ClientUser.gen_email))
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
sorted(client_users, key=lambda cu: cu.client.name)
|
sorted(client_users, key=lambda cu: cu.client.name)
|
||||||
|
@ -115,7 +126,7 @@ def index():
|
||||||
aliases=get_alias_info(current_user.id, query, highlight_gen_email_id),
|
aliases=get_alias_info(current_user.id, query, highlight_gen_email_id),
|
||||||
highlight_gen_email_id=highlight_gen_email_id,
|
highlight_gen_email_id=highlight_gen_email_id,
|
||||||
query=query,
|
query=query,
|
||||||
AliasGeneratorEnum=AliasGeneratorEnum
|
AliasGeneratorEnum=AliasGeneratorEnum,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,8 +165,8 @@ def get_alias_info(user_id, query=None, highlight_gen_email_id=None) -> [AliasIn
|
||||||
# also add alias that has no forward email or log
|
# also add alias that has no forward email or log
|
||||||
q = (
|
q = (
|
||||||
db.session.query(GenEmail)
|
db.session.query(GenEmail)
|
||||||
.filter(GenEmail.email.notin_(aliases.keys()))
|
.filter(GenEmail.email.notin_(aliases.keys()))
|
||||||
.filter(GenEmail.user_id == user_id)
|
.filter(GenEmail.user_id == user_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
if query:
|
if query:
|
||||||
|
|
Loading…
Reference in a new issue