mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-23 00:01:16 +00:00
Addition of the user's club tab
This commit is contained in:
parent
0acc97fa90
commit
1b63d58586
24
core/templates/core/user_clubs.jinja
Normal file
24
core/templates/core/user_clubs.jinja
Normal file
@ -0,0 +1,24 @@
|
||||
{% 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
|
||||
|
Loading…
Reference in New Issue
Block a user