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
1 merge request!15Resolve "Permissions by group owners"
Pipeline #58662 failed
...@@ -95,7 +95,7 @@ MENUS = { ...@@ -95,7 +95,7 @@ MENUS = {
"validators": [ "validators": [
( (
"aleksis.core.util.predicates.permission_validator", "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: ...@@ -36,3 +36,14 @@ def is_own_voucher(user: User, voucher: Voucher) -> bool:
def is_own_registration(user: User, registration: EventRegistration) -> bool: def is_own_registration(user: User, registration: EventRegistration) -> bool:
"""Predicate which checks if the registration belongs to the user.""" """Predicate which checks if the registration belongs to the user."""
return registration.person == user.person 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 ...@@ -86,6 +86,7 @@ rules.add_perm("paweljong.view_registrations_rule", view_registrations_predicate
# Manage registrations # Manage registrations
manage_registrations_predicate = has_person & ( manage_registrations_predicate = has_person & (
has_global_perm("paweljong.manage_registration") has_global_perm("paweljong.manage_registration")
| is_organiser
| is_own_registration | is_own_registration
| has_any_object("paweljong.manage_registration", EventRegistration) | 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