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
bd0ae76f
Verified
Commit
bd0ae76f
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Simplify registering of data check results by adding a dedicated method
parent
3c99004a
No related branches found
No related tags found
1 merge request
!92
Resolve "Add task for checking plausibility of data"
Pipeline
#5010
failed
4 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/alsijil/data_checks.py
+5
-31
5 additions, 31 deletions
aleksis/apps/alsijil/data_checks.py
with
5 additions
and
31 deletions
aleksis/apps/alsijil/data_checks.py
+
5
−
31
View file @
bd0ae76f
...
...
@@ -56,12 +56,8 @@ class NoPersonalNotesInCancelledLessonsDataCheck(DataCheck):
@classmethod
def
check_data
(
cls
):
from
aleksis.core.models
import
DataCheckResult
from
.models
import
PersonalNote
ct
=
ContentType
.
objects
.
get_for_model
(
PersonalNote
)
personal_notes
=
PersonalNote
.
objects
.
filter
(
lesson_period__substitutions__cancelled
=
True
,
lesson_period__substitutions__week
=
F
(
"
week
"
),
...
...
@@ -70,9 +66,7 @@ class NoPersonalNotesInCancelledLessonsDataCheck(DataCheck):
for
note
in
personal_notes
:
logging
.
info
(
f
"
Check personal note
{
note
}
"
)
result
=
DataCheckResult
.
objects
.
get_or_create
(
check
=
cls
.
name
,
content_type
=
ct
,
object_id
=
note
.
id
)
cls
.
register_result
(
note
)
@DATA_CHECK_REGISTRY.register
...
...
@@ -88,19 +82,13 @@ class NoGroupsOfPersonsSetInPersonalNotesDataCheck(DataCheck):
@classmethod
def
check_data
(
cls
):
from
aleksis.core.models
import
DataCheckResult
from
.models
import
PersonalNote
ct
=
ContentType
.
objects
.
get_for_model
(
PersonalNote
)
personal_notes
=
PersonalNote
.
objects
.
filter
(
groups_of_person__isnull
=
True
)
for
note
in
personal_notes
:
logging
.
info
(
f
"
Check personal note
{
note
}
"
)
result
=
DataCheckResult
.
objects
.
get_or_create
(
check
=
cls
.
name
,
content_type
=
ct
,
object_id
=
note
.
id
)
cls
.
register_result
(
note
)
@DATA_CHECK_REGISTRY.register
...
...
@@ -121,11 +109,9 @@ class LessonDocumentationOnHolidaysDataCheck(DataCheck):
@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
(
...
...
@@ -137,9 +123,7 @@ class LessonDocumentationOnHolidaysDataCheck(DataCheck):
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
)
cls
.
register_result
(
doc
)
@DATA_CHECK_REGISTRY.register
...
...
@@ -160,11 +144,9 @@ class PersonalNoteOnHolidaysDataCheck(DataCheck):
@classmethod
def
check_data
(
cls
):
from
aleksis.apps.chronos.models
import
Holiday
from
aleksis.core.models
import
DataCheckResult
from
.models
import
PersonalNote
ct
=
ContentType
.
objects
.
get_for_model
(
PersonalNote
)
holidays
=
list
(
Holiday
.
objects
.
all
())
personal_notes
=
PersonalNote
.
objects
.
filter
(
...
...
@@ -176,9 +158,7 @@ class PersonalNoteOnHolidaysDataCheck(DataCheck):
day
=
week_weekday_to_date
(
note
.
calendar_week
,
note
.
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
=
note
.
id
)
cls
.
register_result
(
note
)
@DATA_CHECK_REGISTRY.register
...
...
@@ -193,16 +173,10 @@ class ExcusesWithoutAbsences(DataCheck):
@classmethod
def
check_data
(
cls
):
from
aleksis.core.models
import
DataCheckResult
from
.models
import
PersonalNote
ct
=
ContentType
.
objects
.
get_for_model
(
PersonalNote
)
personal_notes
=
PersonalNote
.
objects
.
filter
(
excused
=
True
,
absent
=
False
)
for
note
in
personal_notes
:
logging
.
info
(
f
"
Check personal note
{
note
}
"
)
result
=
DataCheckResult
.
objects
.
get_or_create
(
check
=
cls
.
name
,
content_type
=
ct
,
object_id
=
note
.
id
)
cls
.
register_result
(
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