diff --git a/batadasen/templates/base.html b/batadasen/templates/base.html index d2ac607..8116dbd 100644 --- a/batadasen/templates/base.html +++ b/batadasen/templates/base.html @@ -39,6 +39,7 @@
Spextjänster
Internsidor
Inställningar Uppsättningar + Verksamhetsår Epostlistor Inventarier Föreställningsräknare diff --git a/batadasen/templates/batadasen/associationyear_detail.html b/batadasen/templates/batadasen/associationyear_detail.html new file mode 100644 index 0000000..b551362 --- /dev/null +++ b/batadasen/templates/batadasen/associationyear_detail.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} +{% load i18n %} + +{% block title %}Verksamhetsår {{ object }}{% endblock %} + +{% block content %} +

Verksamhetsår {{ object }}

+ +{% for group in groups %} + +{% for activity in group.activities %} + + + + + + +{% endfor %} +{% endfor %} +
{{ group.group.group_type.name }} ({{ group.group.group_type.short_name }})
{{ activity.person.member_number }}{{ activity.person.first_name }} {% if activity.person.spex_name %}"{{ activity.person.spex_name }}" {% endif %}{{ activity.person.last_name }}{% if activity.title %}{{ activity.title }}{% endif %}{% if activity.comment %}{{ activity.comment }}{% endif %}
+{% endblock %} \ No newline at end of file diff --git a/batadasen/templates/batadasen/associationyear_list.html b/batadasen/templates/batadasen/associationyear_list.html new file mode 100644 index 0000000..0ed7aca --- /dev/null +++ b/batadasen/templates/batadasen/associationyear_list.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} +{% load i18n %} + +{% block title %}Verksamhetsår{% endblock %} + +{% block content %} +

Verksamhetsår

+ + + + + {% for year in object_list %} + + + + {% endfor %} +
År
{{ year }}
+{% endblock %} \ No newline at end of file diff --git a/batadasen/urls.py b/batadasen/urls.py index 4afc542..c8b9ca7 100644 --- a/batadasen/urls.py +++ b/batadasen/urls.py @@ -13,6 +13,8 @@ path('persons//', views.PersonDetailView.as_view(), name='person_detail'), path('productions/', views.ProductionListView.as_view(), name='production_list'), path('productions//', views.ProductionDetailView.as_view(), name='production_detail'), + path('association/', views.AssociationYearListView.as_view(), name='associationyear_list'), + path('association//', views.AssociationYearDetailView.as_view(), name='associationyear_detail'), path('api/users', views.UserList.as_view()), path('api/users_count', views.user_count), path('no_admin/', views.no_admin_view, name='no_admin'), diff --git a/batadasen/views.py b/batadasen/views.py index 599ec7a..29c9d83 100644 --- a/batadasen/views.py +++ b/batadasen/views.py @@ -154,6 +154,33 @@ def get_context_data(self, **kwargs): groups.append(result_group) context['groups'] = groups return context + + +method_decorator(login_required, name='dispatch') +class AssociationYearListView(ListView): + model = models.AssociationYear + + +@method_decorator(login_required, name='dispatch') +class AssociationYearDetailView(DetailView): + model = models.AssociationYear + + # This dance is done to order the memberships in each group by title + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + groups = [] + for group in context['object'].groups.all(): + activities = group.activities.order_by("-title") + + if not activities.exists(): + continue + result_group = dict() + result_group['group'] = group + result_group['activities'] = activities + groups.append(result_group) + context['groups'] = groups + return context + @login_required def index_view(request):