Skip to content
Snippets Groups Projects
Commit ea8ae583 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Check if person is organiser

parent 4c1cfb6d
No related branches found
No related tags found
No related merge requests found
......@@ -95,7 +95,7 @@ MENUS = {
"validators": [
(
"aleksis.core.util.predicates.permission_validator",
"paweljong.view_registrations_rule",
"paweljong.manage_registrations",
)
],
},
......
......@@ -36,3 +36,14 @@ def is_own_voucher(user: User, voucher: Voucher) -> bool:
def is_own_registration(user: User, registration: EventRegistration) -> bool:
"""Predicate which checks if the registration belongs to the user."""
return registration.person == user.person
@predicate
def is_organiser(user: User, registration: EventRegistration) -> bool:
"""Predicate which checks if the registration belongs to the user."""
return user.person in registration.event.owners.all()
@predicate
def is_participant(user: User, registration: EventRegistration) -> bool:
"""Predicate which checks if the registration belongs to the user."""
return user.person in registration.event.members.all()
......@@ -86,6 +86,7 @@ rules.add_perm("paweljong.view_registrations_rule", view_registrations_predicate
# Manage registrations
manage_registrations_predicate = has_person & (
has_global_perm("paweljong.manage_registration")
| is_organiser
| is_own_registration
| has_any_object("paweljong.manage_registration", EventRegistration)
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment