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
Merge requests
!13
Add function to cancel lessons. Closes
#25
.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add function to cancel lessons. Closes
#25
.
issue25
into
master
Overview
5
Commits
11
Pipelines
0
Changes
1
Merged
Tom Teichler
requested to merge
issue25
into
master
5 years ago
Overview
5
Commits
11
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
b0bc6e8b
Prev
Next
Show latest version
1 file
+
12
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
b0bc6e8b
Enforce that lessons are either cancelled or substituted.
· b0bc6e8b
Nik | Klampfradler
authored
5 years ago
biscuit/apps/chronos/models.py
+
12
−
0
Options
@@ -2,7 +2,9 @@ from datetime import datetime
from
typing
import
Dict
,
Optional
,
Tuple
from
django.core
import
validators
from
django.core.exceptions
import
ValidationError
from
django.db
import
models
from
django.db.models
import
Q
from
django.utils.translation
import
ugettext_lazy
as
_
from
biscuit.core.mixins
import
SchoolRelated
@@ -121,10 +123,20 @@ class LessonSubstitution(SchoolRelated):
cancelled
=
models
.
BooleanField
(
default
=
False
)
def
clean
(
self
)
->
None
:
if
self
.
subject
and
self
.
cancelled
:
raise
ValidationError
(
_
(
'
Lessons can only be either substituted or cancelled.
'
))
class
Meta
:
unique_together
=
[[
'
school
'
,
'
lesson_period
'
,
'
week
'
]]
ordering
=
[
'
lesson_period__lesson__date_start
'
,
'
week
'
,
'
lesson_period__period__weekday
'
,
'
lesson_period__period__period
'
]
constraints
=
[
models
.
CheckConstraint
(
check
=
Q
(
cancelled
=
False
,
subject__isnull
=
False
)
|
Q
(
cancelled
=
True
,
subject__isnull
=
True
,
room__isnull
=
True
),
name
=
'
either_substituted_or_cancelled
'
)
]
class
LessonPeriod
(
SchoolRelated
):
Loading