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
5675ce4f
Commit
5675ce4f
authored
11 months ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
Add coursebook menu rule
parent
ce49fbab
No related branches found
No related tags found
2 merge requests
!352
Draft: Resolve "Add dialog with each lesson's students"
,
!350
Resolve "Add simple course book list"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/apps/alsijil/frontend/index.js
+2
-2
2 additions, 2 deletions
aleksis/apps/alsijil/frontend/index.js
aleksis/apps/alsijil/rules.py
+7
-0
7 additions, 0 deletions
aleksis/apps/alsijil/rules.py
aleksis/apps/alsijil/util/predicates.py
+9
-0
9 additions, 0 deletions
aleksis/apps/alsijil/util/predicates.py
with
18 additions
and
2 deletions
aleksis/apps/alsijil/frontend/index.js
+
2
−
2
View file @
5675ce4f
...
...
@@ -411,7 +411,7 @@ export default {
iconActive
:
"
mdi-book-education
"
,
titleKey
:
"
alsijil.coursebook.menu_title
"
,
toolbarTitle
:
"
alsijil.coursebook.menu_title
"
,
permission
:
"
core.view_calendar_feed
_rule
"
,
permission
:
"
alsijil.view_documentations_menu
_rule
"
,
},
children
:
[
{
...
...
@@ -421,7 +421,7 @@ export default {
meta
:
{
titleKey
:
"
alsijil.coursebook.menu_title
"
,
toolbarTitle
:
"
alsijil.coursebook.menu_title
"
,
permission
:
"
core.view_calendar_feed
_rule
"
,
permission
:
"
alsijil.view_documentations_menu
_rule
"
,
fullWidth
:
true
,
},
},
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/rules.py
+
7
−
0
View file @
5675ce4f
...
...
@@ -13,6 +13,7 @@ from aleksis.core.util.predicates import (
from
.util.predicates
import
(
can_edit_documentation
,
can_view_documentation
,
can_view_any_documentation
,
has_lesson_group_object_perm
,
has_person_group_object_perm
,
has_personal_note_group_perm
,
...
...
@@ -382,6 +383,12 @@ view_documentations_for_group_predicate = has_person & (
)
add_perm
(
"
alsijil.view_documentations_for_group_rule
"
,
view_documentations_for_group_predicate
)
view_documentations_menu_predicate
=
has_person
&
(
has_global_perm
(
"
alsijil.view_documentation
"
)
|
can_view_any_documentation
)
add_perm
(
"
alsijil.view_documentations_menu_rule
"
,
view_documentations_menu_predicate
)
view_documentations_for_teacher_predicate
=
has_person
&
(
has_global_perm
(
"
alsijil.view_documentation
"
)
|
is_current_person
)
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/util/predicates.py
+
9
−
0
View file @
5675ce4f
from
typing
import
Any
,
Union
from
django.contrib.auth.models
import
User
from
django.db.models
import
Prefetch
,
Q
from
django.utils.timezone
import
localdate
,
localtime
from
rules
import
predicate
...
...
@@ -417,6 +418,14 @@ def can_view_documentation(user: User, obj: Documentation):
return
False
@predicate
def
can_view_any_documentation
(
user
:
User
):
"""
Predicate which checks if the user is allowed to view any documentation.
"""
allowed_lesson_events
=
LessonEvent
.
objects
.
related_to_person
(
user
.
person
)
return
Documentation
.
objects
.
filter
(
Q
(
teachers
=
user
.
person
)
|
Q
(
lesson_event__in
=
allowed_lesson_events
)
|
Q
(
course__teachers
=
user
.
person
)).
exists
()
@predicate
def
can_edit_documentation
(
user
:
User
,
obj
:
Documentation
):
"""
Predicate which checks if the user is allowed to edit or delete a documentation.
"""
...
...
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