Skip to content
Snippets Groups Projects
Verified Commit 961ea376 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add some rules

parent a92d23de
No related branches found
No related tags found
1 merge request!7Resolve "Implement Absence model based on FreeBusy"
import rules import rules
from aleksis.apps.kolego.models.absence import Absence, AbsenceReason
from aleksis.core.util.predicates import ( from aleksis.core.util.predicates import (
has_any_object,
has_global_perm, has_global_perm,
has_object_perm, has_object_perm,
has_person, has_person,
) )
view_absences_predicate = has_person & (
has_global_perm("kolego.view_absence") | has_any_object("kolego.view_absence", Absence)
)
rules.add_perm("kolego.view_absences_rule", view_absences_predicate)
view_absence_predicate = has_person & (
has_global_perm("kolego.view_absence") | has_object_perm("kolego.view_absence")
)
rules.add_perm("kolego.view_absence_rule", view_absence_predicate)
edit_absence_predicate = has_person & ( edit_absence_predicate = has_person & (
has_global_perm("kolego.change_absence") | has_object_perm("kolego.change_absence") has_global_perm("kolego.change_absence") | has_object_perm("kolego.change_absence")
) )
...@@ -16,6 +29,17 @@ delete_absence_predicate = has_person & ( ...@@ -16,6 +29,17 @@ delete_absence_predicate = has_person & (
) )
rules.add_perm("kolego.delete_absence_rule", delete_absence_predicate) rules.add_perm("kolego.delete_absence_rule", delete_absence_predicate)
view_absencereasons_predicate = has_person & (
has_global_perm("kolego.view_absencereason")
| has_any_object("kolego.view_absencereason", AbsenceReason)
)
rules.add_perm("kolego.view_absencereasons_rule", view_absencereasons_predicate)
view_absencereason_predicate = has_person & (
has_global_perm("kolego.view_absencereason") | has_object_perm("kolego.view_absencereason")
)
rules.add_perm("kolego.view_absencereason_rule", view_absencereason_predicate)
edit_absencereason_predicate = has_person & ( edit_absencereason_predicate = has_person & (
has_global_perm("kolego.change_absencereason") | has_object_perm("kolego.change_absencereason") has_global_perm("kolego.change_absencereason") | has_object_perm("kolego.change_absencereason")
) )
......
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