Skip to content

Commit 21aec97

Browse files
committed
Petition.is_allowed_to_edit(): Code cleanup
The code was a mess, if (x) return True else return False => return x
1 parent 9b36910 commit 21aec97

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

pytition/petition/models.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -382,23 +382,18 @@ def is_allowed_to_edit(self, user):
382382
Check if a user is allowed to edit this petition
383383
"""
384384
if self.owner_type == "user":
385-
if self.user == user:
386-
# The user is the owner of the petition
387-
return True
388-
else:
389-
return False
390-
else:
391-
# But it is an org petition
392-
try:
393-
perm = Permission.objects.get(
394-
organization=self.org,
395-
user=user
396-
)
397-
except Permission.DoesNotExist:
398-
# No such permission, denied
399-
return False
400-
else:
401-
return perm.can_modify_petitions
385+
# The user is the owner of the petition
386+
return self.user == user
387+
# But it is an org petition
388+
try:
389+
perm = Permission.objects.get(
390+
organization=self.org,
391+
user=user
392+
)
393+
except Permission.DoesNotExist:
394+
# No such permission, denied
395+
return False
396+
return perm.can_modify_petitions
402397

403398
@property
404399
def url(self):

0 commit comments

Comments
 (0)