Commit 1b63d585 authored by Lo-J's avatar Lo-J
Browse files

Addition of the user's club tab

parent 0acc97fa
{% extends "core/base.jinja" %}
{% block title %}
{% trans user_name=profile.get_display_name() %}{{ user_name }}'s club(s){% endtrans %}
{% endblock %}
{% block content %}
<h3>{% trans%}Club(s){% endtrans %}</h3>
<h4>{% trans%}Current club(s){% endtrans %}</h4>
<ul>
{% for m in profile.memberships.filter(end_date=None).all() %}
<li><a href="{{ url('club:club_members', club_id=m.club.id) }}">{{ m.club }}</a></li>
{% endfor %}
</ul>
<h4>{% trans%}Old club(s){% endtrans %}</h4>
<ul>
{% for m in profile.memberships.exclude(end_date=None).all() %}
<li><a href="{{ url('club:club_members', club_id=m.club.id) }}">{{ m.club }}</a></li>
{% endfor %}
</ul>
{% endblock %}
......@@ -36,6 +36,7 @@ urlpatterns = [
url(r'^user/(?P<user_id>[0-9]+)/godfathers/(?P<godfather_id>[0-9]+)/(?P<is_father>(True)|(False))/delete$', DeleteUserGodfathers, name='user_godfathers_delete'),
url(r'^user/(?P<user_id>[0-9]+)/edit$', UserUpdateProfileView.as_view(), name='user_edit'),
url(r'^user/(?P<user_id>[0-9]+)/profile_upload$', UserUploadProfilePictView.as_view(), name='user_profile_upload'),
url(r'^user/(?P<user_id>[0-9]+)/clubs$', UserClubView.as_view(), name='user_clubs'),
url(r'^user/(?P<user_id>[0-9]+)/groups$', UserUpdateGroupView.as_view(), name='user_groups'),
url(r'^user/tools/$', UserToolsView.as_view(), name='user_tools'),
url(r'^user/(?P<user_id>[0-9]+)/account$', UserAccountView.as_view(), name='user_account'),
......
......@@ -20,6 +20,7 @@ import logging
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, LoginForm, UserGodfathersForm
from core.models import User, SithFile
from club.models import Club
from subscription.models import Subscription
def login(request):
......@@ -150,6 +151,12 @@ class UserTabsMixin(TabedViewMixin):
'slug': 'edit',
'name': _("Edit"),
})
if self.request.user.can_view(self.object):
tab_list.append({
'url': reverse('core:user_clubs', kwargs={'user_id': self.object.id}),
'slug': 'clubs',
'name': _("Clubs"),
})
if self.request.user.is_owner(self.object):
tab_list.append({
'url': reverse('core:user_groups', kwargs={'user_id': self.object.id}),
......@@ -336,6 +343,16 @@ class UserUpdateProfileView(UserTabsMixin, CanEditMixin, UpdateView):
kwargs['form'] = self.form
return kwargs
class UserClubView(UserTabsMixin, CanViewMixin, DetailView):
"""
Display the user's club(s)
"""
model = User
context_object_name = "profile"
pk_url_kwarg = "user_id"
template_name = "core/user_clubs.jinja"
current_tab = "clubs"
class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
"""
Edit a user's groups
......
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