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
0a33cbb2
Verified
Commit
0a33cbb2
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Revert change to 404 error if group not found in class register.
It accidentally removed the possibility to select a group manually.
parent
0e6e6b5a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
biscuit/apps/alsijil/templates/alsijil/group_week.html
+83
-68
83 additions, 68 deletions
biscuit/apps/alsijil/templates/alsijil/group_week.html
biscuit/apps/alsijil/views.py
+35
-34
35 additions, 34 deletions
biscuit/apps/alsijil/views.py
with
118 additions
and
102 deletions
biscuit/apps/alsijil/templates/alsijil/group_week.html
+
83
−
68
View file @
0a33cbb2
...
...
@@ -17,79 +17,94 @@
<input
type=
"submit"
value=
"Select"
/>
</form>
<div
class=
"row"
>
<div
class=
"col-md-7"
>
<div
class=
"card"
>
<div
class=
"card-header bg-light text-dark"
>
{% blocktrans %}Week{% endblocktrans %}
{{ week }} ({{ week|week_start }} — {{ week|week_end }}),
{{ group.name }}
</div>
<div
class=
"card-body"
>
{% regroup lesson_periods by period.weekday as periods_by_day %}
{% for weekday, periods in periods_by_day.items %}
<h3>
{{ weekday }}
</h3>
<table
class=
"table table-striped table-bordered table-hover table-responsive-xl"
>
<thead>
<tr>
<th>
{% blocktrans %}Period{% endblocktrans %}
</th>
<th>
{% blocktrans %}Subject{% endblocktrans %}
</th>
<th>
{% blocktrans %}Teachers{% endblocktrans %}
</th>
</tr>
</thead>
<tbody>
{% for period in periods %}
<tr
class=
"
{% if period.has_documentation %}
table-success
{% else %}
{% weekday_to_date week weekday as current_date %}
{% today as today %}
{% if current_date < today %}
table-danger
{% endif %}
{% endif %}
"
>
<td>
{{ period.period.period }}
</td>
<td>
<a
href=
"{% url 'lesson_by_week_and_period' week period.id %}"
>
{{ period.lesson.subject.name }}
</a>
</td>
<td>
{{ period.lesson.teacher_names }}
</td>
{% if group %}
<div
class=
"row"
>
<div
class=
"col-md-7"
>
<div
class=
"card"
>
<div
class=
"card-header bg-light text-dark"
>
{% blocktrans %}Week{% endblocktrans %}
{{ week }} ({{ week|week_start }} — {{ week|week_end }}),
{{ group.name }}
</div>
<div
class=
"card-body"
>
{% regroup lesson_periods by period.weekday as periods_by_day %}
{% for weekday, periods in periods_by_day.items %}
<h3>
{{ weekday }}
</h3>
<table
class=
"table table-striped table-bordered table-hover table-responsive-xl"
>
<thead>
<tr>
<th>
{% blocktrans %}Period{% endblocktrans %}
</th>
<th>
{% blocktrans %}Subject{% endblocktrans %}
</th>
<th>
{% blocktrans %}Teachers{% endblocktrans %}
</th>
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for period in periods %}
<tr
class=
"
{% if period.has_documentation %}
table-success
{% else %}
{% weekday_to_date week weekday as current_date %}
{% today as today %}
{% if current_date < today %}
table-danger
{% endif %}
{% endif %}
"
>
<td>
{{ period.period.period }}
</td>
<td>
<a
href=
"{% url 'lesson_by_week_and_period' week period.id %}"
>
{{ period.lesson.subject.name }}
</a>
</td>
<td>
{{ period.lesson.teacher_names }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
</div>
</div>
</div>
<div
class=
"col-md-5"
>
<div
class=
"card"
>
<div
class=
"card-header bg-light text-dark"
>
{% blocktrans %}Personal notes{% endblocktrans %}
</div>
{% for person in persons %}
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
{{ person.full_name }}
</h5>
<p
class=
"card-text"
>
{% trans "Absent" %}: {{ person.absences }}
({{ person.unexcused }} {% trans "unexcused" %})
</p>
<p
class=
"card-text"
>
{% trans "Summed up tardiness" %}: {{ person.tardiness }}
</p>
{% for note in person.personal_notes %}
{% if note.remarks %}
<p
class=
"card-text"
>
{{ note.remarks }}
</p>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
</div>
</div>
<div
class=
"col-md-5"
>
<div
class=
"card"
>
<div
class=
"card-header bg-light text-dark"
>
{% blocktrans %}Personal notes{% endblocktrans %}
</div>
{% for person in persons %}
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
{{ person.full_name }}
</h5>
<p
class=
"card-text"
>
{% trans "Absent" %}: {{ person.absences }}
({{ person.unexcused }} {% trans "unexcused" %})
</p>
<p
class=
"card-text"
>
{% trans "Summed up tardiness" %}: {{ person.tardiness }}
</p>
{% for note in person.personal_notes %}
{% if note.remarks %}
<p
class=
"card-text"
>
{{ note.remarks }}
</p>
{% endif %}
{% endfor %}
</div>
{% endfor %}
{% else %}
<div
class=
"card text-white bg-danger"
>
<div
class=
"card-header"
>
{% blocktrans %}No group selected{% endblocktrans %}
</div>
<div
class=
"card-body"
>
<p>
{% blocktrans %}
You must select a group to see the week summary.
{% endblocktrans %}
</p>
</div>
</div>
</div>
{% endif %}
{% endblock %}
This diff is collapsed.
Click to expand it.
biscuit/apps/alsijil/views.py
+
35
−
34
View file @
0a33cbb2
...
...
@@ -98,40 +98,41 @@ def group_week(request: HttpRequest, week: Optional[int] = None) -> HttpResponse
else
:
group
=
None
if
not
group
:
raise
Http404
(
_
(
'
You must select a group to see the week summary.
'
))
# Get all lesson periods for the selected group
lesson_periods
=
LessonPeriod
.
objects
.
annotate
(
has_documentation
=
Exists
(
LessonDocumentation
.
objects
.
filter
(
~
Q
(
topic__exact
=
''
),
lesson_period
=
OuterRef
(
'
pk
'
)
))
).
filter
(
lesson__date_start__lte
=
week_start
,
lesson__date_end__gte
=
week_end
).
select_related
(
'
lesson
'
,
'
lesson__subject
'
,
'
period
'
,
'
room
'
).
prefetch_related
(
'
lesson__groups
'
,
'
lesson__teachers
'
,
'
substitutions
'
).
extra
(
select
=
{
'
_week
'
:
wanted_week
}
).
filter
(
Q
(
lesson__groups__pk
=
int
(
request
.
GET
[
'
group
'
]))
|
Q
(
lesson__groups__parent_groups__pk
=
int
(
request
.
GET
[
'
group
'
]))
)
# Aggregate all personal notes for this group and week
persons
=
Person
.
objects
.
filter
(
is_active
=
True
).
filter
(
Q
(
member_of
=
group
)
|
Q
(
member_of__parent_groups
=
group
)
).
prefetch_related
(
'
personal_notes
'
).
annotate
(
absences
=
Count
(
'
personal_notes__absent
'
,
filter
=
Q
(
week
=
wanted_week
,
absent
=
True
)),
unexcused
=
Count
(
'
personal_notes__absent
'
,
filter
=
Q
(
week
=
wanted_week
,
absent
=
True
,
excused
=
False
)),
tardiness
=
Sum
(
'
personal_notes__tardiness
'
,
filter
=
Q
(
week
=
wanted_week
))
)
if
group
:
# Get all lesson periods for the selected group
lesson_periods
=
LessonPeriod
.
objects
.
annotate
(
has_documentation
=
Exists
(
LessonDocumentation
.
objects
.
filter
(
~
Q
(
topic__exact
=
''
),
lesson_period
=
OuterRef
(
'
pk
'
)
))
).
filter
(
lesson__date_start__lte
=
week_start
,
lesson__date_end__gte
=
week_end
).
select_related
(
'
lesson
'
,
'
lesson__subject
'
,
'
period
'
,
'
room
'
).
prefetch_related
(
'
lesson__groups
'
,
'
lesson__teachers
'
,
'
substitutions
'
).
extra
(
select
=
{
'
_week
'
:
wanted_week
}
).
filter
(
Q
(
lesson__groups__pk
=
int
(
request
.
GET
[
'
group
'
]))
|
Q
(
lesson__groups__parent_groups__pk
=
int
(
request
.
GET
[
'
group
'
]))
)
# Aggregate all personal notes for this group and week
persons
=
Person
.
objects
.
filter
(
is_active
=
True
).
filter
(
Q
(
member_of
=
group
)
|
Q
(
member_of__parent_groups
=
group
)
).
prefetch_related
(
'
personal_notes
'
).
annotate
(
absences
=
Count
(
'
personal_notes__absent
'
,
filter
=
Q
(
week
=
wanted_week
,
absent
=
True
)),
unexcused
=
Count
(
'
personal_notes__absent
'
,
filter
=
Q
(
week
=
wanted_week
,
absent
=
True
,
excused
=
False
)),
tardiness
=
Sum
(
'
personal_notes__tardiness
'
,
filter
=
Q
(
week
=
wanted_week
))
)
else
:
lesson_periods
=
None
persons
=
None
# Add a form to filter the view
select_form
=
SelectForm
(
request
.
GET
or
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