Skip to content

Commit

Permalink
Update common.py
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-sorrentino committed Feb 3, 2025
1 parent ba93e0f commit 91dbccc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions hushline/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,14 @@ def handle_field_post(username: Username) -> Response | None:
# Create a new field
if field_form.submit.name in request.form:
# Get the highest existing sort_order for this username
max_sort_order = db.session.scalar(
db.select(db.func.coalesce(db.func.max(FieldDefinition.sort_order), 0))
.filter(FieldDefinition.username_id == username.id)
) or 0
max_sort_order = (
db.session.scalar(
db.select(db.func.coalesce(db.func.max(FieldDefinition.sort_order), 0)).filter(
FieldDefinition.username_id == username.id
)
)
or 0
)

field_definition = FieldDefinition(
username,
Expand Down

0 comments on commit 91dbccc

Please sign in to comment.