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
349a9ec4
Verified
Commit
349a9ec4
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Refactor group view logic to properly load lessons. Closes
#16
.
parent
b7e635cc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+42
-56
42 additions, 56 deletions
biscuit/apps/alsijil/templates/alsijil/group_week.html
biscuit/apps/alsijil/views.py
+16
-13
16 additions, 13 deletions
biscuit/apps/alsijil/views.py
with
58 additions
and
69 deletions
biscuit/apps/alsijil/templates/alsijil/group_week.html
+
42
−
56
View file @
349a9ec4
...
...
@@ -17,67 +17,53 @@
<input
type=
"submit"
value=
"Select"
/>
</form>
{% 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"
>
{% for weekday, periods in periods_by_day.items %}
<h3>
{{ weekday }}
</h3>
<table
class=
"table table-striped table-bordered table-hover table-responsive-xl"
>
<thead>
<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>
<th>
{% blocktrans %}Period{% endblocktrans %}
</th>
<th>
{% blocktrans %}Subject{% endblocktrans %}
</th>
<th>
{% blocktrans %}Teachers{% endblocktrans %}
</th>
<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>
</thead>
<tbody>
{% for period in periods %}
<tr>
<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>
<div
class=
"card-body"
>
Not implemented yet.
</div>
{% endfor %}
</tbody>
</table>
{% endfor %}
</div>
</div>
</div>
{% 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
class=
"col-md-5"
>
<div
class=
"card"
>
<div
class=
"card-header bg-light text-dark"
>
{% blocktrans %}Personal notes{% endblocktrans %}
</div>
<div
class=
"card-body"
>
Not implemented yet.
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}
This diff is collapsed.
Click to expand it.
biscuit/apps/alsijil/views.py
+
16
−
13
View file @
349a9ec4
...
...
@@ -98,25 +98,28 @@ def group_week(request: HttpRequest, week: Optional[int] = None) -> HttpResponse
else
:
group
=
None
periods_by_day_unsorted
=
{}
if
group
:
for
act_group
in
[
group
]
+
list
(
group
.
child_groups
.
all
()):
for
lesson
in
act_group
.
lessons
.
filter
(
date_start__lte
=
week_start
,
date_end__gte
=
week_end
):
for
lesson_period
in
lesson
.
lesson_periods
.
all
():
periods_by_day_unsorted
.
setdefault
(
lesson_period
.
period
.
weekday
,
[]).
append
(
lesson_period
)
periods_by_day
=
OrderedDict
()
for
weekday
,
periods
in
sorted
(
periods_by_day_unsorted
.
items
()):
periods_by_day
[
dict
(
TimePeriod
.
WEEKDAY_CHOICES
)[
weekday
]]
=
sorted
(
periods
,
key
=
lambda
p
:
p
.
period
.
period
)
if
not
group
:
raise
Http404
(
_
(
'
You must select a group to see the week summary.
'
))
lesson_periods
=
LessonPeriod
.
objects
.
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
'
]))
)
# Add a form to filter the view
select_form
=
SelectForm
(
request
.
GET
or
None
)
context
[
'
week
'
]
=
wanted_week
context
[
'
group
'
]
=
group
context
[
'
periods_by_day
'
]
=
periods_by_day
context
[
'
lesson_periods
'
]
=
lesson_periods
context
[
'
select_form
'
]
=
select_form
return
render
(
request
,
'
alsijil/group_week.html
'
,
context
)
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