Commit f1413c04 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Show committeememberships on user profile

parent 7483777a
......@@ -51,20 +51,25 @@
{% endif %}
</ul>
{% comment "This below is for achievements, there are examples for different types of achievements from the old site and an assumption on how it can work" %}
<hr class="separator">
<h4>{% trans "Achievements for Thalia" %}</h4>
<ul class="post-meta">
{% for achievement in member.achievements %}
{% for achievement in achievements %}
<li style="margin-bottom:10px;">
<span>{{ achievement.name }}</span>
<br>
<i>{{ achievement.from }} - {{ achievement.till }}</i>
{% for period in achievement.periods %}
{% if period.chair %}
<span style="text-transform:inherit;">Voorzitter: </span>
{% endif %}
<i>{{ period.since }} - {% if period.until %}{{ period.until }}{% else %}{% trans "today" %}{% endif %}</i>
<br>
{% endfor %}
</li>
{% endfor %}
{% comment "As example for future possible types of achievements" %}
<li style="margin-bottom:10px;">
<span>Huisstijlcommissie</span>
<br>
......@@ -86,8 +91,8 @@
<li style="margin-bottom:10px;">
<span>Mentor introductie 2016</span>
</li>
{% endcomment %}
</ul>
{% endcomment %}
</div>
</div>
<!-- /portfolio single content -->
......
from datetime import date
from django.db.models.query import QuerySet
from django.shortcuts import get_object_or_404, render
from django.utils.text import slugify
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from .models import Member
from .models import BecomeAMemberDocument
from committees.models import CommitteeMembership
import os
from sendfile import sendfile
......@@ -86,7 +89,30 @@ def index(request):
def profile(request, pk):
member = get_object_or_404(Member, pk=int(pk))
return render(request, 'members/profile.html', {'member': member})
# Group the memberships under the committees for easier template rendering
memberships = member.committeemembership_set.all()
achievements = {}
for membership in memberships:
name = membership.committee.name
if achievements.get(name):
achievements[name]['periods'].append({
'since': membership.since,
'until': membership.until,
'chair': membership.chair
})
else:
achievements[name] = {
'name': name,
'periods': [{
'since': membership.since,
'until': membership.until,
'chair': membership.chair
}]
}
achievements[name]['periods'].sort(key=lambda period: period['since'])
return render(request, 'members/profile.html',
{'member': member, 'achievements': achievements.values()})
def become_a_member(request):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment