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
b0bc6e8b
Verified
Commit
b0bc6e8b
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Enforce that lessons are either cancelled or substituted.
parent
9fd0444c
No related branches found
No related tags found
1 merge request
!13
Add function to cancel lessons. Closes #25.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biscuit/apps/chronos/models.py
+12
-0
12 additions, 0 deletions
biscuit/apps/chronos/models.py
with
12 additions
and
0 deletions
biscuit/apps/chronos/models.py
+
12
−
0
View file @
b0bc6e8b
...
...
@@ -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
):
...
...
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