Skip to content

Commit

Permalink
Add views for Verksamhetsår
Browse files Browse the repository at this point in the history
Wortk in progress. This commit will be rewritten!

Part of #57
  • Loading branch information
jonatanskogsfors committed Sep 9, 2024
1 parent 8b9e0e6 commit c1af6d5
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions batadasen/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h5>Spextjänster</h5>
<h5>Internsidor</h5>
<a class="nav-link" href="{% url 'batadasen:person_settings' %}">Inställningar</a>
<a class="nav-link" href="{% url 'batadasen:production_list' %}">Uppsättningar</a>
<a class="nav-link" href="{% url 'batadasen:associationyear_list' %}">Verksamhetsår</a>
<a class="nav-link" href="{% url 'batadasen:emaillist_list' %}">Epostlistor</a>
<a class="nav-link" href="{% url 'assetmanager:asset_list' %}">Inventarier</a>
<a class="nav-link" href="{% url 'showcounter:overview' %}">Föreställningsräknare</a>
Expand Down
21 changes: 21 additions & 0 deletions batadasen/templates/batadasen/associationyear_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends 'base.html' %}
{% load i18n %}

{% block title %}Verksamhetsår {{ object }}{% endblock %}

{% block content %}
<h2>Verksamhetsår {{ object }}</h2>
<table class="table table-sm table-striped">
{% for group in groups %}
<tr class="table-primary"> <th colspan="4">{{ group.group.group_type.name }} ({{ group.group.group_type.short_name }})</th></tr>
{% for activity in group.activities %}
<tr>
<td><a href="{% url 'batadasen:person_detail' activity.person.member_number %}">{{ activity.person.member_number }}</a></td>
<td>{{ activity.person.first_name }} {% if activity.person.spex_name %}"{{ activity.person.spex_name }}" {% endif %}{{ activity.person.last_name }}</td>
<td>{% if activity.title %}{{ activity.title }}{% endif %}</td>
<td>{% if activity.comment %}{{ activity.comment }}{% endif %}</td>
</tr>
{% endfor %}
{% endfor %}
</table>
{% endblock %}
18 changes: 18 additions & 0 deletions batadasen/templates/batadasen/associationyear_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends 'base.html' %}
{% load i18n %}

{% block title %}Verksamhetsår{% endblock %}

{% block content %}
<h2>Verksamhetsår</h2>
<table class="table table-sm">
<tr>
<th>År</th>
</tr>
{% for year in object_list %}
<tr>
<td><a href="{% url 'batadasen:associationyear_detail' year.end_year %}"></ahref>{{ year }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
2 changes: 2 additions & 0 deletions batadasen/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
path('persons/<int:pk>/', views.PersonDetailView.as_view(), name='person_detail'),
path('productions/', views.ProductionListView.as_view(), name='production_list'),
path('productions/<int:pk>/', views.ProductionDetailView.as_view(), name='production_detail'),
path('association/', views.AssociationYearListView.as_view(), name='associationyear_list'),
path('association/<int:pk>/', 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'),
Expand Down
27 changes: 27 additions & 0 deletions batadasen/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c1af6d5

Please sign in to comment.