Add other sorting options: A-Z, Z-A, new-old, old-new

This commit is contained in:
Son NK 2020-04-26 12:25:12 +02:00
parent 5c48f82f41
commit 4c64393df1
3 changed files with 16 additions and 3 deletions

View File

@ -141,6 +141,12 @@ def get_alias_infos_with_pagination_v2(
if sort == "old2new":
q = q.order_by(Alias.created_at)
elif sort == "new2old":
q = q.order_by(Alias.created_at.desc())
elif sort == "a2z":
q = q.order_by(Alias.email)
elif sort == "z2a":
q = q.order_by(Alias.email.desc())
else:
# default sorting
q = q.order_by(latest_activity.desc())

View File

@ -70,7 +70,16 @@
Sort by most recent activity
</option>
<option value="old2new" {% if sort == "old2new" %} selected {% endif %}>
Oldest Alias to Newest
Alias Old-Recent
</option>
<option value="old2new" {% if sort == "new2old" %} selected {% endif %}>
Alias Recent-Old
</option>
<option value="a2z" {% if sort == "a2z" %} selected {% endif %}>
Alias A-Z
</option>
<option value="z2a" {% if sort == "z2a" %} selected {% endif %}>
Alias Z-A
</option>
</select>

View File

@ -3,7 +3,6 @@ from flask_login import login_required, current_user
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import joinedload
from app import email_utils
from app.api.serializer import get_alias_infos_with_pagination_v2
from app.dashboard.base import dashboard_bp
from app.extensions import db
@ -13,7 +12,6 @@ from app.models import (
ClientUser,
DeletedAlias,
AliasGeneratorEnum,
Mailbox,
)