Louis Mazin d424689e12 big maj
2026-09-24 19:35:37 +02:00

34 lines
619 B
Python

def is_admin(user):
return (
user.is_authenticated
and (
user.is_staff
or user.is_superuser
)
)
def can_edit_note(user, note):
if not user.is_authenticated:
return False
return (
is_admin(user)
or note.author_id == user.id
)
def can_complete_note(user, note):
if not user.is_authenticated:
return False
if note.kind != 'task':
return False
return (
is_admin(user)
or note.author_id == user.id
or note.recipients.filter(
pk=user.pk,
).exists()
)