Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Alsijil
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Alsijil
Commits
6e9a0f60
Commit
6e9a0f60
authored
4 years ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
Add menu validators using rules
parent
07ca4f09
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!49
Resolve "Add rules and permissions"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/menus.py
+24
-4
24 additions, 4 deletions
aleksis/apps/alsijil/menus.py
aleksis/apps/alsijil/rules.py
+19
-3
19 additions, 3 deletions
aleksis/apps/alsijil/rules.py
with
43 additions
and
7 deletions
aleksis/apps/alsijil/menus.py
+
24
−
4
View file @
6e9a0f60
...
...
@@ -16,25 +16,45 @@ MENUS = {
"
name
"
:
_
(
"
Current lesson
"
),
"
url
"
:
"
lesson
"
,
"
icon
"
:
"
alarm
"
,
"
validators
"
:
[
"
menu_generator.validators.is_authenticated
"
],
"
validators
"
:
[
(
"
aleksis.core.util.predicates.permission_validator
"
,
"
alsijil.view_lesson_menu
"
,
),
],
},
{
"
name
"
:
_
(
"
Current week
"
),
"
url
"
:
"
week_view
"
,
"
icon
"
:
"
view_week
"
,
"
validators
"
:
[
"
menu_generator.validators.is_authenticated
"
],
"
validators
"
:
[
(
"
aleksis.core.util.predicates.permission_validator
"
,
"
alsijil.view_week_menu
"
,
),
],
},
{
"
name
"
:
_
(
"
Register absence
"
),
"
url
"
:
"
register_absence
"
,
"
icon
"
:
"
rate_review
"
,
"
validators
"
:
[
"
menu_generator.validators.is_superuser
"
],
"
validators
"
:
[
(
"
aleksis.core.util.predicates.permission_validator
"
,
"
alsijil.view_register_absence
"
,
),
],
},
{
"
name
"
:
_
(
"
Personal note filters
"
),
"
url
"
:
"
list_personal_note_filters
"
,
"
icon
"
:
"
filter_list
"
,
"
validators
"
:
[
"
menu_generator.validators.is_superuser
"
],
"
validators
"
:
[
(
"
aleksis.core.util.predicates.permission_validator
"
,
"
alsijil.view_personal_note_filters
"
,
),
],
},
],
}
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/rules.py
+
19
−
3
View file @
6e9a0f60
from
rules
import
add_perm
from
aleksis.core.models
import
Person
from
aleksis.core.util.predicates
import
(
has_any_object
,
has_global_perm
,
has_object_perm
,
has_person
,
is_current_person
,
)
from
.models
import
PersonalNoteFilter
from
.util.predicates
import
(
has_lesson_group_object_perm
,
has_person_group_object_perm
,
...
...
@@ -28,6 +31,9 @@ view_lesson_predicate = has_person & (
)
add_perm
(
"
alsijil.view_lesson
"
,
view_lesson_predicate
)
# View lesson in menu
add_perm
(
"
alsijil.view_lesson_menu
"
,
has_person
)
# View lesson personal notes
view_lesson_personal_notes_predicate
=
has_person
&
(
has_global_perm
(
"
alsijil.view_personalnote
"
)
...
...
@@ -73,6 +79,9 @@ view_week_predicate = has_person & (
)
add_perm
(
"
alsijil.view_week
"
,
view_week_predicate
)
# View week overview in menu
add_perm
(
"
alsijil.view_week_menu
"
,
has_person
)
# View week personal notes
view_week_personal_notes_predicate
=
has_person
&
(
has_global_perm
(
"
alsijil.view_personalnote
"
)
...
...
@@ -81,6 +90,12 @@ view_week_personal_notes_predicate = has_person & (
)
add_perm
(
"
alsijil.view_week_personalnote
"
,
view_week_personal_notes_predicate
)
# View register absence page
view_register_absence_predicate
=
has_person
&
(
has_any_object
(
"
alsijil.register_absence
"
,
Person
)
)
add_perm
(
"
alsijil.view_register_absence
"
,
view_register_absence_predicate
)
# Register absence
register_absence_predicate
=
has_person
&
(
has_global_perm
(
"
alsijil.register_absence
"
)
...
...
@@ -99,10 +114,11 @@ view_full_register_predicate = has_person & (
add_perm
(
"
alsijil.view_full_register
"
,
view_full_register_predicate
)
# View all personal note filters
list_personal_note_filters_predicate
=
has_person
&
has_global_perm
(
"
alsijil.view_personal_note_filter
"
view_personal_note_filters_predicate
=
has_person
&
(
has_global_perm
(
"
alsijil.view_personalnotefilter
"
)
|
has_any_object
(
"
alsijil.view_personalnotefilter
"
,
PersonalNoteFilter
)
)
add_perm
(
"
alsijil.view_personal_note_filters
"
,
list
_personal_note_filters_predicate
)
add_perm
(
"
alsijil.view_personal_note_filters
"
,
view
_personal_note_filters_predicate
)
# Edit personal note filter
edit_personal_note_filter_predicate
=
has_person
&
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment