Skip to content
Snippets Groups Projects
Commit 3039a61f authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch...

Merge branch '11-lesson-substitution-view-with-all-lesson-substitutions-in-the-future' into 'master'

Resolve "[Lesson substitution] View with all lesson substitutions in the future"

Closes #11

See merge request BiscuIT/BiscuIT-App-Chronos!21
parents 04e24cdb adf0ff2e
No related branches found
No related tags found
1 merge request!21Resolve "[Lesson substitution] View with all lesson substitutions in the future"
Changelog Changelog
========= =========
`1.0a2`_
--------
New features
~~~~~~~~~~~~
* Add list of all future substitutions
`1.0a2`_ `1.0a2`_
-------- --------
...@@ -37,3 +46,4 @@ Minor changes ...@@ -37,3 +46,4 @@ Minor changes
_`1.0a1`: https://edugit.org/Teckids/BiscuIT/BiscuIT-App-Chronos/-/tags/1.0a1 _`1.0a1`: https://edugit.org/Teckids/BiscuIT/BiscuIT-App-Chronos/-/tags/1.0a1
_`1.0a2`: https://edugit.org/Teckids/BiscuIT/BiscuIT-App-Chronos/-/tags/1.0a2 _`1.0a2`: https://edugit.org/Teckids/BiscuIT/BiscuIT-App-Chronos/-/tags/1.0a2
_`1.0a3`: https://edugit.org/Teckids/BiscuIT/BiscuIT-App-Chronos/-/tags/1.0a3
...@@ -17,6 +17,11 @@ MENUS = { ...@@ -17,6 +17,11 @@ MENUS = {
'name': _('Daily lessons'), 'name': _('Daily lessons'),
'url': 'lessons_day', 'url': 'lessons_day',
'validators': ['menu_generator.validators.is_authenticated'] 'validators': ['menu_generator.validators.is_authenticated']
},
{
'name': _('Substitutions'),
'url': 'substitutions',
'validators': ['menu_generator.validators.is_authenticated']
} }
] ]
} }
......
...@@ -31,3 +31,15 @@ class LessonsTable(tables.Table): ...@@ -31,3 +31,15 @@ class LessonsTable(tables.Table):
room = tables.Column(accessor='room') room = tables.Column(accessor='room')
edit_substitution = tables.LinkColumn( edit_substitution = tables.LinkColumn(
'edit_substitution', args=[A('id'), A('_week')], text=_('Substitution')) 'edit_substitution', args=[A('id'), A('_week')], text=_('Substitution'))
class SubstitutionsTable(tables.Table):
class Meta:
attrs = {'class': 'table table-striped table-bordered table-hover table-responsive-xl'}
lesson_period = tables.Column(verbose_name=_('Lesson'))
lesson__groups = tables.Column(accessor='lesson_period.lesson.group_names', verbose_name=_('Groups'))
lesson__teachers = tables.Column(accessor='lesson_period.get_teacher_names', verbose_name=_('Teachers'))
lesson__subject = tables.Column(accessor='subject')
room = tables.Column(accessor='room')
cancelled = tables.BooleanColumn(accessor='cancelled', verbose_name=_('Cancelled'))
{# -*- engine:django -*- #}
{% extends "core/turnable.html" %}
{% load bootstrap4 i18n font_awesome %}
{% load render_table from django_tables2 %}
{% block bootstrap4_title %}{% blocktrans %}Substitutions{% endblocktrans %} - {{ block.super }}{% endblock %}
{% block current_content %}
{% render_table substitutions_table %}
{% endblock %}
...@@ -9,5 +9,7 @@ urlpatterns = [ ...@@ -9,5 +9,7 @@ urlpatterns = [
path('lessons', views.lessons_day, name='lessons_day'), path('lessons', views.lessons_day, name='lessons_day'),
path('lessons/<when>', views.lessons_day, name='lessons_day_by_date'), path('lessons/<when>', views.lessons_day, name='lessons_day_by_date'),
path('lessons/<int:id_>/<int:week>/substition', views.edit_substitution, name='edit_substitution'), path('lessons/<int:id_>/<int:week>/substition', views.edit_substitution, name='edit_substitution'),
path('lessons/<int:id_>/<int:week>/substition/delete', views.delete_substitution, name='delete_substitution') path('lessons/<int:id_>/<int:week>/substition/delete', views.delete_substitution, name='delete_substitution'),
path('substitutions', views.substitutions, name='substitutions'),
path('substitutions/<int:year>/<int:week>', views.substitutions, name='substitutions_by_week')
] ]
...@@ -17,7 +17,7 @@ from biscuit.core.util import messages ...@@ -17,7 +17,7 @@ from biscuit.core.util import messages
from .forms import SelectForm, LessonSubstitutionForm from .forms import SelectForm, LessonSubstitutionForm
from .models import LessonPeriod, TimePeriod, LessonSubstitution from .models import LessonPeriod, TimePeriod, LessonSubstitution
from .util import CalendarWeek from .util import CalendarWeek
from .tables import LessonsTable from .tables import LessonsTable, SubstitutionsTable
@login_required @login_required
...@@ -160,3 +160,27 @@ def delete_substitution(request: HttpRequest, id_: int, week: int) -> HttpRespon ...@@ -160,3 +160,27 @@ def delete_substitution(request: HttpRequest, id_: int, week: int) -> HttpRespon
messages.success(request, _('The substitution has been deleted.')) messages.success(request, _('The substitution has been deleted.'))
return redirect('lessons_day_by_date', when=wanted_week[lesson_period.period.weekday - 1].strftime('%Y-%m-%d')) return redirect('lessons_day_by_date', when=wanted_week[lesson_period.period.weekday - 1].strftime('%Y-%m-%d'))
def substitutions(request: HttpRequest, year: Optional[int] = None, week: Optional[int] = None) -> HttpResponse:
context = {}
if week:
wanted_week = CalendarWeek(year=year, week=week)
else:
wanted_week = CalendarWeek()
substitutions = LessonSubstitution.objects.filter(week=wanted_week.week)
# Prepare table
substitutions_table = SubstitutionsTable(substitutions)
RequestConfig(request).configure(substitutions_table)
context['current_head'] = str(wanted_week)
context['substitutions_table'] = substitutions_table
week_prev = wanted_week - 1
week_next = wanted_week + 1
context['url_prev'] = '%s' % (reverse('substitutions_by_week', args=[week_prev.year, week_prev.week]))
context['url_next'] = '%s' % (reverse('substitutions_by_week', args=[week_next.year, week_next.week]))
return render(request, 'chronos/substitutions.html', context)
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