Skip to content
Snippets Groups Projects
Commit ecf35884 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Rename late field of PersonalNote to tardiness

parent 7a76c1ae
No related branches found
No related tags found
No related merge requests found
Pipeline #95432 canceled
This commit is part of merge request !297. Comments created here will be created in the context of that merge request.
Showing with 53 additions and 30 deletions
......@@ -9,6 +9,11 @@ and this project adheres to `Semantic Versioning`_.
Unreleased
----------
Changed
~~~~~~~
* Rename the "late" field in the PersonalNote model to "tardiness".
Fixed
~~~~~
......
......@@ -41,7 +41,7 @@ def delete_personal_note(modeladmin, request, queryset):
personal_note.reset_values()
notes.append(personal_note)
PersonalNote.objects.bulk_update(
notes, fields=["absent", "excused", "late", "excuse_type", "remarks"]
notes, fields=["absent", "excused", "tardiness", "excuse_type", "remarks"]
)
......
......@@ -27,20 +27,20 @@ class PersonalNoteFilter(FilterSet):
data[name] = initial
super().__init__(data, *args, **kwargs)
self.form.fields["late__lt"].label = _("Tardiness is lower than")
self.form.fields["late__gt"].label = _("Tardiness is bigger than")
self.form.fields["tardiness"].label = _("Tardiness is lower than")
self.form.fields["tardiness"].label = _("Tardiness is bigger than")
self.form.layout = Layout(
Row("subject"),
Row("day_start", "day_end"),
Row("absent", "excused", "excuse_type"),
Row("late__gt", "late__lt", "extra_marks"),
Row("tardiness", "tardiness", "extra_marks"),
)
class Meta:
model = PersonalNote
fields = {
"excused": ["exact"],
"late": ["lt", "gt"],
"tardiness": ["lt", "gt"],
"absent": ["exact"],
"excuse_type": ["exact"],
"extra_marks": ["exact"],
......
......@@ -75,7 +75,7 @@ class LessonDocumentationForm(forms.ModelForm):
class PersonalNoteForm(forms.ModelForm):
class Meta:
model = PersonalNote
fields = ["absent", "late", "excused", "excuse_type", "extra_marks", "remarks"]
fields = ["absent", "tardiness", "excused", "excuse_type", "extra_marks", "remarks"]
person_name = forms.CharField(disabled=True)
......
......@@ -119,7 +119,7 @@ class PersonalNoteQuerySet(RegisterObjectRelatedQuerySet, QuerySet):
def not_empty(self):
"""Get all not empty personal notes."""
return self.filter(
~Q(remarks="") | Q(absent=True) | ~Q(late=0) | Q(extra_marks__isnull=False)
~Q(remarks="") | Q(absent=True) | ~Q(tardiness=0) | Q(extra_marks__isnull=False)
)
......
# Generated by Django 3.2.15 on 2022-08-27 15:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('alsijil', '0016_add_not_counted_excuse_types'),
]
operations = [
migrations.RenameField(
model_name='personalnote',
old_name='late',
new_name='tardiness',
),
]
......@@ -326,12 +326,12 @@ def get_tardinesses(self, week: Optional[CalendarWeek] = None) -> QuerySet:
"""Get all personal notes of late persons for this lesson."""
if not week:
week = self.week
return self.personal_notes.filter(week=week.week, year=week.year, late__gt=0)
return self.personal_notes.filter(week=week.week, year=week.year, tardiness__gt=0)
def get_tardinesses_simple(self, week: Optional[CalendarWeek] = None) -> QuerySet:
"""Get all personal notes of late persons for this event/extra lesson."""
return self.personal_notes.filter(late__gt=0)
return self.personal_notes.filter(tardiness__gt=0)
Event.method(get_tardinesses_simple, "get_tardinesses")
......@@ -455,10 +455,10 @@ def generate_person_list_with_class_register_statistics(
"filtered_personal_notes",
filter=Q(filtered_personal_notes__absent=True, filtered_personal_notes__excused=False),
),
tardiness=Sum("filtered_personal_notes__late"),
tardiness=Sum("filtered_personal_notes__tardiness"),
tardiness_count=Count(
"filtered_personal_notes",
filter=Q(filtered_personal_notes__late__gt=0),
filter=Q(filtered_personal_notes__tardiness__gt=0),
),
)
......
......@@ -243,7 +243,7 @@ class PersonalNote(RegisterObjectRelatedMixin, ExtensibleModel):
)
absent = models.BooleanField(default=False)
late = models.PositiveSmallIntegerField(default=0)
tardiness = models.PositiveSmallIntegerField(default=0)
excused = models.BooleanField(default=False)
excuse_type = models.ForeignKey(
ExcuseType,
......@@ -275,7 +275,7 @@ class PersonalNote(RegisterObjectRelatedMixin, ExtensibleModel):
defaults = PersonalNote()
self.absent = defaults.absent
self.late = defaults.late
self.tardiness = defaults.tardiness
self.excused = defaults.excused
self.excuse_type = defaults.excuse_type
self.remarks = defaults.remarks
......@@ -333,7 +333,7 @@ class LessonDocumentation(RegisterObjectRelatedMixin, ExtensibleModel):
lesson_period = models.ForeignKey(
"chronos.LessonPeriod", models.CASCADE, related_name="documentations", blank=True, null=True
)
)
event = models.ForeignKey(
"chronos.Event", models.CASCADE, related_name="documentations", blank=True, null=True
)
......
......@@ -115,7 +115,7 @@ class PersonalNoteTable(tables.Table):
)
subject = tables.Column(verbose_name=_("Subject"), accessor=A("subject"), linkify=True)
absent = tables.Column(verbose_name=_("Absent"))
late = tables.Column(verbose_name=_("Tardiness"))
tardiness = tables.Column(verbose_name=_("Tardiness"))
excused = tables.Column(verbose_name=_("Excuse"))
extra_marks = tables.Column(verbose_name=_("Extra marks"), accessor=A("extra_marks__all"))
......@@ -151,9 +151,9 @@ class PersonalNoteTable(tables.Table):
return badge
return ""
def render_late(self, value):
def render_tardiness(self, value):
if value:
content = _(f"{value}' late")
content = _(f"{value}' tardiness")
context = dict(content=content, classes="orange white-text")
return render_to_string("components/materialize-chips.html", context)
else:
......
......@@ -54,7 +54,7 @@
</td>
<td>
<div class="input-field">
{{ form.late }}
{{ form.tardiness }}
<label for="{{ form.absent.id_for_label }}">
{% trans "Tardiness (in m)" %}
</label>
......@@ -107,9 +107,9 @@
</td>
<td><i class="material-icons center">{{ form.absent.value|yesno:"check,clear" }}</i></td>
<td>
<i class="material-icons center">{{ form.late.value|yesno:"check,clear" }}</i>
<i class="material-icons center">{{ form.tardiness.value|yesno:"check,clear" }}</i>
<span class="alsijil-tardiness-text">
{% if form.late.value %}{{ form.late.value|to_time|time:"i\m" }}{% endif %}
{% if form.tardiness.value %}{{ form.tardiness.value|to_time|time:"i\m" }}{% endif %}
</span>
</td>
<td><i class="material-icons center">{{ form.excused.value|yesno:"check,clear" }}</i></td>
......
......@@ -2,6 +2,6 @@
{% for note in notes %}
{% has_perm "alsijil.view_personalnote_rule" user note as can_view_personalnote %}
{% if can_view_personalnote %}
<span>{{ note.person }} ({{ note.late }}'){% if not forloop.last %},{% endif %}</span>
<span>{{ note.person }} ({{ note.tardiness }}'){% if not forloop.last %},{% endif %}</span>
{% endif %}
{% endfor %}
......@@ -357,7 +357,7 @@
<tbody>
{% for note in person.filtered_notes %}
{% if note.absent or note.late or note.remarks or note.extra_marks.all %}
{% if note.absent or note.tardiness or note.remarks or note.extra_marks.all %}
<tr>
{% if note.date %}
<td>{{ note.date }}</td>
......@@ -389,8 +389,8 @@
{% endif %}
</td>
<td>
{% if note.late %}
{{ note.late }}'
{% if note.tardiness %}
{{ note.tardiness }}'
{% endif %}
</td>
<td>
......@@ -486,10 +486,10 @@
{% endif %}
</span>
{% endif %}
{% if note.late %}
{% if note.tardiness %}
<span class="lesson-note-late">
{{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}.
({{ note.late }}′)
({{ note.tardiness }}′)
{% if note.excused %}
<span class="lesson-note-excused">
{% if note.excuse_type %}
......
......@@ -538,10 +538,10 @@ def week_view(
filtered_personal_notes__absent=True, filtered_personal_notes__excused=False
),
),
tardiness_sum=Sum("filtered_personal_notes__late"),
tardiness_sum=Sum("filtered_personal_notes__tardiness"),
tardiness_count=Count(
"filtered_personal_notes",
filter=Q(filtered_personal_notes__late__gt=0),
filter=Q(filtered_personal_notes__tardiness__gt=0),
),
)
......@@ -1008,8 +1008,8 @@ def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResp
unexcused=Count("absent")
)
)
stat.update(personal_notes.aggregate(tardiness=Sum("late")))
stat.update(personal_notes.filter(~Q(late=0)).aggregate(tardiness_count=Count("late")))
stat.update(personal_notes.aggregate(tardiness=Sum("tardiness")))
stat.update(personal_notes.filter(~Q(tardiness=0)).aggregate(tardiness_count=Count("tardiness")))
for extra_mark in extra_marks:
stat.update(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment