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

Add account overview page, add view for editing profile and fix user' profile pages

parent 9c521e52
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% block title %}{% trans "Members" %} - {{ block.super }}{% endblock %}
{% block body %}
<h1>{% trans 'Account' %}</h1>
<div class="row">
<div class="span6 offset3">
<p class="text-center">U bent momenteel ingelogd als <strong>{{ request.user.username }}</strong>.</p>
<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 authenticated area of the website.{% endblocktrans %}</p>
</div>
</div>
</div>
{% endblock %}}
\ No newline at end of file
...@@ -6,5 +6,8 @@ from . import views ...@@ -6,5 +6,8 @@ from . import views
urlpatterns = [ urlpatterns = [
url('^become-a-member-document/(?P<pk>[0-9]*)', views.get_become_a_member_document, name='become-a-member-document'), 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/(?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'), url('^$', views.index, name='index'),
] ]
...@@ -3,6 +3,7 @@ from datetime import date ...@@ -3,6 +3,7 @@ from datetime import date
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import get_object_or_404, render from django.shortcuts import get_object_or_404, render
from django.contrib.auth.decorators import login_required
from django.utils.text import slugify from django.utils.text import slugify
from sendfile import sendfile from sendfile import sendfile
...@@ -85,8 +86,11 @@ def index(request): ...@@ -85,8 +86,11 @@ def index(request):
'keywords': keywords}) 'keywords': keywords})
def profile(request, pk): def profile(request, pk=None):
member = get_object_or_404(Member, pk=int(pk)) if pk:
member = get_object_or_404(Member, pk=int(pk))
elif request.user.is_authenticated():
member = get_object_or_404(Member, user=request.user)
# Group the memberships under the committees for easier template rendering # Group the memberships under the committees for easier template rendering
memberships = member.committeemembership_set.all() memberships = member.committeemembership_set.all()
...@@ -110,7 +114,7 @@ def profile(request, pk): ...@@ -110,7 +114,7 @@ def profile(request, pk):
} }
achievements[name]['periods'].sort(key=lambda period: period['since']) 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: for mentor_year in mentor_years:
name = str(mentor_year) name = str(mentor_year)
if not achievements.get(name): if not achievements.get(name):
...@@ -121,6 +125,14 @@ def profile(request, pk): ...@@ -121,6 +125,14 @@ def profile(request, pk):
return render(request, 'members/profile.html', return render(request, 'members/profile.html',
{'member': member, 'achievements': achievements.values()}) {'member': member, 'achievements': achievements.values()})
@login_required
def account(request):
return render(request, 'members/account.html')
@login_required
def edit_profile(request):
return render(request, 'members/account.html')
def become_a_member(request): def become_a_member(request):
context = {'documents': BecomeAMemberDocument.objects.all()} context = {'documents': BecomeAMemberDocument.objects.all()}
......
...@@ -105,6 +105,12 @@ DATABASES = { ...@@ -105,6 +105,12 @@ DATABASES = {
} }
} }
# Login pages
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
# Password validation # Password validation
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
......
...@@ -69,13 +69,13 @@ ...@@ -69,13 +69,13 @@
</div> </div>
{% else %} {% else %}
<div class="btn-group" id="account-menu"> <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"> <button class="btn btn-default dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu pull-right" role="menu"> <ul class="dropdown-menu pull-right" role="menu">
<li><a href="/nyi">{% trans "Edit Profile" %}</a></li> <li><a href="{% url 'members:edit-profile' %}">{% trans "edit profile"|capfirst %}</a></li>
<li><a href="/nyi">{% trans "Profile Picture" %}</a></li> <li><a href="{% url 'password_change' %}">{% trans "change password"|capfirst %}</a></li>
<li class="divider"></li> <li class="divider"></li>
<li><a href="{% url 'logout' %}"><i class="fa fa-sign-out"></i>{% trans "Log Out" %}</a></li> <li><a href="{% url 'logout' %}"><i class="fa fa-sign-out"></i>{% trans "Log Out" %}</a></li>
</ul> </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