Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
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-Chronos
Commits
d0355a61
Commit
d0355a61
authored
3 years ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
Use optional type annotations
parent
c4ccb64d
No related branches found
No related tags found
1 merge request
!113
Resolve "Review permissions"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/chronos/util/chronos_helpers.py
+9
-4
9 additions, 4 deletions
aleksis/apps/chronos/util/chronos_helpers.py
with
9 additions
and
4 deletions
aleksis/apps/chronos/util/chronos_helpers.py
+
9
−
4
View file @
d0355a61
from
typing
import
Optional
from
typing
import
Optional
from
django.contrib.auth.models
import
User
from
django.db.models
import
Count
,
Q
from
django.db.models
import
Count
,
Q
from
django.http
import
HttpRequest
,
HttpResponseNotFound
from
django.http
import
HttpRequest
,
HttpResponseNotFound
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
guardian.core
import
ObjectPermissionChecker
from
guardian.core
import
ObjectPermissionChecker
from
typing
import
TYPE_CHECKING
from
aleksis.core.models
import
Group
,
Person
from
aleksis.core.models
import
Group
,
Person
from
aleksis.core.util.predicates
import
check_global_permission
from
aleksis.core.util.predicates
import
check_global_permission
...
@@ -13,6 +13,11 @@ from aleksis.core.util.predicates import check_global_permission
...
@@ -13,6 +13,11 @@ from aleksis.core.util.predicates import check_global_permission
from
..managers
import
TimetableType
from
..managers
import
TimetableType
from
..models
import
LessonPeriod
,
LessonSubstitution
,
Room
from
..models
import
LessonPeriod
,
LessonSubstitution
,
Room
if
TYPE_CHECKING
:
from
django.contrib.auth
import
get_user_model
User
=
get_user_model
()
# noqa
def
get_el_by_pk
(
def
get_el_by_pk
(
request
:
HttpRequest
,
request
:
HttpRequest
,
...
@@ -46,7 +51,7 @@ def get_substitution_by_id(request: HttpRequest, id_: int, week: int):
...
@@ -46,7 +51,7 @@ def get_substitution_by_id(request: HttpRequest, id_: int, week: int):
).
first
()
).
first
()
def
get_teachers
(
user
:
User
):
def
get_teachers
(
user
:
"
User
"
):
"""
Get the teachers whose timetables are allowed to be seen by current user.
"""
"""
Get the teachers whose timetables are allowed to be seen by current user.
"""
checker
=
ObjectPermissionChecker
(
user
)
checker
=
ObjectPermissionChecker
(
user
)
...
@@ -70,7 +75,7 @@ def get_teachers(user: User):
...
@@ -70,7 +75,7 @@ def get_teachers(user: User):
return
teachers
return
teachers
def
get_classes
(
user
:
User
):
def
get_classes
(
user
:
"
User
"
):
"""
Get the classes whose timetables are allowed to be seen by current user.
"""
"""
Get the classes whose timetables are allowed to be seen by current user.
"""
checker
=
ObjectPermissionChecker
(
user
)
checker
=
ObjectPermissionChecker
(
user
)
...
@@ -104,7 +109,7 @@ def get_classes(user: User):
...
@@ -104,7 +109,7 @@ def get_classes(user: User):
return
classes
return
classes
def
get_rooms
(
user
:
User
):
def
get_rooms
(
user
:
"
User
"
):
"""
Get the rooms whose timetables are allowed to be seen by current user.
"""
"""
Get the rooms whose timetables are allowed to be seen by current user.
"""
checker
=
ObjectPermissionChecker
(
user
)
checker
=
ObjectPermissionChecker
(
user
)
...
...
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