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
602e3f0b
Verified
Commit
602e3f0b
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add docstrings
parent
0cc8f22f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/apps/chronos/model_extensions.py
+1
-0
1 addition, 0 deletions
aleksis/apps/chronos/model_extensions.py
aleksis/apps/chronos/tables.py
+2
-0
2 additions, 0 deletions
aleksis/apps/chronos/tables.py
aleksis/apps/chronos/util/format.py
+8
-3
8 additions, 3 deletions
aleksis/apps/chronos/util/format.py
with
11 additions
and
3 deletions
aleksis/apps/chronos/model_extensions.py
+
1
−
0
View file @
602e3f0b
...
@@ -88,6 +88,7 @@ def lesson_periods_as_teacher(self):
...
@@ -88,6 +88,7 @@ def lesson_periods_as_teacher(self):
def
for_timetables
(
cls
):
def
for_timetables
(
cls
):
"""
Return all announcements that should be shown in timetable views.
"""
return
cls
.
objects
.
filter
(
show_in_timetables
=
True
)
return
cls
.
objects
.
filter
(
show_in_timetables
=
True
)
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/tables.py
+
2
−
0
View file @
602e3f0b
...
@@ -13,6 +13,7 @@ from .models import LessonPeriod
...
@@ -13,6 +13,7 @@ from .models import LessonPeriod
def
_css_class_from_lesson_state
(
def
_css_class_from_lesson_state
(
record
:
Optional
[
LessonPeriod
]
=
None
,
table
:
Optional
[
LessonsTable
]
=
None
record
:
Optional
[
LessonPeriod
]
=
None
,
table
:
Optional
[
LessonsTable
]
=
None
)
->
str
:
)
->
str
:
"""
Return CSS class depending on lesson state.
"""
if
record
.
get_substitution
(
record
.
_week
):
if
record
.
get_substitution
(
record
.
_week
):
if
record
.
get_substitution
(
record
.
_week
).
cancelled
:
if
record
.
get_substitution
(
record
.
_week
).
cancelled
:
return
"
success
"
return
"
success
"
...
@@ -23,6 +24,7 @@ def _css_class_from_lesson_state(
...
@@ -23,6 +24,7 @@ def _css_class_from_lesson_state(
class
LessonsTable
(
tables
.
Table
):
class
LessonsTable
(
tables
.
Table
):
"""
Table for daily lessons and management of substitutions.
"""
class
Meta
:
class
Meta
:
attrs
=
{
"
class
"
:
"
highlight
"
}
attrs
=
{
"
class
"
:
"
highlight
"
}
row_attrs
=
{
"
class
"
:
_css_class_from_lesson_state
}
row_attrs
=
{
"
class
"
:
_css_class_from_lesson_state
}
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/util/format.py
+
8
−
3
View file @
602e3f0b
from
datetime
import
date
from
aleksis.apps.chronos.models
import
TimePeriod
from
django.utils.formats
import
date_format
from
django.utils.formats
import
date_format
def
format_m2m
(
f
,
attr
:
str
=
"
short_name
"
):
def
format_m2m
(
f
,
attr
:
str
=
"
short_name
"
)
->
str
:
"""
Join a attribute of all elements of a ManyToManyField.
"""
return
"
,
"
.
join
([
getattr
(
x
,
attr
)
for
x
in
f
.
all
()])
return
"
,
"
.
join
([
getattr
(
x
,
attr
)
for
x
in
f
.
all
()])
def
format_date_period
(
date
,
period
):
def
format_date_period
(
day
:
date
,
period
:
TimePeriod
)
->
str
:
return
"
{}, {}.
"
.
format
(
date_format
(
date
),
period
.
period
)
"""
Format date and time period.
"""
return
"
{}, {}.
"
.
format
(
date_format
(
day
),
period
.
period
)
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