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

Add frontend pages for societies

parent 01008791
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-09-01 20:29+0200\n"
"PO-Revision-Date: 2018-09-01 20:30+0200\n"
"POT-Creation-Date: 2018-09-06 16:13+0200\n"
"PO-Revision-Date: 2018-09-06 16:12+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -158,7 +158,8 @@ msgstr "commissies"
msgid "society"
msgstr "gezelschap"
#: models.py
#: models.py templates/activemembers/society_detail.html
#: templates/activemembers/society_index.html
msgid "societies"
msgstr "gezelschappen"
......@@ -270,6 +271,7 @@ msgstr "Bestuursleden"
#: templates/activemembers/board_detail.html
#: templates/activemembers/committee_detail.html
#: templates/activemembers/society_detail.html
msgid "Chair"
msgstr "Voorzitter"
......@@ -300,6 +302,7 @@ msgstr "Oude besturen"
#: templates/activemembers/board_index.html
#: templates/activemembers/committee_detail.html
#: templates/activemembers/society_detail.html
#, python-format
msgid "Photo of %(name)s"
msgstr "Foto van %(name)s"
......@@ -314,6 +317,7 @@ msgid "Committees"
msgstr "Commissies"
#: templates/activemembers/committee_detail.html
#: templates/activemembers/society_detail.html
#, python-format
msgid "About the %(name)s"
msgstr "Over de %(name)s"
......@@ -339,23 +343,23 @@ msgstr "Deze commissie heeft geen leden?"
msgid "There are no committees!"
msgstr "Er zijn geen commissies!"
#~ msgid "Only board memberships"
#~ msgstr "Alleen bestuurslidmaatschappen"
#~ msgid "No board memberships"
#~ msgstr "Geen bestuurslidmaatschappen"
#: templates/activemembers/society_detail.html
msgid "Society members"
msgstr "Leden van het gezelschap"
#~ msgid "Committee member since"
#~ msgstr "Commissielid sinds"
#: templates/activemembers/society_detail.html
msgid "Society member since: ?"
msgstr "Lid van het gezelschap sinds: ?"
#~ msgid "Committee member until"
#~ msgstr "Commissielid tot"
#~ msgid "Is this a board"
#~ msgstr "Is dit een bestuur"
#: templates/activemembers/society_detail.html
#, python-format
msgid "Society member since: %(since)s"
msgstr "Lid van het gezelschap sinds: %(since)s"
#~ msgid "committee membership"
#~ msgstr "commissielidmaatschap"
#: templates/activemembers/society_detail.html
msgid "This society doesn't have any members?"
msgstr "Dit gezelschap heeft geen leden?"
#~ msgid "committee memberships"
#~ msgstr "commissielidmaatschappen"
#: templates/activemembers/society_index.html
msgid "There are no societies!"
msgstr "Er zijn geen gezelschappen!"
......@@ -27,7 +27,7 @@
</div>
<div class="clearfix member-directory">
<h1 class="midhead">{% trans 'Committee members' %}</h1>
<ul class="row" id="commissieleden">
<ul class="row" id="members">
{% for member in members %}
<li class="post member-item span3 has-overlay">
<a href="{{ member.get_absolute_url }}">
......@@ -50,10 +50,10 @@
<div class="post-overlay-meta">
<h2>{{ member.profile.display_name }}</h2>
<p>
{% if member.committee_since.year == 1970 %}
{% if member.member_since.year == 1970 %}
{% blocktrans %}Committee member since: ?{% endblocktrans %}
{% else %}
{% blocktrans with since=member.committee_since|date:"Y" %}Committee member since: {{ since }}{% endblocktrans %}
{% blocktrans with since=member.member_since|date:"Y" %}Committee member since: {{ since }}{% endblocktrans %}
{% endif %}
</p>
{% if member.role %}
......
{% extends "base.html" %}
{% load i18n static thumbnail bleach_tags %}
{% block title %}{{ society.name }} — {% trans 'societies'|capfirst %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{{ society.name }} — {% trans 'societies'|capfirst %} — {{ block.super }}{% endblock %}
{% block body %}
<h1>{{ society.name }}
<span class="title-meta clearfix">
<span>
<a class="back" href="{% url 'activemembers:societies' %}" id="collectionButton"></a>
</span>
</span>
</h1>
<div class="portfolio"></div>
<div class="clearfix portfolio">
<div id="society-div">
<div class="row">
{% if society.photo %}
<img alt="{% blocktrans with name=society.name %}Photo of {{ name }}{% endblocktrans %}" class="span12" src="{% thumbnail society.photo '1024x683' fit=False %}">
{% else %}
<img alt="{% blocktrans with name=society.name %}Photo of {{ name }}{% endblocktrans %}" class="span12" src="{% static 'activemembers/images/placeholder.png' %}">
{% endif %}
</div>
<div class="text-center">
<h1 class="midhead">{% blocktrans with name=society.name %}About the {{ name }}{% endblocktrans %}</h1>
{{ society.description|bleach }}
</div>
<div class="clearfix member-directory">
<h1 class="midhead">{% trans 'Society members' %}</h1>
<ul class="row" id="members">
{% for member in members %}
<li class="post member-item span3 has-overlay">
<a href="{{ member.get_absolute_url }}">
<div class="post-inner">
<div class="inner-img">
{% if not member.profile.photo %}
<img alt="{{ member.profile.display_name }}" src="{% static 'members/images/default-avatar.jpg' %}" height="220" width="220" />
{% else %}
<img alt="{{ member.profile.display_name }}" src="{% thumbnail member.profile.photo '220x220' %}" width="220" height="220" />
{% endif %}
</div>
{% if member.chair %}
<div class="ribbon-wrapper-basiskleur">
<div class="ribbon-basiskleur">
{% trans "Chair" %}
</div>
</div>
{% endif %}
<div class="post-overlay">
<div class="post-overlay-meta">
<h2>{{ member.profile.display_name }}</h2>
<p>
{% if member.member_since.year == 1970 %}
{% blocktrans %}Society member since: ?{% endblocktrans %}
{% else %}
{% blocktrans with since=member.member_since|date:"Y" %}Society member since: {{ since }}{% endblocktrans %}
{% endif %}
</p>
{% if member.role %}
<p>{{ member.role }}</p>
{% endif %}
</div>
</div>
<div class="post-body avatar-subtitle">
{{ member.profile.display_name }}
</div>
</div>
</a>
</li>
{% empty %}
<li>{% trans "This society doesn't have any members?" %}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endblock %}
{% extends "base.html" %}
{% load i18n thumbnail static %}
{% block title %}{% trans 'societies'|capfirst %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{% trans 'societies'|capfirst %} — {{ block.super }}{% endblock %}
{% block body %}
<h1>{% trans 'societies'|capfirst %}</h1>
<div class="clearfix portfolio">
<div id="societies">
<ul class="row societies">
{% for society in societies %}
<li class="post member-item span3 has-overlay">
<a href="{{ society.get_absolute_url }}">
<div class="post-inner">
<div class="inner-img">
{% if society.photo %}
<img src="{% thumbnail society.photo '220x220' fit=False %}" alt="Photo of {{ society.name }}">
{% else %}
<img height="220" width="220" src="{% static 'activemembers/images/placeholder.png' %}">
{% endif %}
</div>
<div class="post-overlay">
<div class="post-overlay-meta">
<h2>{{ society.name }}</h2>
</div>
</div>
<div class="post-body avatar-subtitle">
{{ society.name }}
</div>
</div>
</a>
</li>
{% empty %}
{% trans 'There are no societies!' %}
{% endfor %}
</ul>
</div>
</div>
{% endblock %}
......@@ -9,6 +9,8 @@ app_name = "activemembers"
urlpatterns = [
url(r'committees/$', views.committee_index, name='committees'),
url(r'^committees/(?P<pk>\d+)/$', views.committee_detail, name='committee'),
url(r'societies/$', views.society_index, name='societies'),
url(r'^societies/(?P<pk>\d+)/$', views.society_detail, name='society'),
url(r'^boards/$', views.board_index, name='boards'),
url(r'^board/(?P<since>\d{4})$', views.board_detail, name='board'),
url(r'^board/(?P<since>\d{4})-(?P<until>\d{4})$', views.board_detail, name='board'),
......
......@@ -2,7 +2,8 @@ from django.shortcuts import get_object_or_404, render, redirect, reverse
import datetime
from utils.snippets import datetime_to_lectureyear
from utils.translation import localize_attr_name
from .models import Board, MemberGroup, MemberGroupMembership, Committee
from .models import Board, MemberGroup, MemberGroupMembership, Committee, \
Society
def committee_index(request):
......@@ -29,19 +30,18 @@ def committee_detail(request, pk):
"""
committee = get_object_or_404(Committee, pk=pk)
members = []
memberships = (MemberGroupMembership
.active_objects
.filter(group=committee)
.prefetch_related('member__membergroupmembership_set'))
for membership in memberships:
member = membership.member
member.chair = membership.chair
member.role = membership.role
member.committee_since = membership.initial_connected_membership.since
members.append(member) # list comprehension would be more pythonic?
members = [{
'profile': x.member.profile,
'chair': x.chair,
'role': x.role,
'member_since': x.initial_connected_membership.since
} for x in memberships]
members.sort(key=lambda x: x.committee_since)
members.sort(key=lambda x: x['member_since'])
return render(request, 'activemembers/committee_detail.html',
{'committee': committee,
......@@ -95,3 +95,45 @@ def board_detail(request, since, until=None):
return render(request, 'activemembers/board_detail.html',
{'board': board,
'members': members})
def society_index(request):
"""
View that renders the committee overview page
:param request: the request object
:return: response containing the HTML
"""
societies = Society.active_objects.all().order_by(
localize_attr_name('name'))
return render(request, 'activemembers/society_index.html',
{'societies': societies})
def society_detail(request, pk):
"""
View that renders the page of one selected committee
:param request: the request object
:param pk: pk of the selected committee
:return:
"""
society = get_object_or_404(Society, pk=pk)
memberships = (MemberGroupMembership
.active_objects
.filter(group=society)
.prefetch_related('member__membergroupmembership_set'))
members = [{
'profile': x.member.profile,
'chair': x.chair,
'role': x.role,
'member_since': x.initial_connected_membership.since
} for x in memberships]
members.sort(key=lambda x: x['member_since'])
return render(request, 'activemembers/committee_detail.html',
{'committee': society,
'members': members})
......@@ -21,6 +21,7 @@ MAIN_MENU = [
'submenu': [
{'title': _('Board'), 'name': 'activemembers:boards'},
{'title': _('Committees'), 'name': 'activemembers:committees'},
{'title': _('Societies'), 'name': 'activemembers:societies'},
{'title': _('Documents'), 'name': 'documents:index'},
{'title': _('Merchandise'), 'name': 'merchandise:index'},
{'title': _('Sister Associations'), 'name': 'sister-associations'},
......
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