diff --git a/clockwork_web/browser_routes/settings.py b/clockwork_web/browser_routes/settings.py
index 22176a70..0b92220f 100644
--- a/clockwork_web/browser_routes/settings.py
+++ b/clockwork_web/browser_routes/settings.py
@@ -117,24 +117,13 @@ def route_set_nbr_items_per_page():
# Check if nbr_items_per_page is a positive integer
if type(nbr_items_per_page) == int and nbr_items_per_page > 0:
- if current_user.is_authenticated():
- # If it is, update this number in the current user's settings and
- # retrieve the status code and status message associated to this
- # operation
- (
- status_code,
- status_message,
- ) = current_user.settings_nbr_items_per_page_set(nbr_items_per_page)
- else:
- # Otherwise, return an error
- return (
- render_template_with_user_settings(
- "error.html",
- error_msg=gettext("The user is not authenticated."),
- previous_request_args=previous_request_args,
- ),
- 403, # Forbidden
- )
+ # If it is, update this number in the current user's settings and
+ # retrieve the status code and status message associated to this
+ # operation
+ (
+ status_code,
+ status_message,
+ ) = current_user.settings_nbr_items_per_page_set(nbr_items_per_page)
if status_code == 200:
# If a success has been return, redirect to the settings page
@@ -192,18 +181,7 @@ def route_set_dark_mode():
# Set the dark mode value to True in the current user's web settings and
# retrieve the status code and status message associated to the operation
- if current_user.is_authenticated():
- (status_code, status_message) = current_user.settings_dark_mode_enable()
- else:
- # Otherwise, return an error
- return (
- render_template_with_user_settings(
- "error.html",
- error_msg=gettext("The user is not authenticated."),
- previous_request_args=previous_request_args,
- ),
- 403, # Forbidden
- )
+ (status_code, status_message) = current_user.settings_dark_mode_enable()
if status_code == 200:
# If a success has been returned
@@ -234,20 +212,10 @@ def route_unset_dark_mode():
# Initialize the request arguments (it is further transferred to the HTML)
previous_request_args = {}
- if current_user.is_authenticated():
- # Set the dark mode value to False in the current user's web settings and
- # retrieve the status code and status message associated to the operation
- (status_code, status_message) = current_user.settings_dark_mode_disable()
- else:
- # Otherwise, return an error
- return (
- render_template_with_user_settings(
- "error.html",
- error_msg=gettext("The user is not authenticated."),
- previous_request_args=previous_request_args,
- ),
- 403, # Forbidden
- )
+
+ # Set the dark mode value to False in the current user's web settings and
+ # retrieve the status code and status message associated to the operation
+ (status_code, status_message) = current_user.settings_dark_mode_disable()
if status_code == 200:
# If a success has been returned
@@ -493,25 +461,13 @@ def route_set_date_format():
if date_format:
# Check if the date format is supported
if date_format in get_available_date_formats():
- if current_user.is_authenticated():
- # If the requested date format is expected, update the preferred
- # date format of the current user and retrieve the status code
- # and status message associated to this operation
- (
- status_code,
- status_message,
- ) = current_user.settings_date_format_set(date_format)
-
- else:
- # Otherwise, return an error
- return (
- render_template_with_user_settings(
- "error.html",
- error_msg=gettext("The user is not authenticated."),
- previous_request_args=previous_request_args,
- ),
- 403, # Forbidden
- )
+ # If the requested date format is expected, update the preferred
+ # date format of the current user and retrieve the status code
+ # and status message associated to this operation
+ (
+ status_code,
+ status_message,
+ ) = current_user.settings_date_format_set(date_format)
if status_code == 200:
# If a success has been return, redirect to the home page
@@ -575,24 +531,14 @@ def route_set_time_format():
if time_format:
# Check if the date format is supported
if time_format in get_available_time_formats():
- if current_user.is_authenticated():
- # If the requested time format is expected, update the preferred
- # time format of the current user and retrieve the status code
- # and status message associated to this operation
- (
- status_code,
- status_message,
- ) = current_user.settings_time_format_set(time_format)
- else:
- # Otherwise, return an error
- return (
- render_template_with_user_settings(
- "error.html",
- error_msg=gettext("The user is not authenticated."),
- previous_request_args=previous_request_args,
- ),
- 403, # Forbidden
- )
+
+ # If the requested time format is expected, update the preferred
+ # time format of the current user and retrieve the status code
+ # and status message associated to this operation
+ (
+ status_code,
+ status_message,
+ ) = current_user.settings_time_format_set(time_format)
if status_code == 200:
# If a success has been return, redirect to the home page
diff --git a/clockwork_web/login_routes.py b/clockwork_web/login_routes.py
index 2244d4c7..6772e7b6 100644
--- a/clockwork_web/login_routes.py
+++ b/clockwork_web/login_routes.py
@@ -206,9 +206,9 @@ def route_callback():
from flask import current_app
current_app.logger.debug(
- "called login_user(user) for user with email %s, user.is_authenticated() is %s",
+ "called login_user(user) for user with email %s, user.is_authenticated is %s",
user.mila_email_username,
- user.is_authenticated(),
+ user.is_authenticated,
)
# Send user back to homepage
return redirect(url_for("index"))
diff --git a/clockwork_web/server_app.py b/clockwork_web/server_app.py
index c66017cd..6f396898 100644
--- a/clockwork_web/server_app.py
+++ b/clockwork_web/server_app.py
@@ -148,7 +148,7 @@ def have_same_users(user1: str, user2: str):
# Initialize Babel
def get_locale():
# If the user is authenticated
- if current_user and current_user.is_authenticated():
+ if current_user and current_user.is_authenticated:
return current_user.get_language()
@@ -250,7 +250,7 @@ def index():
where people can click on the "login" button on the web interface.
"""
- if current_user.is_authenticated():
+ if current_user.is_authenticated:
app.logger.debug("in route for '/'; redirecting to jobs/")
return redirect("jobs/")
else:
diff --git a/clockwork_web/templates/base.html b/clockwork_web/templates/base.html
index 11a6d074..bf79e7ea 100644
--- a/clockwork_web/templates/base.html
+++ b/clockwork_web/templates/base.html
@@ -70,7 +70,7 @@
{{ gettext("Alpha version!") }}
{% endif %}
- {% if current_user.is_authenticated() %}
+ {% if current_user.is_authenticated %}