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
46baa955
Commit
46baa955
authored
11 months ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
Make allowing future coursebook entries configurable
parent
23123c71
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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/preferences.py
+16
-1
16 additions, 1 deletion
aleksis/apps/alsijil/preferences.py
aleksis/apps/alsijil/rules.py
+2
-1
2 additions, 1 deletion
aleksis/apps/alsijil/rules.py
aleksis/apps/alsijil/util/predicates.py
+15
-0
15 additions, 0 deletions
aleksis/apps/alsijil/util/predicates.py
with
33 additions
and
2 deletions
aleksis/apps/alsijil/preferences.py
+
16
−
1
View file @
46baa955
...
...
@@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError
from
django.utils.translation
import
gettext_lazy
as
_
from
dynamic_preferences.preferences
import
Section
from
dynamic_preferences.types
import
BooleanPreference
,
IntegerPreference
from
dynamic_preferences.types
import
BooleanPreference
,
ChoicePreference
,
IntegerPreference
from
aleksis.core.registries
import
person_preferences_registry
,
site_preferences_registry
...
...
@@ -157,3 +157,18 @@ class DefaultLessonDocumentationFilter(BooleanPreference):
name
=
"
default_lesson_documentation_filter
"
default
=
True
verbose_name
=
_
(
"
Filter lessons by existence of their lesson documentation on default
"
)
@site_preferences_registry.register
class
AllowEditFutureDocumentations
(
ChoicePreference
):
"""
Time range for which documentations may be edited.
"""
section
=
alsijil
name
=
"
allow_edit_future_documentations
"
default
=
"
current_day
"
choices
=
(
(
"
all
"
,
_
(
"
Allow editing of all future documentations
"
)),
(
"
current_day
"
,
_
(
"
Allow editing of all documentations up to and including those on the current day
"
)),
(
"
current_time
"
,
_
(
"
Allow editing of all documentations up to and including those on the current date and time
"
)),
)
verbose_name
=
_
(
"
Set time range for which documentations may be edited
"
)
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/rules.py
+
2
−
1
View file @
46baa955
...
...
@@ -22,6 +22,7 @@ from .util.predicates import (
is_group_member
,
is_group_owner
,
is_group_role_assignment_group_owner
,
is_in_allowed_time_range
,
is_lesson_event_group_owner
,
is_lesson_event_teacher
,
is_lesson_original_teacher
,
...
...
@@ -402,6 +403,6 @@ add_perm(
edit_documentation_predicate
=
has_person
&
(
has_global_perm
(
"
alsijil.change_documentation
"
)
|
can_edit_documentation
)
)
&
is_in_allowed_time_range
add_perm
(
"
alsijil.edit_documentation_rule
"
,
edit_documentation_predicate
)
add_perm
(
"
alsijil.delete_documentation_rule
"
,
edit_documentation_predicate
)
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/util/predicates.py
+
15
−
0
View file @
46baa955
from
typing
import
Any
,
Union
from
django.contrib.auth.models
import
User
from
django.utils.timezone
import
localdate
,
localtime
from
rules
import
predicate
from
aleksis.apps.chronos.models
import
Event
,
ExtraLesson
,
LessonEvent
,
LessonPeriod
from
aleksis.apps.cursus.models
import
Course
from
aleksis.core.models
import
Group
,
Person
from
aleksis.core.util.core_helpers
import
get_site_preferences
from
aleksis.core.util.predicates
import
check_object_permission
from
..models
import
Documentation
,
PersonalNote
...
...
@@ -407,3 +409,16 @@ def can_edit_documentation(user: User, obj: Documentation):
if
obj
.
course
:
return
is_course_teacher
(
user
,
obj
.
course
)
return
False
@predicate
def
is_in_allowed_time_range
(
user
:
User
,
obj
:
Documentation
):
"""
Predicate which checks if the documentation is in the allowed time range for editing.
"""
if
obj
:
if
get_site_preferences
()[
"
alsijil__allow_edit_future_documentations
"
]
==
"
all
"
:
return
True
elif
get_site_preferences
()[
"
alsijil__allow_edit_future_documentations
"
]
==
"
current_day
"
and
obj
.
datetime_start
.
date
()
<=
localdate
():
return
True
elif
get_site_preferences
()[
"
alsijil__allow_edit_future_documentations
"
]
==
"
current_time
"
and
obj
.
datetime_start
<=
localtime
():
return
True
return
False
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