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
47ab315d
Verified
Commit
47ab315d
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Fix defaults of some predicates (True to False) and catch side effect of this change
parent
31fed539
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!49
Resolve "Add rules and permissions"
Pipeline
#4072
failed
4 years ago
Stage: test
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/rules.py
+2
-0
2 additions, 0 deletions
aleksis/apps/alsijil/rules.py
aleksis/apps/alsijil/util/predicates.py
+10
-4
10 additions, 4 deletions
aleksis/apps/alsijil/util/predicates.py
with
12 additions
and
4 deletions
aleksis/apps/alsijil/rules.py
+
2
−
0
View file @
47ab315d
...
@@ -18,6 +18,7 @@ from .util.predicates import (
...
@@ -18,6 +18,7 @@ from .util.predicates import (
is_lesson_parent_group_owner
,
is_lesson_parent_group_owner
,
is_lesson_participant
,
is_lesson_participant
,
is_lesson_teacher
,
is_lesson_teacher
,
is_none
,
is_own_personal_note
,
is_own_personal_note
,
is_person_group_owner
,
is_person_group_owner
,
is_person_primary_group_owner
,
is_person_primary_group_owner
,
...
@@ -29,6 +30,7 @@ from .util.predicates import (
...
@@ -29,6 +30,7 @@ from .util.predicates import (
# View lesson
# View lesson
view_lesson_predicate
=
has_person
&
(
view_lesson_predicate
=
has_person
&
(
has_global_perm
(
"
alsijil.view_lesson
"
)
has_global_perm
(
"
alsijil.view_lesson
"
)
|
is_none
# View is opened as "Current lesson"
|
is_lesson_teacher
|
is_lesson_teacher
|
is_lesson_participant
|
is_lesson_participant
|
is_lesson_parent_group_owner
|
is_lesson_parent_group_owner
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/util/predicates.py
+
10
−
4
View file @
47ab315d
from
typing
import
Union
from
typing
import
Any
,
Union
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
...
@@ -12,6 +12,12 @@ from aleksis.core.util.predicates import check_object_permission
...
@@ -12,6 +12,12 @@ from aleksis.core.util.predicates import check_object_permission
from
..models
import
PersonalNote
from
..models
import
PersonalNote
@predicate
def
is_none
(
user
:
User
,
obj
:
Any
)
->
bool
:
"""
Predicate that checks if the provided object is None-like.
"""
return
bool
(
obj
)
@predicate
@predicate
def
is_lesson_teacher
(
user
:
User
,
obj
:
LessonPeriod
)
->
bool
:
def
is_lesson_teacher
(
user
:
User
,
obj
:
LessonPeriod
)
->
bool
:
"""
Predicate for teachers of a lesson.
"""
Predicate for teachers of a lesson.
...
@@ -24,7 +30,7 @@ def is_lesson_teacher(user: User, obj: LessonPeriod) -> bool:
...
@@ -24,7 +30,7 @@ def is_lesson_teacher(user: User, obj: LessonPeriod) -> bool:
if
sub
and
sub
in
user
.
person
.
lesson_substitutions
.
all
():
if
sub
and
sub
in
user
.
person
.
lesson_substitutions
.
all
():
return
True
return
True
return
user
.
person
in
obj
.
lesson
.
teachers
.
all
()
return
user
.
person
in
obj
.
lesson
.
teachers
.
all
()
return
Tru
e
return
Fals
e
@predicate
@predicate
...
@@ -36,7 +42,7 @@ def is_lesson_participant(user: User, obj: LessonPeriod) -> bool:
...
@@ -36,7 +42,7 @@ def is_lesson_participant(user: User, obj: LessonPeriod) -> bool:
"""
"""
if
hasattr
(
obj
,
"
lesson
"
):
if
hasattr
(
obj
,
"
lesson
"
):
return
obj
.
lesson
.
groups
.
filter
(
members
=
user
.
person
).
exists
()
return
obj
.
lesson
.
groups
.
filter
(
members
=
user
.
person
).
exists
()
return
Tru
e
return
Fals
e
@predicate
@predicate
...
@@ -49,7 +55,7 @@ def is_lesson_parent_group_owner(user: User, obj: LessonPeriod) -> bool:
...
@@ -49,7 +55,7 @@ def is_lesson_parent_group_owner(user: User, obj: LessonPeriod) -> bool:
"""
"""
if
hasattr
(
obj
,
"
lesson
"
):
if
hasattr
(
obj
,
"
lesson
"
):
return
obj
.
lesson
.
groups
.
filter
(
parent_groups__owners
=
user
.
person
).
exists
()
return
obj
.
lesson
.
groups
.
filter
(
parent_groups__owners
=
user
.
person
).
exists
()
return
Tru
e
return
Fals
e
@predicate
@predicate
...
...
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