Refactor logic out of Jinja before making more complicated

To keep the conditionals in the Jinja template more readable, this
commit moves the logic into a method on the model, where it can
be split over multiple statements and lines.
This commit is contained in:
Chris Hill-Scott
2022-05-04 16:40:29 +01:00
parent b4b7ecb2aa
commit 5ac6efc580
2 changed files with 11 additions and 1 deletions

View File

@@ -440,6 +440,13 @@ class User(JSONModel, UserMixin):
def complete_webauthn_login_attempt(self, is_successful=True):
return user_api_client.complete_webauthn_login_attempt(self.id, is_successful)
def is_editable_by(self, other_user):
if other_user == self:
return False
if self.state == 'active':
return True
return False
class InvitedUser(JSONModel):
@@ -575,6 +582,9 @@ class InvitedUser(JSONModel):
# only used on the manage users page to display the count, so okay to not be fully fledged for now
return [{'id': x} for x in self.folder_permissions]
def is_editable_by(self, other):
return False
class InvitedOrgUser(JSONModel):