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
fbab2b33
Verified
Commit
fbab2b33
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Create revisions for personal notes
parent
e4f94f12
No related branches found
No related tags found
1 merge request
!86
Resolve "Add option to reset personal note ("delete") at students view for class teachers"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/model_extensions.py
+21
-15
21 additions, 15 deletions
aleksis/apps/alsijil/model_extensions.py
aleksis/apps/alsijil/views.py
+10
-5
10 additions, 5 deletions
aleksis/apps/alsijil/views.py
with
31 additions
and
20 deletions
aleksis/apps/alsijil/model_extensions.py
+
21
−
15
View file @
fbab2b33
...
...
@@ -3,6 +3,7 @@ from typing import Dict, Optional, Union
from
django.db.models
import
Exists
,
OuterRef
,
QuerySet
import
reversion
from
calendarweek
import
CalendarWeek
from
aleksis.apps.chronos.models
import
LessonPeriod
...
...
@@ -45,21 +46,26 @@ def mark_absent(
# Create and update all personal notes for the discovered lesson periods
for
lesson_period
in
lesson_periods
:
personal_note
,
created
=
PersonalNote
.
objects
.
update_or_create
(
person
=
self
,
lesson_period
=
lesson_period
,
week
=
wanted_week
.
week
,
year
=
wanted_week
.
year
,
defaults
=
{
"
absent
"
:
absent
,
"
excused
"
:
excused
,
"
excuse_type
"
:
excuse_type
},
)
personal_note
.
groups_of_person
.
set
(
self
.
member_of
.
all
())
if
remarks
:
if
personal_note
.
remarks
:
personal_note
.
remarks
+=
"
; %s
"
%
remarks
else
:
personal_note
.
remarks
=
remarks
personal_note
.
save
()
with
reversion
.
create_revision
():
personal_note
,
created
=
PersonalNote
.
objects
.
update_or_create
(
person
=
self
,
lesson_period
=
lesson_period
,
week
=
wanted_week
.
week
,
year
=
wanted_week
.
year
,
defaults
=
{
"
absent
"
:
absent
,
"
excused
"
:
excused
,
"
excuse_type
"
:
excuse_type
,
},
)
personal_note
.
groups_of_person
.
set
(
self
.
member_of
.
all
())
if
remarks
:
if
personal_note
.
remarks
:
personal_note
.
remarks
+=
"
; %s
"
%
remarks
else
:
personal_note
.
remarks
=
remarks
personal_note
.
save
()
@LessonPeriod.method
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/views.py
+
10
−
5
View file @
fbab2b33
...
...
@@ -127,7 +127,8 @@ def lesson(
or
not
get_site_preferences
()[
"
alsijil__block_personal_notes_for_cancelled
"
]
):
if
personal_note_formset
.
is_valid
():
instances
=
personal_note_formset
.
save
()
with
reversion
.
create_revision
():
instances
=
personal_note_formset
.
save
()
# Iterate over personal notes and carry changed absences to following lessons
for
instance
in
instances
:
...
...
@@ -510,7 +511,12 @@ def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResp
absent
=
True
,
excused
=
False
,
)
notes
.
update
(
excused
=
True
,
excuse_type
=
excuse_type
)
for
note
in
notes
:
note
.
excused
=
True
note
.
excuse_type
=
excuse_type
with
reversion
.
create_revision
():
note
.
save
()
messages
.
success
(
request
,
_
(
"
The absences have been marked as excused.
"
)
)
...
...
@@ -525,7 +531,8 @@ def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResp
if
note
.
absent
:
note
.
excused
=
True
note
.
excuse_type
=
excuse_type
note
.
save
()
with
reversion
.
create_revision
():
note
.
save
()
messages
.
success
(
request
,
_
(
"
The absence has been marked as excused.
"
)
)
...
...
@@ -646,8 +653,6 @@ class DeletePersonalNoteView(DetailView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
note
=
self
.
get_object
()
with
reversion
.
create_revision
():
self
.
save
()
with
reversion
.
create_revision
():
note
.
reset_values
()
messages
.
success
(
request
,
_
(
"
The personal note has been deleted.
"
))
...
...
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