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
Merge requests
!92
Resolve "Add task for checking plausibility of data"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Add task for checking plausibility of data"
91-add-task-for-checking-plausibility-of-data
into
master
Overview
11
Commits
30
Pipelines
25
Changes
2
Merged
Jonathan Weth
requested to merge
91-add-task-for-checking-plausibility-of-data
into
master
4 years ago
Overview
10
Commits
30
Pipelines
25
Changes
2
Expand
Closes
#91 (closed)
Edited
4 years ago
by
Jonathan Weth
0
0
Merge request reports
Viewing commit
ba6eeed0
Prev
Next
Show latest version
2 files
+
49
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
Verified
ba6eeed0
Add data check for lesson documentations on holidays
· ba6eeed0
Jonathan Weth
authored
4 years ago
aleksis/apps/alsijil/data_checks.py
+
41
−
0
Options
@@ -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
)
Loading