Skip to content

Commit

Permalink
Autoset shouldn't accept a user parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Oct 27, 2023
1 parent e63ed8d commit 801358b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion funnel/views/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def edit(self) -> ReturnView:
form = AccountForm(obj=current_auth.user)
if form.validate_on_submit():
form.populate_obj(current_auth.user)
autoset_timezone_and_locale(current_auth.user)
autoset_timezone_and_locale()

db.session.commit()
user_data_changed.send(current_auth.user, changes=['profile'])
Expand Down
6 changes: 4 additions & 2 deletions funnel/views/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from werkzeug.routing import BuildError, RequestRedirect

from baseframe import cache, statsd
from coaster.auth import current_auth
from coaster.sqlalchemy import RoleMixin
from coaster.utils import utcnow

Expand Down Expand Up @@ -250,8 +251,9 @@ def get_scheme_netloc(uri: str) -> tuple[str, str]:
return (parsed_uri.scheme, parsed_uri.netloc)


def autoset_timezone_and_locale(user: Account) -> None:
# Set the user's timezone and locale automatically if required
def autoset_timezone_and_locale() -> None:
"""Set the current user's timezone and locale automatically if required."""
user = current_auth.user
if (
user.auto_timezone
or not user.timezone
Expand Down
2 changes: 1 addition & 1 deletion funnel/views/login_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def login_internal(
current_auth.cookie['sessionid'] = login_session.buid
current_auth.cookie['userid'] = user.buid
session.permanent = True
autoset_timezone_and_locale(user)
autoset_timezone_and_locale()
user_login.send(user)


Expand Down

0 comments on commit 801358b

Please sign in to comment.