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
d0658f59
Verified
Commit
d0658f59
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Make all data school-related. Closes
#20
.
parent
122cb456
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
biscuit/apps/chronos/migrations/0005_school_related.py
+78
-0
78 additions, 0 deletions
biscuit/apps/chronos/migrations/0005_school_related.py
biscuit/apps/chronos/models.py
+15
-11
15 additions, 11 deletions
biscuit/apps/chronos/models.py
with
93 additions
and
11 deletions
biscuit/apps/chronos/migrations/0005_school_related.py
0 → 100644
+
78
−
0
View file @
d0658f59
# Generated by Django 2.2.4 on 2019-09-03 14:10
import
biscuit.apps.chronos.util
import
biscuit.core.util.core_helpers
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
chronos
'
,
'
0004_auto_20190821_1550
'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'
lesson
'
,
name
=
'
school
'
,
field
=
models
.
ForeignKey
(
default
=
biscuit
.
core
.
util
.
core_helpers
.
get_current_school
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
core.School
'
),
),
migrations
.
AddField
(
model_name
=
'
lessonperiod
'
,
name
=
'
school
'
,
field
=
models
.
ForeignKey
(
default
=
biscuit
.
core
.
util
.
core_helpers
.
get_current_school
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
core.School
'
),
),
migrations
.
AddField
(
model_name
=
'
lessonsubstitution
'
,
name
=
'
school
'
,
field
=
models
.
ForeignKey
(
default
=
biscuit
.
core
.
util
.
core_helpers
.
get_current_school
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
core.School
'
),
),
migrations
.
AddField
(
model_name
=
'
room
'
,
name
=
'
school
'
,
field
=
models
.
ForeignKey
(
default
=
biscuit
.
core
.
util
.
core_helpers
.
get_current_school
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
core.School
'
),
),
migrations
.
AddField
(
model_name
=
'
subject
'
,
name
=
'
school
'
,
field
=
models
.
ForeignKey
(
default
=
biscuit
.
core
.
util
.
core_helpers
.
get_current_school
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
core.School
'
),
),
migrations
.
AddField
(
model_name
=
'
timeperiod
'
,
name
=
'
school
'
,
field
=
models
.
ForeignKey
(
default
=
biscuit
.
core
.
util
.
core_helpers
.
get_current_school
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
core.School
'
),
),
migrations
.
AlterField
(
model_name
=
'
room
'
,
name
=
'
name
'
,
field
=
models
.
CharField
(
max_length
=
30
,
verbose_name
=
'
Long name
'
),
),
migrations
.
AlterField
(
model_name
=
'
room
'
,
name
=
'
short_name
'
,
field
=
models
.
CharField
(
max_length
=
10
,
verbose_name
=
'
Short name, e.g. room number
'
),
),
migrations
.
AlterField
(
model_name
=
'
subject
'
,
name
=
'
abbrev
'
,
field
=
models
.
CharField
(
max_length
=
10
,
verbose_name
=
'
Abbreviation of subject in timetable
'
),
),
migrations
.
AlterField
(
model_name
=
'
subject
'
,
name
=
'
name
'
,
field
=
models
.
CharField
(
max_length
=
30
,
verbose_name
=
'
Long name of subject
'
),
),
migrations
.
AlterUniqueTogether
(
name
=
'
room
'
,
unique_together
=
{(
'
school
'
,
'
name
'
),
(
'
school
'
,
'
short_name
'
)},
),
migrations
.
AlterUniqueTogether
(
name
=
'
subject
'
,
unique_together
=
{(
'
school
'
,
'
abbrev
'
),
(
'
school
'
,
'
name
'
)},
),
migrations
.
AlterUniqueTogether
(
name
=
'
timeperiod
'
,
unique_together
=
{(
'
school
'
,
'
weekday
'
,
'
period
'
)},
),
]
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/models.py
+
15
−
11
View file @
d0658f59
...
@@ -5,10 +5,12 @@ from django.core import validators
...
@@ -5,10 +5,12 @@ from django.core import validators
from
django.db
import
models
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
biscuit.core.mixins
import
SchoolRelated
from
.util
import
current_week
from
.util
import
current_week
class
TimePeriod
(
models
.
Model
):
class
TimePeriod
(
SchoolRelated
):
WEEKDAY_CHOICES
=
[
WEEKDAY_CHOICES
=
[
(
0
,
_
(
'
Sunday
'
)),
(
0
,
_
(
'
Sunday
'
)),
(
1
,
_
(
'
Monday
'
)),
(
1
,
_
(
'
Monday
'
)),
...
@@ -39,15 +41,15 @@ class TimePeriod(models.Model):
...
@@ -39,15 +41,15 @@ class TimePeriod(models.Model):
return
periods
return
periods
class
Meta
:
class
Meta
:
unique_together
=
[[
'
weekday
'
,
'
period
'
]]
unique_together
=
[[
'
school
'
,
'
weekday
'
,
'
period
'
]]
ordering
=
[
'
weekday
'
,
'
period
'
]
ordering
=
[
'
weekday
'
,
'
period
'
]
class
Subject
(
models
.
Model
):
class
Subject
(
SchoolRelated
):
abbrev
=
models
.
CharField
(
verbose_name
=
_
(
abbrev
=
models
.
CharField
(
verbose_name
=
_
(
'
Abbreviation of subject in timetable
'
),
max_length
=
10
,
unique
=
True
)
'
Abbreviation of subject in timetable
'
),
max_length
=
10
)
name
=
models
.
CharField
(
verbose_name
=
_
(
name
=
models
.
CharField
(
verbose_name
=
_
(
'
Long name of subject
'
),
max_length
=
30
,
unique
=
True
)
'
Long name of subject
'
),
max_length
=
30
)
colour_fg
=
models
.
CharField
(
verbose_name
=
_
(
'
Foreground colour in timetable
'
),
blank
=
True
,
validators
=
[
colour_fg
=
models
.
CharField
(
verbose_name
=
_
(
'
Foreground colour in timetable
'
),
blank
=
True
,
validators
=
[
validators
.
RegexValidator
(
r
'
#[0-9A-F]{6}
'
)],
max_length
=
7
)
validators
.
RegexValidator
(
r
'
#[0-9A-F]{6}
'
)],
max_length
=
7
)
...
@@ -59,22 +61,24 @@ class Subject(models.Model):
...
@@ -59,22 +61,24 @@ class Subject(models.Model):
class
Meta
:
class
Meta
:
ordering
=
[
'
name
'
,
'
abbrev
'
]
ordering
=
[
'
name
'
,
'
abbrev
'
]
unique_together
=
[[
'
school
'
,
'
abbrev
'
],
[
'
school
'
,
'
name
'
]]
class
Room
(
models
.
Model
):
class
Room
(
SchoolRelated
):
short_name
=
models
.
CharField
(
verbose_name
=
_
(
short_name
=
models
.
CharField
(
verbose_name
=
_
(
'
Short name, e.g. room number
'
),
max_length
=
10
,
unique
=
True
)
'
Short name, e.g. room number
'
),
max_length
=
10
)
name
=
models
.
CharField
(
verbose_name
=
_
(
'
Long name
'
),
name
=
models
.
CharField
(
verbose_name
=
_
(
'
Long name
'
),
max_length
=
30
,
unique
=
True
)
max_length
=
30
)
def
__str__
(
self
)
->
str
:
def
__str__
(
self
)
->
str
:
return
'
%s (%s)
'
%
(
self
.
name
,
self
.
short_name
)
return
'
%s (%s)
'
%
(
self
.
name
,
self
.
short_name
)
class
Meta
:
class
Meta
:
ordering
=
[
'
name
'
,
'
short_name
'
]
ordering
=
[
'
name
'
,
'
short_name
'
]
unique_together
=
[[
'
school
'
,
'
short_name
'
],
[
'
school
'
,
'
name
'
]]
class
Lesson
(
models
.
Model
):
class
Lesson
(
SchoolRelated
):
subject
=
models
.
ForeignKey
(
subject
=
models
.
ForeignKey
(
'
Subject
'
,
on_delete
=
models
.
CASCADE
,
related_name
=
'
lessons
'
)
'
Subject
'
,
on_delete
=
models
.
CASCADE
,
related_name
=
'
lessons
'
)
teachers
=
models
.
ManyToManyField
(
'
core.Person
'
,
related_name
=
'
lessons
'
)
teachers
=
models
.
ManyToManyField
(
'
core.Person
'
,
related_name
=
'
lessons
'
)
...
@@ -99,7 +103,7 @@ class Lesson(models.Model):
...
@@ -99,7 +103,7 @@ class Lesson(models.Model):
ordering
=
[
'
date_start
'
]
ordering
=
[
'
date_start
'
]
class
LessonSubstitution
(
models
.
Model
):
class
LessonSubstitution
(
SchoolRelated
):
week
=
models
.
IntegerField
(
verbose_name
=
_
(
'
Week
'
),
week
=
models
.
IntegerField
(
verbose_name
=
_
(
'
Week
'
),
default
=
current_week
)
default
=
current_week
)
...
@@ -118,7 +122,7 @@ class LessonSubstitution(models.Model):
...
@@ -118,7 +122,7 @@ class LessonSubstitution(models.Model):
'
lesson_period__period__weekday
'
,
'
lesson_period__period__period
'
]
'
lesson_period__period__weekday
'
,
'
lesson_period__period__period
'
]
class
LessonPeriod
(
models
.
Model
):
class
LessonPeriod
(
SchoolRelated
):
lesson
=
models
.
ForeignKey
(
'
Lesson
'
,
models
.
CASCADE
,
related_name
=
'
lesson_periods
'
)
lesson
=
models
.
ForeignKey
(
'
Lesson
'
,
models
.
CASCADE
,
related_name
=
'
lesson_periods
'
)
period
=
models
.
ForeignKey
(
'
TimePeriod
'
,
models
.
CASCADE
,
related_name
=
'
lesson_periods
'
)
period
=
models
.
ForeignKey
(
'
TimePeriod
'
,
models
.
CASCADE
,
related_name
=
'
lesson_periods
'
)
...
...
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