Commit a5aa0d0e authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'feature/member-profile-frontend' into 'master'

Member profile frontend

Closes #76

See merge request !73
parents 32344d70 1974a3a7
from __future__ import unicode_literals
from django.forms import ModelForm
from .models import Member
class MemberForm(ModelForm):
class Meta:
fields = ['address_street', 'address_street2',
'address_postal_code', 'address_city', 'phone_number',
'emergency_contact', 'emergency_contact_phone_number',
'show_birthday', 'website',
'profile_description', 'nickname',
'display_name_preference', 'photo', 'language',
'receive_optin', 'receive_newsletter']
model = Member
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-28 22:03+0200\n"
"PO-Revision-Date: 2016-08-28 22:05+0200\n"
"POT-Creation-Date: 2016-09-16 21:37+0200\n"
"PO-Revision-Date: 2016-09-16 21:38+0200\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -18,10 +18,26 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.8\n"
#: admin.py:24
#: admin.py:26
msgid "membership type"
msgstr "lidtype"
#: admin.py:49
msgid "Age"
msgstr "Leeftijd"
#: admin.py:54
msgid "≥ 18"
msgstr "≥ 18"
#: admin.py:55
msgid "< 18"
msgstr "< 18"
#: admin.py:56
msgid "Unknown"
msgstr "Onbekend"
#: models.py:54
msgid "Computing Science"
msgstr "Informatica"
......@@ -175,7 +191,15 @@ msgstr "Ontvang opt-in mailings"
msgid "Receive mailings about vacancies and events from Thalia's sponsors."
msgstr "Ontvang mailings over vacatures en evenmenten van Thalia's sponsoren"
#: models.py:266
#: models.py:264
msgid "Receive newsletter"
msgstr "Ontvang nieuwsbrief"
#: models.py:265
msgid "Receive the Thalia Newsletter"
msgstr "Ontvang de Thalia nieuwsbrief"
#: models.py:272
msgid ""
"Yes, I want Thalia to take the membership fees from my bank account through "
"direct debit for each year."
......@@ -183,71 +207,122 @@ msgstr ""
"Ja, ik wil dat Thalia verschuldigde lidmaatschapsgelden elk jaar van mijn "
"bankrekening afschrijft."
#: models.py:269
#: models.py:275
msgid "No, I will pay the contribution myself"
msgstr "Nee, ik zal de contributie zelf betalen"
#: models.py:270
#: models.py:276
msgid "Direct debit"
msgstr "Automatische afschijving"
#: models.py:271
#: models.py:277
msgid "Each year, have Thalia take the membership fees from my bank account"
msgstr ""
"Laat Thalia elk jaar het lidmaatschapsgeld van mijn bankrekening afschrijven"
#: models.py:277
#: models.py:283
msgid "Bank account"
msgstr "Bankrekening"
#: models.py:278
#: models.py:284
msgid "Bank account for direct debit"
msgstr "Bankrekening voor automatische afschrijving"
#: models.py:298
#: models.py:304
msgid "Display name"
msgstr "Weergavenaam"
#: models.py:323
#: models.py:329
msgid "Member"
msgstr "Lid"
#: models.py:324
#: models.py:330
msgid "Supporter"
msgstr "Begunstiger"
#: models.py:325
#: models.py:331
msgid "Honorary Member"
msgstr "Erelid"
#: models.py:330
#: models.py:336
msgid "Membership type"
msgstr "Lidtype"
#: models.py:339
#: models.py:345
msgid "User"
msgstr "Gebruiker"
#: models.py:343
#: models.py:349
msgid "Membership since"
msgstr "Lid sinds"
#: models.py:344
#: models.py:350
msgid "The date the member started holding this membership."
msgstr "De datum waarop het lid dit lidmaatschap is begonnen."
#: models.py:349
#: models.py:355
msgid "Membership until"
msgstr "Lid tot"
#: models.py:350
#: models.py:356
msgid "The date the member stops holding this membership."
msgstr "De datum waarop het lid dit lidmaatschap beëindigd."
#: templates/members/account.html:6 templates/members/edit_profile.html:5
#: templates/members/index.html:6 templates/members/index.html:9
#: templates/members/profile.html:6
msgid "Members"
msgstr "Leden"
msgid "members"
msgstr "leden"
#: templates/members/account.html:9
msgid "Account"
msgstr "Bankrekening"
#: templates/members/account.html:14
#, python-format
msgid "You’re currently logged in as <strong>%(user)s</strong>"
msgstr "U bent momenteel ingelogd als <strong>%(user)s</strong>"
#: templates/members/account.html:19
msgid "show public profile"
msgstr "bekijk publieke profielpagina"
#: templates/members/account.html:20
msgid "Take a look at your own profile."
msgstr "Bekijk je eigen profielpagina."
#: templates/members/account.html:26 templates/members/edit_profile.html:5
#: templates/members/edit_profile.html:8
msgid "edit profile"
msgstr "profiel bewerken"
#: templates/members/account.html:27
msgid "Edit your profile and avatar."
msgstr "Bewerk je profiel en profielafbeelding."
#: templates/members/account.html:33
msgid "change password"
msgstr "wachtwoord wijzigen"
#: templates/members/account.html:34
msgid "Change your accounts' password."
msgstr "Wijzig het wachtwoord van je account."
#: templates/members/account.html:40
msgid "logout"
msgstr "uitloggen"
#: templates/members/account.html:41
msgid "Leave the restricted area of the website."
msgstr "Verlaat het beveiligde gedeelte van de website."
#: templates/members/edit_profile.html:12
msgid "Your profile has been updated successfully."
msgstr "Je profiel is succesvol opgeslagen."
#: templates/members/edit_profile.html:38
msgid "save"
msgstr "opslaan"
#: templates/members/index.html:12
msgid ""
......@@ -299,8 +374,8 @@ msgid "Next"
msgstr "Volgende"
#: templates/members/profile.html:6
msgid "Profile"
msgstr "Profiel"
msgid "profile"
msgstr "profiel"
#: templates/members/profile.html:25
msgid "About"
......
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% block title %}{% trans "members"|capfirst %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>{% trans 'Account' %}</h1>
<div class="row">
<div class="span6 offset3">
<p class="text-center">{% blocktrans with user=request.user.username %}You’re currently logged in as <strong>{{ user }}</strong>{% endblocktrans %}.</p>
<hr>
<div>
<a href="{% url 'members:profile' %}">{% trans "show public profile"|capfirst %}</a>
<p>{% blocktrans %}Take a look at your own profile.{% endblocktrans %}</p>
</div>
<hr>
<div>
<a href="{% url 'members:edit-profile' %}">{% trans "edit profile"|capfirst %}</a>
<p>{% blocktrans %}Edit your profile and avatar.{% endblocktrans %}</p>
</div>
<hr>
<div>
<a href="{% url 'password_change' %}">{% trans "change password"|capfirst %}</a>
<p>{% blocktrans %}Change your accounts' password.{% endblocktrans %}</p>
</div>
<hr>
<div>
<a href="{% url 'logout' %}">{% trans "logout"|capfirst %}</a>
<p>{% blocktrans %}Leave the restricted area of the website.{% endblocktrans %}</p>
</div>
</div>
</div>
{% endblock %}}
\ No newline at end of file
{% extends "base.html" %}
{% load static i18n fieldtype %}
{% block title %}{% trans "edit profile"|capfirst %} - {% trans "members"|capfirst %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>{% trans "edit profile"|capfirst %}</h1>
{% if saved %}
<div class="alert alert-success">
{% trans "Your profile has been updated successfully." %}
<button class="close" type="button"><span class="alert-icon-close"></span></button>
</div>
{% endif %}
<form method="post" class="form-horizontal span8 offset2">
{% csrf_token %}
{% for field in form %}
<div class="control-group row {% if field.errors %}error{% endif %}">
<label class="control-label" for="{{ field.name }}">{{ field.label_tag }}</label>
<div class="controls">
{{ field }}
{% for error in field.errors %}
<span class="help-block">{{ error|escape }}</span>
{% endfor %}
{% if field.help_text and field|fieldtype != 'CheckboxInput' %}
<span class="help-block">{{ field.help_text|safe }}</span>
{% endif %}
</div>
</div>
{% endfor %}
<input type="submit" value="{% trans 'save'|capfirst %}" class="btn btn-style1 pull-right login" />
</form>
{% endblock %}
\ No newline at end of file
......@@ -3,10 +3,10 @@
{% load static %}
{% load i18n %}
{% block title %}{% trans "Members" %} - {{ block.super }}{% endblock %}
{% block title %}{% trans "members"|capfirst %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>{% trans "Members" %}</h1>
<h1>{% trans "members"|capfirst %}</h1>
<p class="text-center">
{% blocktrans trimmed %}
......
......@@ -3,7 +3,7 @@
{% load static %}
{% load i18n %}
{% block title %}{% trans "Profile" %} - {% trans "Members" %} - {{ block.super }}{% endblock %}
{% block title %}{% trans "profile"|capfirst %} - {% trans "members"|capfirst %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>
......
from django import template
register = template.Library()
@register.filter(name='fieldtype')
def fieldtype(field):
return field.field.widget.__class__.__name__
......@@ -6,5 +6,8 @@ from . import views
urlpatterns = [
url('^become-a-member-document/(?P<pk>[0-9]*)', views.get_become_a_member_document, name='become-a-member-document'),
url('^profile/(?P<pk>[0-9]*)$', views.profile, name='profile'),
url('^profile$', views.profile, name='profile'),
url('^profile/edit/$', views.edit_profile, name='edit-profile'),
url('^account$', views.account, name='account'),
url('^$', views.index, name='index'),
]
......@@ -3,11 +3,13 @@ from datetime import date
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import get_object_or_404, render
from django.contrib.auth.decorators import login_required
from django.utils.text import slugify
from sendfile import sendfile
from .models import BecomeAMemberDocument
from .models import Member
from .forms import MemberForm
def index(request):
......@@ -85,8 +87,12 @@ def index(request):
'keywords': keywords})
def profile(request, pk):
member = get_object_or_404(Member, pk=int(pk))
@login_required
def profile(request, pk=None):
if pk:
member = get_object_or_404(Member, pk=int(pk))
else:
member = get_object_or_404(Member, user=request.user)
# Group the memberships under the committees for easier template rendering
memberships = member.committeemembership_set.all()
......@@ -110,7 +116,7 @@ def profile(request, pk):
}
achievements[name]['periods'].sort(key=lambda period: period['since'])
mentor_years = member.mentor_set.all()
mentor_years = member.mentorship_set.all()
for mentor_year in mentor_years:
name = str(mentor_year)
if not achievements.get(name):
......@@ -122,6 +128,28 @@ def profile(request, pk):
{'member': member, 'achievements': achievements.values()})
@login_required
def account(request):
return render(request, 'members/account.html')
@login_required
def edit_profile(request):
member = get_object_or_404(Member, user=request.user)
saved = False
if request.POST:
form = MemberForm(request.POST, instance=member)
if form.is_valid():
saved = True
member = form.save()
form = MemberForm(instance=member)
return render(request, 'members/edit_profile.html',
{'form': form, 'saved': saved})
def become_a_member(request):
context = {'documents': BecomeAMemberDocument.objects.all()}
return render(request, 'singlepages/become_a_member.html', context)
......
......@@ -105,6 +105,12 @@ DATABASES = {
}
}
# Login pages
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
# Password validation
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
......
......@@ -69,13 +69,13 @@
</div>
{% else %}
<div class="btn-group" id="account-menu">
<a class="btn btn-default" href="/nyi"><i class="fa fa-user"></i> My Account</a>
<a class="btn btn-default" href="{% url 'members:account' %}"><i class="fa fa-user"></i> {% trans "My Account" %}</a>
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right" role="menu">
<li><a href="/nyi">{% trans "Edit Profile" %}</a></li>
<li><a href="/nyi">{% trans "Profile Picture" %}</a></li>
<li><a href="{% url 'members:edit-profile' %}">{% trans "edit profile"|capfirst %}</a></li>
<li><a href="{% url 'password_change' %}">{% trans "change password"|capfirst %}</a></li>
<li class="divider"></li>
<li><a href="{% url 'logout' %}"><i class="fa fa-sign-out"></i>{% trans "Log Out" %}</a></li>
</ul>
......
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