Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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-Core
Commits
7afa58a9
Commit
7afa58a9
authored
2 years ago
by
Jonathan Weth
Committed by
Hangzhi Yu
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Document Holiday model and update changelog
parent
cb9dc200
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1148
Calendar events and iCal feeds
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.rst
+1
-0
1 addition, 0 deletions
CHANGELOG.rst
aleksis/core/models.py
+7
-2
7 additions, 2 deletions
aleksis/core/models.py
with
8 additions
and
2 deletions
CHANGELOG.rst
+
1
−
0
View file @
7afa58a9
...
...
@@ -29,6 +29,7 @@ Added
* GraphQL queries and mutations for core data management
* [Dev] Introduce new mechanism to register classes over all apps.
* Data template for `room` model used for haystack search indexing moved to core.
* Introduce Holiday model to track information about holidays.
Changed
~~~~~~~
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/models.py
+
7
−
2
View file @
7afa58a9
...
...
@@ -1590,15 +1590,17 @@ class BirthdayEvent(CalendarEventMixin):
class
Holiday
(
CalendarEvent
):
"""
Holiday model for keeping track of school holidays.
"""
name
=
"
holidays
"
verbose_name
=
_
(
"
Holidays
"
)
@classmethod
def
value_title
(
cls
,
reference_object
)
:
def
value_title
(
cls
,
reference_object
:
"
Holiday
"
)
->
str
:
return
reference_object
.
holiday_name
@classmethod
def
value_description
(
cls
,
reference_object
)
:
def
value_description
(
cls
,
reference_object
:
"
Holiday
"
)
->
str
:
return
""
objects
=
PolymorphicCurrentSiteManager
.
from_queryset
(
HolidayQuerySet
)()
...
...
@@ -1606,12 +1608,14 @@ class Holiday(CalendarEvent):
holiday_name
=
models
.
CharField
(
verbose_name
=
_
(
"
Name
"
),
max_length
=
255
)
def
get_days
(
self
)
->
Iterator
[
date
]:
"""
Get all days included in the holiday.
"""
delta
=
self
.
date_end
-
self
.
date_start
for
i
in
range
(
delta
.
days
+
1
):
yield
self
.
date_start
+
timedelta
(
days
=
i
)
@classmethod
def
on_day
(
cls
,
day
:
date
)
->
Optional
[
"
Holiday
"
]:
"""
Get the holiday that is active on a given day.
"""
holidays
=
cls
.
objects
.
on_day
(
day
)
if
holidays
.
exists
():
return
holidays
[
0
]
...
...
@@ -1620,6 +1624,7 @@ class Holiday(CalendarEvent):
@classmethod
def
in_week
(
cls
,
week
:
CalendarWeek
)
->
dict
[
int
,
Optional
[
"
Holiday
"
]]:
"""
Get the holidays that are active in a given week.
"""
per_weekday
=
{}
holidays
=
Holiday
.
objects
.
in_week
(
week
)
...
...
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