From f2ac9d356b7f122abe3152efc477635969207b3e Mon Sep 17 00:00:00 2001 From: Jeremy Fisher Date: Tue, 19 Sep 2023 17:56:05 -0400 Subject: [PATCH] Add send to ereader permission --- cps/constants.py | 2 ++ cps/templates/admin.html | 2 ++ cps/templates/detail.html | 2 ++ cps/ub.py | 3 +++ 4 files changed, 9 insertions(+) diff --git a/cps/constants.py b/cps/constants.py index c7d3a6ce..b557d33b 100644 --- a/cps/constants.py +++ b/cps/constants.py @@ -63,6 +63,7 @@ ROLE_ANONYMOUS = 1 << 5 ROLE_EDIT_SHELFS = 1 << 6 ROLE_DELETE_BOOKS = 1 << 7 ROLE_VIEWER = 1 << 8 +ROLE_SEND_TO_EREADER = 1 << 9 ALL_ROLES = { "admin_role": ROLE_ADMIN, @@ -73,6 +74,7 @@ ALL_ROLES = { "edit_shelf_role": ROLE_EDIT_SHELFS, "delete_role": ROLE_DELETE_BOOKS, "viewer_role": ROLE_VIEWER, + "send_to_ereader": ROLE_SEND_TO_EREADER, } DETAIL_RANDOM = 1 << 0 diff --git a/cps/templates/admin.html b/cps/templates/admin.html index ac124fe8..4cb69e21 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -20,6 +20,7 @@ {{_('Upload')}} {% endif %} {{_('Download')}} + {{_('Send to eReader')}} {{_('View Books')}} {{_('Edit')}} {{_('Delete')}} @@ -38,6 +39,7 @@ {{ display_bool_setting(user.role_upload()) }} {% endif %} {{ display_bool_setting(user.role_download()) }} + {{ display_bool_setting(user.role_send_to_ereader()) }} {{ display_bool_setting(user.role_viewer()) }} {{ display_bool_setting(user.role_edit()) }} {{ display_bool_setting(user.role_delete_books()) }} diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 30430663..8c9d2df6 100755 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -43,6 +43,8 @@ {% endif %} {% endif %} + {% endif %} + {% if current_user.role_send_to_ereader() %} {% if current_user.kindle_mail and entry.email_share_list %} {% if entry.email_share_list.__len__() == 1 %} diff --git a/cps/ub.py b/cps/ub.py index db8dba03..9d2706a0 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -160,6 +160,9 @@ class UserBase: def role_viewer(self): return self._has_role(constants.ROLE_VIEWER) + def role_send_to_ereader(self): + return self._has_role(constants.ROLE_SEND_TO_EREADER) + @property def is_active(self): return True