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
b73c9a3d
Commit
b73c9a3d
authored
8 months ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Move tardiness to Participationstatus, simplify constraints
parent
7167e1f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!362
Resolve "Add personal note management dialog in course book"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/migrations/0023_add_tardiness_and_rework_constraints.py
+9
-38
9 additions, 38 deletions
...l/migrations/0023_add_tardiness_and_rework_constraints.py
aleksis/apps/alsijil/models.py
+8
-12
8 additions, 12 deletions
aleksis/apps/alsijil/models.py
with
17 additions
and
50 deletions
aleksis/apps/alsijil/migrations/0023_add_tardiness_and_rework_constraints.py
+
9
−
38
View file @
b73c9a3d
# Generated by Django 4.2.10 on 2024-0
6-18 09
:44
# Generated by Django 4.2.10 on 2024-0
7-01 13
:44
# Updated for more custom logic
# Updated for more custom logic
from
django.db
import
migrations
,
models
from
django.db
import
migrations
,
models
def
forwards__one_value_per_note
(
apps
,
schema_editor
):
# We get the model from the versioned app registry;
# if we directly import it, it'll be the wrong version
NewPersonalNote
=
apps
.
get_model
(
"
alsijil
"
,
"
NewPersonalNote
"
)
# noqa
db_alias
=
schema_editor
.
connection
.
alias
NewPersonalNote
.
objects
.
using
(
db_alias
).
filter
(
note
=
""
).
update
(
note
=
None
)
def
reverse__one_value_per_note
(
apps
,
schema_editor
):
NewPersonalNote
=
apps
.
get_model
(
"
alsijil
"
,
"
NewPersonalNote
"
)
# noqa
db_alias
=
schema_editor
.
connection
.
alias
NewPersonalNote
.
objects
.
using
(
db_alias
).
filter
(
note
=
None
).
update
(
note
=
""
)
def
forwards__unique_extra_mark_documentation
(
apps
,
schema_editor
):
def
forwards__unique_extra_mark_documentation
(
apps
,
schema_editor
):
NewPersonalNote
=
apps
.
get_model
(
"
alsijil
"
,
"
NewPersonalNote
"
)
# noqa
NewPersonalNote
=
apps
.
get_model
(
"
alsijil
"
,
"
NewPersonalNote
"
)
# noqa
db_alias
=
schema_editor
.
connection
.
alias
db_alias
=
schema_editor
.
connection
.
alias
...
@@ -39,10 +23,12 @@ def forwards__unique_extra_mark_documentation(apps, schema_editor):
...
@@ -39,10 +23,12 @@ def forwards__unique_extra_mark_documentation(apps, schema_editor):
)[
1
:]
)[
1
:]
NewPersonalNote
.
objects
.
using
(
db_alias
).
filter
(
pk__in
=
pks
).
delete
()
NewPersonalNote
.
objects
.
using
(
db_alias
).
filter
(
pk__in
=
pks
).
delete
()
def
reverse__unique_extra_mark_documentation
(
apps
,
schema_editor
):
def
reverse__unique_extra_mark_documentation
(
apps
,
schema_editor
):
# Nothing to do, we cannot bring back the deleted objects, but they were duplicate data, so they are not needed anyway.
# Nothing to do, we cannot bring back the deleted objects, but they were duplicate data, so they are not needed anyway.
pass
pass
class
Migration
(
migrations
.
Migration
):
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
dependencies
=
[
(
'
alsijil
'
,
'
0022_documentation_participation_touched_at
'
),
(
'
alsijil
'
,
'
0022_documentation_participation_touched_at
'
),
...
@@ -54,35 +40,20 @@ class Migration(migrations.Migration):
...
@@ -54,35 +40,20 @@ class Migration(migrations.Migration):
name
=
'
unique_absence_per_documentation
'
,
name
=
'
unique_absence_per_documentation
'
,
),
),
migrations
.
AddField
(
migrations
.
AddField
(
model_name
=
'
newpersonalnote
'
,
model_name
=
'
participationstatus
'
,
name
=
'
tardiness
'
,
name
=
'
tardiness
'
,
field
=
models
.
PositiveSmallIntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'
Tardiness
'
),
field
=
models
.
PositiveSmallIntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'
Tardiness
'
),
),
),
migrations
.
AlterField
(
migrations
.
AlterField
(
model_name
=
'
newpersonalnote
'
,
model_name
=
'
newpersonalnote
'
,
name
=
'
note
'
,
name
=
'
note
'
,
field
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'
Note
'
),
field
=
models
.
TextField
(
blank
=
True
,
default
=
''
,
verbose_name
=
'
Note
'
),
),
),
migrations
.
RunPython
(
forwards__one_value_per_note
,
reverse__one_value_per_note
),
migrations
.
AddConstraint
(
migrations
.
AddConstraint
(
model_name
=
'
newpersonalnote
'
,
model_name
=
'
newpersonalnote
'
,
constraint
=
models
.
CheckConstraint
(
constraint
=
models
.
CheckConstraint
(
check
=
models
.
Q
(
check
=
models
.
Q
(
models
.
Q
((
'
note
'
,
''
),
_negated
=
True
),
(
'
extra_mark__isnull
'
,
False
),
_connector
=
'
OR
'
),
models
.
Q
((
'
extra_mark__isnull
'
,
True
),
(
'
note__isnull
'
,
False
),
(
'
tardiness__isnull
'
,
True
)),
name
=
'
either_note_or_extra_mark_per_note
'
),
models
.
Q
((
'
extra_mark__isnull
'
,
False
),
(
'
note__isnull
'
,
True
),
(
'
tardiness__isnull
'
,
True
)),
models
.
Q
((
'
extra_mark__isnull
'
,
True
),
(
'
note__isnull
'
,
True
),
(
'
tardiness__isnull
'
,
False
)),
_connector
=
'
OR
'
),
name
=
'
one_value_per_personal_note
'
),
),
migrations
.
AddConstraint
(
model_name
=
'
newpersonalnote
'
,
constraint
=
models
.
UniqueConstraint
(
condition
=
models
.
Q
((
'
tardiness
'
,
None
),
_negated
=
True
),
fields
=
(
'
person
'
,
'
documentation
'
),
name
=
'
unique_person_documentation_tardiness
'
),
),
),
migrations
.
RunPython
(
forwards__unique_extra_mark_documentation
,
reverse__unique_extra_mark_documentation
),
migrations
.
RunPython
(
forwards__unique_extra_mark_documentation
,
reverse__unique_extra_mark_documentation
),
migrations
.
AddConstraint
(
migrations
.
AddConstraint
(
...
@@ -90,7 +61,7 @@ class Migration(migrations.Migration):
...
@@ -90,7 +61,7 @@ class Migration(migrations.Migration):
constraint
=
models
.
UniqueConstraint
(
constraint
=
models
.
UniqueConstraint
(
condition
=
models
.
Q
((
'
extra_mark
'
,
None
),
_negated
=
True
),
condition
=
models
.
Q
((
'
extra_mark
'
,
None
),
_negated
=
True
),
fields
=
(
'
person
'
,
'
documentation
'
,
'
extra_mark
'
),
fields
=
(
'
person
'
,
'
documentation
'
,
'
extra_mark
'
),
name
=
'
unique_person_documentation_extra_mark
'
name
=
'
unique_person_documentation_extra_mark
'
,
),
violation_error_message
=
'
A person got assigned the same extra mark multiple times per documentation.
'
),
),
),
]
]
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/models.py
+
8
−
12
View file @
b73c9a3d
...
@@ -790,6 +790,8 @@ class ParticipationStatus(CalendarEvent):
...
@@ -790,6 +790,8 @@ class ParticipationStatus(CalendarEvent):
verbose_name
=
_
(
"
Base Absence
"
),
verbose_name
=
_
(
"
Base Absence
"
),
)
)
tardiness
=
models
.
PositiveSmallIntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
"
Tardiness
"
))
def
fill_from_kolego
(
self
,
kolego_absence
:
KolegoAbsence
):
def
fill_from_kolego
(
self
,
kolego_absence
:
KolegoAbsence
):
"""
Take over data from a Kolego absence.
"""
"""
Take over data from a Kolego absence.
"""
self
.
base_absence
=
kolego_absence
self
.
base_absence
=
kolego_absence
...
@@ -828,33 +830,27 @@ class NewPersonalNote(ExtensibleModel):
...
@@ -828,33 +830,27 @@ class NewPersonalNote(ExtensibleModel):
null
=
True
,
null
=
True
,
)
)
note
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
"
Note
"
))
note
=
models
.
TextField
(
blank
=
True
,
default
=
""
,
verbose_name
=
_
(
"
Note
"
))
extra_mark
=
models
.
ForeignKey
(
extra_mark
=
models
.
ForeignKey
(
ExtraMark
,
on_delete
=
models
.
PROTECT
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
"
Extra Mark
"
)
ExtraMark
,
on_delete
=
models
.
PROTECT
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
"
Extra Mark
"
)
)
)
tardiness
=
models
.
PositiveSmallIntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
"
Tardiness
"
))
def
__str__
(
self
)
->
str
:
def
__str__
(
self
)
->
str
:
return
f
"
{
self
.
person
}
,
{
self
.
note
}
,
{
self
.
extra_mark
}
,
{
self
.
tardiness
}
"
return
f
"
{
self
.
person
}
,
{
self
.
note
}
,
{
self
.
extra_mark
}
"
class
Meta
:
class
Meta
:
verbose_name
=
_
(
"
Personal Note
"
)
verbose_name
=
_
(
"
Personal Note
"
)
verbose_name_plural
=
_
(
"
Personal Notes
"
)
verbose_name_plural
=
_
(
"
Personal Notes
"
)
constraints
=
[
constraints
=
[
# This constraint could be dropped in future scenarios
models
.
CheckConstraint
(
models
.
CheckConstraint
(
check
=
Q
(
note__isnull
=
False
,
extra_mark__isnull
=
True
,
tardiness__isnull
=
True
)
check
=~
Q
(
note
=
""
)
|
Q
(
extra_mark__isnull
=
False
),
|
Q
(
note__isnull
=
True
,
extra_mark__isnull
=
False
,
tardiness__isnull
=
True
)
name
=
"
either_note_or_extra_mark_per_note
"
,
|
Q
(
note__isnull
=
True
,
extra_mark__isnull
=
True
,
tardiness__isnull
=
False
),
name
=
"
one_value_per_personal_note
"
,
),
models
.
UniqueConstraint
(
fields
=
[
"
person
"
,
"
documentation
"
],
name
=
"
unique_person_documentation_tardiness
"
,
condition
=~
Q
(
tardiness
=
None
),
),
),
models
.
UniqueConstraint
(
models
.
UniqueConstraint
(
fields
=
[
"
person
"
,
"
documentation
"
,
"
extra_mark
"
],
fields
=
[
"
person
"
,
"
documentation
"
,
"
extra_mark
"
],
name
=
"
unique_person_documentation_extra_mark
"
,
name
=
"
unique_person_documentation_extra_mark
"
,
violation_error_message
=
_
(
"
A person got assigned the same extra mark multiple times per documentation.
"
),
condition
=~
Q
(
extra_mark
=
None
),
condition
=~
Q
(
extra_mark
=
None
),
),
),
]
]
...
...
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