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
ba6eeed0
Verified
Commit
ba6eeed0
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add data check for lesson documentations on holidays
parent
ebff52ea
No related branches found
No related tags found
1 merge request
!92
Resolve "Add task for checking plausibility of data"
Pipeline
#4670
failed
4 years ago
Stage: test
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/data_checks.py
+41
-0
41 additions, 0 deletions
aleksis/apps/alsijil/data_checks.py
aleksis/apps/alsijil/models.py
+8
-0
8 additions, 0 deletions
aleksis/apps/alsijil/models.py
with
49 additions
and
0 deletions
aleksis/apps/alsijil/data_checks.py
+
41
−
0
View file @
ba6eeed0
...
...
@@ -2,10 +2,12 @@ import logging
from
django.contrib.contenttypes.models
import
ContentType
from
django.db.models
import
F
from
django.db.models.query_utils
import
Q
from
django.utils.translation
import
gettext
as
_
from
calendarweek
import
CalendarWeek
from
aleksis.apps.chronos.util.date
import
week_weekday_to_date
from
aleksis.core.data_checks
import
DATA_CHECK_REGISTRY
,
DataCheck
,
IgnoreSolveOption
,
SolveOption
...
...
@@ -88,3 +90,42 @@ class NoGroupsOfPersonsSetInPersonalNotesDataCheck(DataCheck):
result
=
DataCheckResult
.
objects
.
get_or_create
(
check
=
cls
.
name
,
content_type
=
ct
,
object_id
=
note
.
id
)
@DATA_CHECK_REGISTRY.register
class
LessonDocumentationOnHolidaysDataCheck
(
DataCheck
):
"""
Checks for lesson documentation objects on holidays.
This ignores empty lesson documentation as they are created by default.
"""
name
=
"
lesson_documentation_on_holidays
"
verbose_name
=
_
(
"
Ensure that there are no filled out lesson documentations on holidays
"
)
problem_name
=
_
(
"
The lesson documentation is on holidays.
"
)
solve_options
=
{
DeleteRelatedObjectSolveOption
.
name
:
DeleteRelatedObjectSolveOption
,
IgnoreSolveOption
.
name
:
IgnoreSolveOption
,
}
@classmethod
def
check_data
(
cls
):
from
aleksis.apps.chronos.models
import
Holiday
from
aleksis.core.models
import
DataCheckResult
from
.models
import
LessonDocumentation
ct
=
ContentType
.
objects
.
get_for_model
(
LessonDocumentation
)
holidays
=
list
(
Holiday
.
objects
.
all
())
documentations
=
LessonDocumentation
.
objects
.
filter
(
~
Q
(
topic
=
""
)
|
~
Q
(
group_note
=
""
)
|
~
Q
(
homework
=
""
)
)
for
doc
in
documentations
:
logging
.
info
(
f
"
Check lesson documentation
{
doc
}
"
)
day
=
week_weekday_to_date
(
doc
.
calendar_week
,
doc
.
lesson_period
.
period
.
weekday
)
if
len
(
list
(
filter
(
lambda
h
:
h
.
date_start
<=
day
<=
h
.
date_end
,
holidays
)))
>
0
:
logging
.
info
(
"
... on holidays
"
)
result
=
DataCheckResult
.
objects
.
get_or_create
(
check
=
cls
.
name
,
content_type
=
ct
,
object_id
=
doc
.
id
)
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/models.py
+
8
−
0
View file @
ba6eeed0
...
...
@@ -169,6 +169,14 @@ class LessonDocumentation(ExtensibleModel, WeekRelatedMixin):
if
changed
:
lesson_documentation
.
save
()
def
__str__
(
self
):
return
f
"
{
self
.
lesson_period
}
,
{
date_format
(
self
.
date
)
}
"
def
get_absolute_url
(
self
):
return
reverse
(
"
lesson_by_week_and_period
"
,
args
=
[
self
.
year
,
self
.
week
,
self
.
lesson_period
.
pk
],
)
def
save
(
self
,
*
args
,
**
kwargs
):
if
get_site_preferences
()[
"
alsijil__carry_over
"
]
and
(
self
.
topic
or
self
.
homework
or
self
.
group_note
...
...
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