Skip to content

Commit

Permalink
minor routes improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
brassy-endomorph committed Sep 17, 2024
1 parent a73e818 commit 92bf51b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hushline/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def register() -> Response | str | tuple[Response | str, int]:
400,
)

if db.session.query(exists(Username).where(Username.username == username)).scalar():
if db.session.query(exists(Username).where(Username._username == username)).scalar():
flash("💔 Username already taken.", "error")
return (
render_template(
Expand Down
4 changes: 2 additions & 2 deletions hushline/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ async def index() -> str | Response:

# Check if user is admin and add admin-specific data
if user.is_admin:
user_count = db.session.scalar(db.func.count(User.id))
two_fa_count = db.session.scalar(
db.select(db.func.count(User.id).filter(User._totp_secret.isnot(None)))
)
Expand All @@ -262,9 +261,10 @@ async def index() -> str | Response:
.filter(User._pgp_key != "")
)
)
user_count = len(all_users)
two_fa_percentage = (two_fa_count / user_count * 100) if user_count else 0
pgp_key_percentage = (pgp_key_count / user_count * 100) if user_count else 0
all_users = list(User.query.all())
all_users = list(User.query.join(Username).order_by(Username._username).all())

# Prepopulate form fields
email_forwarding_form.forwarding_enabled.data = user.email is not None
Expand Down

0 comments on commit 92bf51b

Please sign in to comment.