From d89830af613ee463379b213194eecc183cef1672 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Mon, 24 Aug 2020 21:00:13 +0200 Subject: [PATCH] Fix anonymous user has no modified_flag error --- cps/web.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cps/web.py b/cps/web.py index a2804d70..02d7e6f4 100644 --- a/cps/web.py +++ b/cps/web.py @@ -473,7 +473,10 @@ def update_view(): #visibility = json.loads(current_user.view_settings) current_user.view_settings['series_view'] = to_save["series_view"] # current_user.view_settings = json.dumps(visibility) - flag_modified(current_user, "view_settings") + try: + flag_modified(current_user, "view_settings") + except AttributeError: + pass ub.session.commit() except InvalidRequestError: log.error("Invalid request received: %r ", request, ) @@ -626,7 +629,10 @@ def render_books_list(data, sort, book_id, page): else: try: current_user.view_settings[data] = sort - flag_modified(current_user, "view_settings") + try: + flag_modified(current_user, "view_settings") + except AttributeError: + pass ub.session.commit() except InvalidRequestError: log.error("Invalid request received: %r ", request, ) @@ -1015,7 +1021,10 @@ def update_table_settings(): # ToDo: Save table settings current_user.view_settings['table'] = json.loads(request.data) try: - flag_modified(current_user, "view_settings") + try: + flag_modified(current_user, "view_settings") + except AttributeError: + pass ub.session.commit() except InvalidRequestError: log.error("Invalid request received: %r ", request, )