We planned to upgrade GitLab and Mattermost to the latest version this Friday morning. Expect some downtime!

Commit 061346c6 authored by Thijs de Jong's avatar Thijs de Jong Committed by Thijs de Jong

Added Societies Header on Profile

parent d24295de
This diff was suppressed by a .gitattributes entry.
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-12 19:36+0100\n"
"PO-Revision-Date: 2018-11-12 19:37+0100\n"
"POT-Creation-Date: 2018-11-14 19:57+0100\n"
"PO-Revision-Date: 2018-11-14 19:58+0100\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -50,6 +50,14 @@ msgstr "Voornaam"
msgid "Last name"
msgstr "Achternaam"
#: admin.py
msgid "Email"
msgstr "E-mail"
#: admin.py
msgid "Download email addresses for selected users"
msgstr "Download e-mailadressen voor geselecteerde gebruikers"
#: admin.py
msgid "Address"
msgstr "Adres"
......@@ -1003,6 +1011,10 @@ msgstr "Voorzitter"
msgid "today"
msgstr "heden"
#: templates/members/profile.html
msgid "Societies"
msgstr "Gezelschappen"
#: templates/members/statistics.html
msgid "Statistics"
msgstr "Statistieken"
......
......@@ -12,7 +12,10 @@ from utils.snippets import datetime_to_lectureyear
def member_achievements(member):
memberships = member.membergroupmembership_set.all()
achievements = {}
for membership in memberships:
if hasattr(membership.group, 'society'):
continue
period = {
'since': membership.since,
'until': membership.until,
......@@ -28,6 +31,7 @@ def member_achievements(member):
name = membership.group.name
if achievements.get(name):
achievements[name]['periods'].append(period)
if achievements[name]['earliest'] > membership.since:
achievements[name]['earliest'] = membership.since
......@@ -38,6 +42,7 @@ def member_achievements(member):
'periods': [period],
'earliest': membership.since,
}
mentor_years = member.mentorship_set.all()
for mentor_year in mentor_years:
name = "Mentor in {}".format(mentor_year.year)
......@@ -52,6 +57,35 @@ def member_achievements(member):
return sorted(achievements.values(), key=lambda x: x['earliest'])
def member_societies(member):
memberships = member.membergroupmembership_set.all()
societies = {}
for membership in memberships:
period = {
'since': membership.since,
'until': membership.until,
'chair': membership.chair
}
if hasattr(membership.group, 'society'):
name = membership.group.name
if societies.get(name):
societies[name]['periods'].append(period)
if societies[name]['earliest'] > membership.since:
societies[name]['earliest'] = membership.since
societies[name]['periods'].sort(key=lambda x: x['since'])
else:
societies[name] = {
'name': name,
'periods': [period],
'earliest': membership.since,
}
return sorted(societies.values(), key=lambda x: x['earliest'])
def gen_stats_member_type(member_types):
total = dict()
for member_type in member_types:
......
......@@ -87,6 +87,31 @@
{% endfor %}
</ul>
{% endif %}
{% if societies %}
<hr class="separator">
<h4>{% trans "Societies" %}</h4>
<ul class="list-unstyled">
{% for society in societies %}
<li class="mb-1">
<strong>{{ society.name }}</strong>
<br>
{% for period in society.periods %}
{% if period.role %}
<span>{{ period.role }}: </span>
{% elif period.chair %}
<span>{% trans "Chair" %}: </span>
{% endif %}
<i>{% if period.since|date:'Y m d' == '1970 01 01' %}?{% else %}
{{ period.since }}{% endif %} -
{% if period.until %}{{ period.until }}{% else %}
{% trans "today" %}{% endif %}</i>
<br>
{% endfor %}
</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
</div>
......
......@@ -21,6 +21,7 @@ from members.models import EmailChange, Membership
from . import models
from .forms import ProfileForm, EmailChangeForm
from .services import member_achievements
from .services import member_societies
class ObtainThaliaAuthToken(ObtainAuthToken):
......@@ -147,6 +148,7 @@ def profile(request, pk=None):
# Group the memberships under the committees for easier template rendering
achievements = member_achievements(member)
societies = member_societies(member)
membership = member.current_membership
membership_type = _("Unknown membership history")
......@@ -162,6 +164,7 @@ def profile(request, pk=None):
return render(request, 'members/profile.html',
{
'achievements': achievements,
'societies': societies,
'member': member,
'membership_type': membership_type,
})
......
Markdown is supported
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