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
50459916
Verified
Commit
50459916
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Rewrite some rules more efficient
parent
24ef1e73
No related branches found
No related tags found
1 merge request
!90
Performance optimizations
Pipeline
#3677
passed
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/util/predicates.py
+10
-3
10 additions, 3 deletions
aleksis/apps/alsijil/util/predicates.py
aleksis/apps/alsijil/views.py
+1
-1
1 addition, 1 deletion
aleksis/apps/alsijil/views.py
with
11 additions
and
4 deletions
aleksis/apps/alsijil/util/predicates.py
+
10
−
3
View file @
50459916
...
...
@@ -38,7 +38,10 @@ def is_lesson_participant(user: User, obj: LessonPeriod) -> bool:
the groups linked to the given LessonPeriod.
"""
if
hasattr
(
obj
,
"
lesson
"
):
return
obj
.
lesson
.
groups
.
filter
(
members
=
user
.
person
).
exists
()
for
group
in
obj
.
lesson
.
groups
.
all
():
if
user
.
person
in
group
.
members
.
all
():
return
True
return
False
return
True
...
...
@@ -51,7 +54,11 @@ def is_lesson_parent_group_owner(user: User, obj: LessonPeriod) -> bool:
any parent groups of any groups of the given LessonPeriods lesson.
"""
if
hasattr
(
obj
,
"
lesson
"
):
return
obj
.
lesson
.
groups
.
filter
(
parent_groups__owners
=
user
.
person
).
exists
()
for
group
in
obj
.
lesson
.
groups
.
all
():
for
parent_group
in
group
.
parent_groups
.
all
():
if
user
.
person
in
parent_group
.
owners
.
all
():
return
True
return
False
return
True
...
...
@@ -63,7 +70,7 @@ def is_group_owner(user: User, obj: Union[Group, Person]) -> bool:
If there isn
'
t provided a group, it will return `False`.
"""
if
isinstance
(
obj
,
Group
):
if
obj
.
owners
.
filter
(
pk
=
user
.
person
.
pk
).
exists
():
if
user
.
person
in
obj
.
owners
.
all
():
return
True
return
False
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/views.py
+
1
−
1
View file @
50459916
...
...
@@ -179,7 +179,7 @@ def week_view(
instance
=
get_instance_by_pk
(
request
,
year
,
week
,
type_
,
id_
)
lesson_periods
=
LessonPeriod
.
objects
.
in_week
(
wanted_week
)
lesson_periods
=
LessonPeriod
.
objects
.
in_week
(
wanted_week
)
.
prefetch_related
(
"
lesson__groups__members
"
,
"
lesson__groups__parent_groups
"
,
"
lesson__groups__parent_groups__owners
"
)
lesson_periods_query_exists
=
True
if
type_
and
id_
:
...
...
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