Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Lesrooster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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®
Onboarding
AlekSIS-App-Lesrooster
Commits
f17d86af
Commit
f17d86af
authored
1 year ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Fix models and admin
parent
5566aee5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/lesrooster/admin.py
+1
-1
1 addition, 1 deletion
aleksis/apps/lesrooster/admin.py
aleksis/apps/lesrooster/models.py
+10
-5
10 additions, 5 deletions
aleksis/apps/lesrooster/models.py
with
11 additions
and
6 deletions
aleksis/apps/lesrooster/admin.py
+
1
−
1
View file @
f17d86af
...
...
@@ -17,7 +17,7 @@ admin.site.register(ValidityRange, ValidityRangeAdmin)
class
SlotAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
"
school_term
"
,
"
weekday
"
,
"
period
"
,
"
time_start
"
,
"
time_end
"
)
list_display
=
(
"
validity_range
"
,
"
weekday
"
,
"
period
"
,
"
time_start
"
,
"
time_end
"
)
list_display_links
=
(
"
weekday
"
,
"
period
"
)
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/lesrooster/models.py
+
10
−
5
View file @
f17d86af
...
...
@@ -90,7 +90,7 @@ class Slot(ExtensiblePolymorphicModel):
WEEKDAY_CHOICES_SHORT
=
i18n_day_abbr_choices_lazy
()
validity_range
=
models
.
ForeignKey
(
"
ch
ro
n
os.ValidityRange
"
,
"
les
roos
ter
.ValidityRange
"
,
on_delete
=
models
.
CASCADE
,
related_name
=
"
slots
"
,
verbose_name
=
_
(
"
Linked validity range
"
),
...
...
@@ -133,11 +133,16 @@ class Slot(ExtensiblePolymorphicModel):
day
=
self
.
get_date
(
date_ref
)
return
datetime
.
combine
(
day
,
self
.
time_end
)
@property
def
lessons
(
self
):
# FIXME: this may not be the intended behaviour of this property
return
Lesson
.
objects
.
filter
(
models
.
Q
(
lesson_start
=
self
)
|
models
.
Q
(
lesson_end
=
self
))
class
Meta
:
constraints
=
[
# Heads up: Uniqueness per validity range implies validity per site
models
.
UniqueConstraint
(
fields
=
[
"
weekday
"
,
"
period
"
,
"
validity
"
],
name
=
"
unique_period_per_range
"
fields
=
[
"
weekday
"
,
"
period
"
,
"
validity
_range
"
],
name
=
"
unique_period_per_range
"
),
]
ordering
=
[
"
weekday
"
,
"
period
"
]
...
...
@@ -161,13 +166,13 @@ class Lesson(ExtensibleModel):
Slot
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
_
(
"
Start slot
"
),
related_name
=
"
lessons
"
,
related_name
=
"
lessons
_starting
"
,
)
slot_end
=
models
.
ForeignKey
(
Slot
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
_
(
"
End slot
"
),
related_name
=
"
lessons
"
,
related_name
=
"
lessons
_ending
"
,
)
# Recurrence rules allow to define a series of lessons
...
...
@@ -212,7 +217,7 @@ class Lesson(ExtensibleModel):
class
Meta
:
# Heads up: Link to slot implies uniqueness per site
ordering
=
[
"
slot_start__validity__date_start
"
,
"
slot_start__validity_
range_
_date_start
"
,
"
slot_start__weekday
"
,
"
slot_start__time_start
"
,
"
subject
"
,
...
...
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