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
81c3a538
Verified
Commit
81c3a538
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Allow setting personal notes only if lesson isn't cancelled
parent
3cb069cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!61
Resolve "Do not allow to add personal notes for cancelled lessons"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/templates/alsijil/class_register/lesson.html
+56
-54
56 additions, 54 deletions
...apps/alsijil/templates/alsijil/class_register/lesson.html
aleksis/apps/alsijil/views.py
+21
-13
21 additions, 13 deletions
aleksis/apps/alsijil/views.py
with
77 additions
and
67 deletions
aleksis/apps/alsijil/templates/alsijil/class_register/lesson.html
+
56
−
54
View file @
81c3a538
...
...
@@ -128,66 +128,68 @@
</div>
</div>
<div
class=
"row"
>
<div
class=
"col s12"
>
<div
class=
"card"
>
<div
class=
"card-content"
>
<span
class=
"card-title"
>
{% blocktrans %}Personal notes{% endblocktrans %}
</span>
{% form form=personal_note_formset.management_form %}{% endform %}
<table
class=
"striped responsive-table alsijil-table"
>
<thead>
<tr>
<th>
{% blocktrans %}Person{% endblocktrans %}
</th>
<th>
{% blocktrans %}Absent{% endblocktrans %}
</th>
<th>
{% blocktrans %}Tardiness{% endblocktrans %}
</th>
<th>
{% blocktrans %}Excused{% endblocktrans %}
</th>
<th>
{% blocktrans %}Remarks{% endblocktrans %}
</th>
</tr>
</thead>
<tbody>
{% for form in personal_note_formset %}
{% if not lesson_period.get_substitution.cancelled %}
<div
class=
"row"
>
<div
class=
"col s12"
>
<div
class=
"card"
>
<div
class=
"card-content"
>
<span
class=
"card-title"
>
{% blocktrans %}Personal notes{% endblocktrans %}
</span>
{% form form=personal_note_formset.management_form %}{% endform %}
<table
class=
"striped responsive-table alsijil-table"
>
<thead>
<tr>
{{ form.id }}
<td>
{{ form.person_name }}{{ form.person_name.value }}
</td>
<td
class=
"center-align"
>
<label>
{{ form.absent }}
<span></span>
</label>
</td>
<td>
<div
class=
"input-field"
>
{{ form.late }}
<label
for=
"{{ form.absent.id_for_label }}"
>
{% trans "Tardiness (in m)" %}
<th>
{% blocktrans %}Person{% endblocktrans %}
</th>
<th>
{% blocktrans %}Absent{% endblocktrans %}
</th>
<th>
{% blocktrans %}Tardiness{% endblocktrans %}
</th>
<th>
{% blocktrans %}Excused{% endblocktrans %}
</th>
<th>
{% blocktrans %}Remarks{% endblocktrans %}
</th>
</tr>
</thead>
<tbody>
{% for form in personal_note_formset %}
<tr>
{{ form.id }}
<td>
{{ form.person_name }}{{ form.person_name.value }}
</td>
<td
class=
"center-align"
>
<label>
{{ form.absent }}
<span></span>
</label>
</d
iv
>
<
/
td>
<td
class=
"center-align
"
>
<label>
{{ form.excused
}}
<span></span>
</label>
</td
>
<
td>
<d
iv
class=
"
input-field
"
>
{{ form.remarks }}
<label
for=
"{{ form.absent.id_for_label
}}
"
>
{% trans "Remarks" %}
</
t
d>
<td>
<div
class=
"input-field
"
>
{{ form.late }}
<label
for=
"{{ form.absent.id_for_label
}}
"
>
{% trans "Tardiness (in m)" %}
</label>
</div
>
</
td>
<
t
d
class=
"
center-align
"
>
<label>
{{ form.excused
}}
<span></span>
</label>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</td>
<td>
<div
class=
"input-field"
>
{{ form.remarks }}
<label
for=
"{{ form.absent.id_for_label }}"
>
{% trans "Remarks" %}
</label>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endif %}
<div
class=
"row"
>
<div
class=
"col s12"
>
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/views.py
+
21
−
13
View file @
81c3a538
...
...
@@ -12,7 +12,7 @@ from calendarweek import CalendarWeek
from
django_tables2
import
RequestConfig
from
aleksis.apps.chronos.managers
import
TimetableType
from
aleksis.apps.chronos.models
import
LessonPeriod
from
aleksis.apps.chronos.models
import
LessonPeriod
,
LessonSubstitution
from
aleksis.apps.chronos.util.chronos_helpers
import
get_el_by_pk
from
aleksis.core.models
import
Group
,
Person
,
SchoolTerm
from
aleksis.core.util
import
messages
...
...
@@ -98,17 +98,19 @@ def lesson(
if
lesson_documentation_form
.
is_valid
():
lesson_documentation_form
.
save
()
if
personal_note_formset
.
is_valid
():
instances
=
personal_note_formset
.
save
()
# Iterate over personal notes and carry changed absences to following lessons
for
instance
in
instances
:
instance
.
person
.
mark_absent
(
wanted_week
[
lesson_period
.
period
.
weekday
],
lesson_period
.
period
.
period
+
1
,
instance
.
absent
,
instance
.
excused
,
)
substitution
=
lesson_period
.
get_substitution
()
if
not
getattr
(
substitution
,
"
cancelled
"
,
False
):
if
personal_note_formset
.
is_valid
():
instances
=
personal_note_formset
.
save
()
# Iterate over personal notes and carry changed absences to following lessons
for
instance
in
instances
:
instance
.
person
.
mark_absent
(
wanted_week
[
lesson_period
.
period
.
weekday
],
lesson_period
.
period
.
period
+
1
,
instance
.
absent
,
instance
.
excused
,
)
context
[
"
lesson_documentation
"
]
=
lesson_documentation
context
[
"
lesson_documentation_form
"
]
=
lesson_documentation_form
...
...
@@ -297,7 +299,13 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse:
persons
=
group
.
members
.
annotate
(
absences_count
=
Count
(
"
personal_notes__absent
"
,
filter
=
Q
(
personal_notes__absent
=
True
)
"
personal_notes__absent
"
,
filter
=
Q
(
personal_notes__absent
=
True
)
&
~
Q
(
personal_notes__lesson_period__substitutions
=
Subquery
(
LessonSubstitution
.
objects
.
filter
(
lesson_period__pk
=
OuterRef
(
"
personal_notes__lesson_period__pk
"
),
cancelled
=
True
,
week
=
OuterRef
(
"
personal_notes__week
"
),
).
values
(
"
pk
"
)
))
),
unexcused
=
Count
(
"
personal_notes__absent
"
,
...
...
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