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
f9991cec
Verified
Commit
f9991cec
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Update LessonDocumentation and PersonalNote to link also to events and extra lessons
parent
891584bf
No related branches found
No related tags found
1 merge request
!120
Resolve "Support events and extra lessons in class register"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/migrations/0008_events_extra_lessons.py
+91
-0
91 additions, 0 deletions
aleksis/apps/alsijil/migrations/0008_events_extra_lessons.py
aleksis/apps/alsijil/models.py
+59
-8
59 additions, 8 deletions
aleksis/apps/alsijil/models.py
with
150 additions
and
8 deletions
aleksis/apps/alsijil/migrations/0008_events_extra_lessons.py
0 → 100644
+
91
−
0
View file @
f9991cec
# Generated by Django 3.1.5 on 2021-01-10 15:48
import
aleksis.apps.chronos.util.date
import
django.contrib.sites.managers
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
chronos
'
,
'
0004_substitution_extra_lesson_year
'
),
(
'
alsijil
'
,
'
0007_personal_note_lesson_documentation_year
'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'
lessondocumentation
'
,
options
=
{
'
ordering
'
:
[
'
year
'
,
'
week
'
,
'
lesson_period__period__weekday
'
,
'
lesson_period__period__period
'
],
'
verbose_name
'
:
'
Lesson documentation
'
,
'
verbose_name_plural
'
:
'
Lesson documentations
'
},
),
migrations
.
AlterModelOptions
(
name
=
'
personalnote
'
,
options
=
{
'
ordering
'
:
[
'
year
'
,
'
week
'
,
'
lesson_period__period__weekday
'
,
'
lesson_period__period__period
'
,
'
person__last_name
'
,
'
person__first_name
'
],
'
verbose_name
'
:
'
Personal note
'
,
'
verbose_name_plural
'
:
'
Personal notes
'
},
),
migrations
.
AddField
(
model_name
=
'
lessondocumentation
'
,
name
=
'
event
'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
documentations
'
,
to
=
'
chronos.event
'
),
),
migrations
.
AddField
(
model_name
=
'
lessondocumentation
'
,
name
=
'
extra_lesson
'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
documentations
'
,
to
=
'
chronos.extralesson
'
),
),
migrations
.
AddField
(
model_name
=
'
personalnote
'
,
name
=
'
event
'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
personal_notes
'
,
to
=
'
chronos.event
'
),
),
migrations
.
AddField
(
model_name
=
'
personalnote
'
,
name
=
'
extra_lesson
'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
personal_notes
'
,
to
=
'
chronos.extralesson
'
),
),
migrations
.
AlterField
(
model_name
=
'
lessondocumentation
'
,
name
=
'
lesson_period
'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
documentations
'
,
to
=
'
chronos.lessonperiod
'
),
),
migrations
.
AlterField
(
model_name
=
'
lessondocumentation
'
,
name
=
'
week
'
,
field
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
),
),
migrations
.
AlterField
(
model_name
=
'
lessondocumentation
'
,
name
=
'
year
'
,
field
=
models
.
IntegerField
(
blank
=
True
,
default
=
aleksis
.
apps
.
chronos
.
util
.
date
.
get_current_year
,
null
=
True
,
verbose_name
=
'
Year
'
),
),
migrations
.
AlterField
(
model_name
=
'
personalnote
'
,
name
=
'
lesson_period
'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
personal_notes
'
,
to
=
'
chronos.lessonperiod
'
),
),
migrations
.
AlterField
(
model_name
=
'
personalnote
'
,
name
=
'
week
'
,
field
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
),
),
migrations
.
AlterField
(
model_name
=
'
personalnote
'
,
name
=
'
year
'
,
field
=
models
.
IntegerField
(
blank
=
True
,
default
=
aleksis
.
apps
.
chronos
.
util
.
date
.
get_current_year
,
null
=
True
,
verbose_name
=
'
Year
'
),
),
migrations
.
AlterUniqueTogether
(
name
=
'
lessondocumentation
'
,
unique_together
=
set
(),
),
migrations
.
AlterUniqueTogether
(
name
=
'
personalnote
'
,
unique_together
=
set
(),
),
migrations
.
AddConstraint
(
model_name
=
'
lessondocumentation
'
,
constraint
=
models
.
CheckConstraint
(
check
=
models
.
Q
(
models
.
Q
((
'
event__isnull
'
,
True
),
(
'
extra_lesson__isnull
'
,
True
),
(
'
lesson_period__isnull
'
,
False
),
(
'
week__isnull
'
,
False
),
(
'
year__isnull
'
,
False
)),
models
.
Q
((
'
event__isnull
'
,
False
),
(
'
extra_lesson__isnull
'
,
True
),
(
'
lesson_period__isnull
'
,
True
),
(
'
week__isnull
'
,
True
),
(
'
year__isnull
'
,
True
)),
models
.
Q
((
'
event__isnull
'
,
True
),
(
'
extra_lesson__isnull
'
,
False
),
(
'
lesson_period__isnull
'
,
True
),
(
'
week__isnull
'
,
True
),
(
'
year__isnull
'
,
True
)),
_connector
=
'
OR
'
),
name
=
'
one_relation_only_lesson_documentation
'
),
),
migrations
.
AddConstraint
(
model_name
=
'
personalnote
'
,
constraint
=
models
.
CheckConstraint
(
check
=
models
.
Q
(
models
.
Q
((
'
event__isnull
'
,
True
),
(
'
extra_lesson__isnull
'
,
True
),
(
'
lesson_period__isnull
'
,
False
),
(
'
week__isnull
'
,
False
),
(
'
year__isnull
'
,
False
)),
models
.
Q
((
'
event__isnull
'
,
False
),
(
'
extra_lesson__isnull
'
,
True
),
(
'
lesson_period__isnull
'
,
True
),
(
'
week__isnull
'
,
True
),
(
'
year__isnull
'
,
True
)),
models
.
Q
((
'
event__isnull
'
,
True
),
(
'
extra_lesson__isnull
'
,
False
),
(
'
lesson_period__isnull
'
,
True
),
(
'
week__isnull
'
,
True
),
(
'
year__isnull
'
,
True
)),
_connector
=
'
OR
'
),
name
=
'
one_relation_only_personal_note
'
),
),
]
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/models.py
+
59
−
8
View file @
f9991cec
from
django.db
import
models
from
django.db
import
models
from
django.db.models.constraints
import
CheckConstraint
from
django.db.models.query_utils
import
Q
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.utils.formats
import
date_format
from
django.utils.formats
import
date_format
from
django.utils.translation
import
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
as
_
...
@@ -46,6 +48,31 @@ class ExcuseType(ExtensibleModel):
...
@@ -46,6 +48,31 @@ class ExcuseType(ExtensibleModel):
verbose_name_plural
=
_
(
"
Excuse types
"
)
verbose_name_plural
=
_
(
"
Excuse types
"
)
lesson_related_constraint_q
=
(
Q
(
lesson_period__isnull
=
False
,
event__isnull
=
True
,
extra_lesson__isnull
=
True
,
week__isnull
=
False
,
year__isnull
=
False
,
)
|
Q
(
lesson_period__isnull
=
True
,
event__isnull
=
False
,
extra_lesson__isnull
=
True
,
week__isnull
=
True
,
year__isnull
=
True
,
)
|
Q
(
lesson_period__isnull
=
True
,
event__isnull
=
True
,
extra_lesson__isnull
=
False
,
week__isnull
=
True
,
year__isnull
=
True
,
)
)
class
PersonalNote
(
ExtensibleModel
,
WeekRelatedMixin
):
class
PersonalNote
(
ExtensibleModel
,
WeekRelatedMixin
):
"""
A personal note about a single person.
"""
A personal note about a single person.
...
@@ -65,11 +92,19 @@ class PersonalNote(ExtensibleModel, WeekRelatedMixin):
...
@@ -65,11 +92,19 @@ class PersonalNote(ExtensibleModel, WeekRelatedMixin):
person
=
models
.
ForeignKey
(
"
core.Person
"
,
models
.
CASCADE
,
related_name
=
"
personal_notes
"
)
person
=
models
.
ForeignKey
(
"
core.Person
"
,
models
.
CASCADE
,
related_name
=
"
personal_notes
"
)
groups_of_person
=
models
.
ManyToManyField
(
"
core.Group
"
,
related_name
=
"
+
"
)
groups_of_person
=
models
.
ManyToManyField
(
"
core.Group
"
,
related_name
=
"
+
"
)
week
=
models
.
IntegerField
()
week
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
year
=
models
.
IntegerField
(
verbose_name
=
_
(
"
Year
"
),
default
=
get_current_year
)
year
=
models
.
IntegerField
(
verbose_name
=
_
(
"
Year
"
),
default
=
get_current_year
,
blank
=
True
,
null
=
True
)
lesson_period
=
models
.
ForeignKey
(
lesson_period
=
models
.
ForeignKey
(
"
chronos.LessonPeriod
"
,
models
.
CASCADE
,
related_name
=
"
personal_notes
"
"
chronos.LessonPeriod
"
,
models
.
CASCADE
,
related_name
=
"
personal_notes
"
,
blank
=
True
,
null
=
True
)
event
=
models
.
ForeignKey
(
"
chronos.Event
"
,
models
.
CASCADE
,
related_name
=
"
personal_notes
"
,
blank
=
True
,
null
=
True
)
extra_lesson
=
models
.
ForeignKey
(
"
chronos.ExtraLesson
"
,
models
.
CASCADE
,
related_name
=
"
personal_notes
"
,
blank
=
True
,
null
=
True
)
)
absent
=
models
.
BooleanField
(
default
=
False
)
absent
=
models
.
BooleanField
(
default
=
False
)
...
@@ -123,7 +158,6 @@ class PersonalNote(ExtensibleModel, WeekRelatedMixin):
...
@@ -123,7 +158,6 @@ class PersonalNote(ExtensibleModel, WeekRelatedMixin):
class
Meta
:
class
Meta
:
verbose_name
=
_
(
"
Personal note
"
)
verbose_name
=
_
(
"
Personal note
"
)
verbose_name_plural
=
_
(
"
Personal notes
"
)
verbose_name_plural
=
_
(
"
Personal notes
"
)
unique_together
=
[[
"
lesson_period
"
,
"
week
"
,
"
person
"
]]
ordering
=
[
ordering
=
[
"
year
"
,
"
year
"
,
"
week
"
,
"
week
"
,
...
@@ -132,6 +166,11 @@ class PersonalNote(ExtensibleModel, WeekRelatedMixin):
...
@@ -132,6 +166,11 @@ class PersonalNote(ExtensibleModel, WeekRelatedMixin):
"
person__last_name
"
,
"
person__last_name
"
,
"
person__first_name
"
,
"
person__first_name
"
,
]
]
constraints
=
[
CheckConstraint
(
check
=
lesson_related_constraint_q
,
name
=
"
one_relation_only_personal_note
"
)
]
class
LessonDocumentation
(
ExtensibleModel
,
WeekRelatedMixin
):
class
LessonDocumentation
(
ExtensibleModel
,
WeekRelatedMixin
):
...
@@ -142,11 +181,19 @@ class LessonDocumentation(ExtensibleModel, WeekRelatedMixin):
...
@@ -142,11 +181,19 @@ class LessonDocumentation(ExtensibleModel, WeekRelatedMixin):
data_checks
=
[
LessonDocumentationOnHolidaysDataCheck
]
data_checks
=
[
LessonDocumentationOnHolidaysDataCheck
]
week
=
models
.
IntegerField
()
week
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
year
=
models
.
IntegerField
(
verbose_name
=
_
(
"
Year
"
),
default
=
get_current_year
)
year
=
models
.
IntegerField
(
verbose_name
=
_
(
"
Year
"
),
default
=
get_current_year
,
blank
=
True
,
null
=
True
)
lesson_period
=
models
.
ForeignKey
(
lesson_period
=
models
.
ForeignKey
(
"
chronos.LessonPeriod
"
,
models
.
CASCADE
,
related_name
=
"
documentations
"
"
chronos.LessonPeriod
"
,
models
.
CASCADE
,
related_name
=
"
documentations
"
,
blank
=
True
,
null
=
True
)
event
=
models
.
ForeignKey
(
"
chronos.Event
"
,
models
.
CASCADE
,
related_name
=
"
documentations
"
,
blank
=
True
,
null
=
True
)
extra_lesson
=
models
.
ForeignKey
(
"
chronos.ExtraLesson
"
,
models
.
CASCADE
,
related_name
=
"
documentations
"
,
blank
=
True
,
null
=
True
)
)
topic
=
models
.
CharField
(
verbose_name
=
_
(
"
Lesson topic
"
),
max_length
=
200
,
blank
=
True
)
topic
=
models
.
CharField
(
verbose_name
=
_
(
"
Lesson topic
"
),
max_length
=
200
,
blank
=
True
)
...
@@ -203,13 +250,17 @@ class LessonDocumentation(ExtensibleModel, WeekRelatedMixin):
...
@@ -203,13 +250,17 @@ class LessonDocumentation(ExtensibleModel, WeekRelatedMixin):
class
Meta
:
class
Meta
:
verbose_name
=
_
(
"
Lesson documentation
"
)
verbose_name
=
_
(
"
Lesson documentation
"
)
verbose_name_plural
=
_
(
"
Lesson documentations
"
)
verbose_name_plural
=
_
(
"
Lesson documentations
"
)
unique_together
=
[[
"
lesson_period
"
,
"
week
"
]]
ordering
=
[
ordering
=
[
"
year
"
,
"
year
"
,
"
week
"
,
"
week
"
,
"
lesson_period__period__weekday
"
,
"
lesson_period__period__weekday
"
,
"
lesson_period__period__period
"
,
"
lesson_period__period__period
"
,
]
]
constraints
=
[
CheckConstraint
(
check
=
lesson_related_constraint_q
,
name
=
"
one_relation_only_lesson_documentation
"
,
)
]
class
ExtraMark
(
ExtensibleModel
):
class
ExtraMark
(
ExtensibleModel
):
...
...
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