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
e1a7b126
Verified
Commit
e1a7b126
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Write data check NoGroupsOfPersonsSetInPersonalNotesDataCheck
parent
e8129856
No related branches found
No related tags found
1 merge request
!92
Resolve "Add task for checking plausibility of data"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/alsijil/data_checks.py
+44
-1
44 additions, 1 deletion
aleksis/apps/alsijil/data_checks.py
with
44 additions
and
1 deletion
aleksis/apps/alsijil/data_checks.py
+
44
−
1
View file @
e1a7b126
...
...
@@ -6,7 +6,12 @@ from django.utils.translation import gettext as _
from
calendarweek
import
CalendarWeek
from
aleksis.core.data_checks
import
DATA_CHECK_REGISTRY
,
DataCheck
,
IgnoreSolveOption
,
SolveOption
from
aleksis.core.data_checks
import
(
DATA_CHECK_REGISTRY
,
DataCheck
,
IgnoreSolveOption
,
SolveOption
,
)
class
DeleteRelatedObjectSolveOption
(
SolveOption
):
...
...
@@ -19,6 +24,17 @@ class DeleteRelatedObjectSolveOption(SolveOption):
check_result
.
delete
()
class
SetGroupsOfPersonWithCurrentGroupsOfPersonSolveOption
(
SolveOption
):
name
=
"
set_groups_of_person
"
verbose_name
=
_
(
"
Set current groups
"
)
@classmethod
def
solve
(
cls
,
check_result
:
"
DataCheckResult
"
):
person
=
check_result
.
related_object
.
person
check_result
.
related_object
.
groups_of_person
.
set
(
person
.
member_of
.
all
())
check_result
.
delete
()
@DATA_CHECK_REGISTRY.register
class
NoPersonalNotesInCancelledLessonsDataCheck
(
DataCheck
):
name
=
"
no_personal_notes_in_cancelled_lessons
"
...
...
@@ -50,3 +66,30 @@ class NoPersonalNotesInCancelledLessonsDataCheck(DataCheck):
result
=
DataCheckResult
.
objects
.
get_or_create
(
check
=
cls
.
name
,
content_type
=
ct
,
object_id
=
note
.
id
)
@DATA_CHECK_REGISTRY.register
class
NoGroupsOfPersonsSetInPersonalNotesDataCheck
(
DataCheck
):
name
=
"
no_groups_of_persons_set_in_personal_notes
"
verbose_name
=
_
(
"
Ensure that
'
groups_of_person
'
is set for every personal note
"
)
problem_name
=
_
(
"
The personal note has no group in
'
groups_of_person
'
.
"
)
solve_options
=
{
SetGroupsOfPersonWithCurrentGroupsOfPersonSolveOption
.
name
:
SetGroupsOfPersonWithCurrentGroupsOfPersonSolveOption
,
DeleteRelatedObjectSolveOption
.
name
:
DeleteRelatedObjectSolveOption
,
IgnoreSolveOption
.
name
:
IgnoreSolveOption
,
}
@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
)
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