Merge branch 'LoJ' into 'master'

Lo j : Addition of the user's club page

When a user check his profile, he can access a new tab "Clubs" to see his currents and olds Clubs

See merge request !14
This commit is contained in:
Skia 2016-10-07 13:36:35 +02:00
commit c66d61ee85
5 changed files with 147 additions and 40 deletions

View File

@ -0,0 +1,62 @@
{% 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>
<br>
<h4>{% trans%}Current club(s) :{% endtrans %}</h4>
<br>
<table>
<thead>
<tr>
<td>{% trans %}User{% endtrans %}</td>
<td>{% trans %}Role{% endtrans %}</td>
<td>{% trans %}Description{% endtrans %}</td>
<td>{% trans %}Since{% endtrans %}</td>
</tr>
</thead>
<tbody>
{% for m in profile.memberships.filter(end_date=None).all() %}
<tr>
<td><a href="{{ url('club:club_members', club_id=m.club.id) }}">{{ m.club }}</a></td>
<td>{{ settings.SITH_CLUB_ROLES[m.role] }}</td>
<td>{{ m.description }}</td>
<td>{{ m.start_date }}</td>
{% if m.can_be_edited_by(user) %}
<td><a href="{{ url('club:membership_set_old', membership_id=m.id) }}">{% trans %}Mark as old{% endtrans %}</a></td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
<br>
<h4>{% trans%}Old club(s) :{% endtrans %}</h4>
<br>
<table>
<thead>
<tr>
<td>{% trans %}User{% endtrans %}</td>
<td>{% trans %}Role{% endtrans %}</td>
<td>{% trans %}Description{% endtrans %}</td>
<td>{% trans %}From{% endtrans %}</td>
<td>{% trans %}To{% endtrans %}</td>
</tr>
</thead>
<tbody>
{% for m in profile.memberships.exclude(end_date=None).all() %}
<tr>
<td><a href="{{ url('club:club_members', club_id=m.club.id) }}">{{ m.club }}</a></td>
<td>{{ settings.SITH_CLUB_ROLES[m.role] }}</td>
<td>{{ m.description }}</td>
<td>{{ m.start_date }}</td>
<td>{{ m.end_date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -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]+)/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]+)/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]+)/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/(?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/tools/$', UserToolsView.as_view(), name='user_tools'),
url(r'^user/(?P<user_id>[0-9]+)/account$', UserAccountView.as_view(), name='user_account'), url(r'^user/(?P<user_id>[0-9]+)/account$', UserAccountView.as_view(), name='user_account'),

View File

@ -20,6 +20,7 @@ import logging
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, LoginForm, UserGodfathersForm from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, LoginForm, UserGodfathersForm
from core.models import User, SithFile from core.models import User, SithFile
from club.models import Club
from subscription.models import Subscription from subscription.models import Subscription
def login(request): def login(request):
@ -150,6 +151,12 @@ class UserTabsMixin(TabedViewMixin):
'slug': 'edit', 'slug': 'edit',
'name': _("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): if self.request.user.is_owner(self.object):
tab_list.append({ tab_list.append({
'url': reverse('core:user_groups', kwargs={'user_id': self.object.id}), 'url': reverse('core:user_groups', kwargs={'user_id': self.object.id}),
@ -336,6 +343,16 @@ class UserUpdateProfileView(UserTabsMixin, CanEditMixin, UpdateView):
kwargs['form'] = self.form kwargs['form'] = self.form
return kwargs 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): class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
""" """
Edit a user's groups Edit a user's groups

Binary file not shown.

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-05 11:46+0200\n" "POT-Creation-Date: 2016-10-07 13:10+0200\n"
"PO-Revision-Date: 2016-07-18\n" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n" "Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@ -169,6 +169,8 @@ msgstr "type de cible"
#: accounting/models.py:204 club/templates/club/club_members.jinja:8 #: accounting/models.py:204 club/templates/club/club_members.jinja:8
#: club/templates/club/club_old_members.jinja:8 #: club/templates/club/club_old_members.jinja:8
#: core/templates/core/user_clubs.jinja:15
#: core/templates/core/user_clubs.jinja:41
#: counter/templates/counter/cash_summary_list.jinja:27 #: counter/templates/counter/cash_summary_list.jinja:27
#: counter/templates/counter/stats.jinja:15 #: counter/templates/counter/stats.jinja:15
#: launderette/templates/launderette/launderette_admin.jinja:44 #: launderette/templates/launderette/launderette_admin.jinja:44
@ -180,7 +182,7 @@ msgstr "Utilisateur"
msgid "Club" msgid "Club"
msgstr "Club" msgstr "Club"
#: accounting/models.py:204 core/views/user.py:167 #: accounting/models.py:204 core/views/user.py:174
msgid "Account" msgid "Account"
msgstr "Compte" msgstr "Compte"
@ -314,7 +316,7 @@ msgid "Delete"
msgstr "Supprimer" msgstr "Supprimer"
#: accounting/templates/accounting/bank_account_details.jinja:17 #: accounting/templates/accounting/bank_account_details.jinja:17
#: club/views.py:31 core/views/user.py:129 #: club/views.py:31 core/views/user.py:130
msgid "Infos" msgid "Infos"
msgstr "Infos" msgstr "Infos"
@ -333,9 +335,9 @@ msgstr "Nouveau compte club"
#: accounting/templates/accounting/bank_account_details.jinja:26 #: accounting/templates/accounting/bank_account_details.jinja:26
#: accounting/templates/accounting/bank_account_list.jinja:21 #: accounting/templates/accounting/bank_account_list.jinja:21
#: accounting/templates/accounting/club_account_details.jinja:55 #: accounting/templates/accounting/club_account_details.jinja:55
#: accounting/templates/accounting/journal_details.jinja:66 club/views.py:53 #: accounting/templates/accounting/journal_details.jinja:70 club/views.py:53
#: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31 #: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31
#: core/templates/core/user_tools.jinja:35 core/views/user.py:151 #: core/templates/core/user_tools.jinja:35 core/views/user.py:152
#: counter/templates/counter/cash_summary_list.jinja:48 #: counter/templates/counter/cash_summary_list.jinja:48
#: counter/templates/counter/counter_list.jinja:17 #: counter/templates/counter/counter_list.jinja:17
#: counter/templates/counter/counter_list.jinja:32 #: counter/templates/counter/counter_list.jinja:32
@ -371,11 +373,13 @@ msgid "Club account:"
msgstr "Compte club : " msgstr "Compte club : "
#: accounting/templates/accounting/club_account_details.jinja:18 #: accounting/templates/accounting/club_account_details.jinja:18
#: accounting/templates/accounting/journal_details.jinja:16
#: accounting/templates/accounting/label_list.jinja:15 #: accounting/templates/accounting/label_list.jinja:15
msgid "New label" msgid "New label"
msgstr "Nouvelle étiquette" msgstr "Nouvelle étiquette"
#: accounting/templates/accounting/club_account_details.jinja:19 #: accounting/templates/accounting/club_account_details.jinja:19
#: accounting/templates/accounting/journal_details.jinja:17
#: accounting/templates/accounting/label_list.jinja:4 #: accounting/templates/accounting/label_list.jinja:4
#: accounting/templates/accounting/label_list.jinja:17 #: accounting/templates/accounting/label_list.jinja:17
msgid "Label list" msgid "Label list"
@ -403,7 +407,7 @@ msgid "End"
msgstr "Fin" msgstr "Fin"
#: accounting/templates/accounting/club_account_details.jinja:31 #: accounting/templates/accounting/club_account_details.jinja:31
#: accounting/templates/accounting/journal_details.jinja:28 #: accounting/templates/accounting/journal_details.jinja:31
#: core/templates/core/user_account_detail.jinja:20 #: core/templates/core/user_account_detail.jinja:20
#: core/templates/core/user_account_detail.jinja:81 #: core/templates/core/user_account_detail.jinja:81
#: counter/templates/counter/last_ops.jinja:17 #: counter/templates/counter/last_ops.jinja:17
@ -419,17 +423,17 @@ msgid "Closed"
msgstr "Fermé" msgstr "Fermé"
#: accounting/templates/accounting/club_account_details.jinja:34 #: accounting/templates/accounting/club_account_details.jinja:34
#: accounting/templates/accounting/journal_details.jinja:36 #: accounting/templates/accounting/journal_details.jinja:39
msgid "Actions" msgid "Actions"
msgstr "Actions" msgstr "Actions"
#: accounting/templates/accounting/club_account_details.jinja:50 #: accounting/templates/accounting/club_account_details.jinja:50
#: accounting/templates/accounting/journal_details.jinja:54 #: accounting/templates/accounting/journal_details.jinja:58
msgid "Yes" msgid "Yes"
msgstr "Oui" msgstr "Oui"
#: accounting/templates/accounting/club_account_details.jinja:52 #: accounting/templates/accounting/club_account_details.jinja:52
#: accounting/templates/accounting/journal_details.jinja:56 #: accounting/templates/accounting/journal_details.jinja:60
msgid "No" msgid "No"
msgstr "Non" msgstr "Non"
@ -443,31 +447,31 @@ msgstr "Voir"
msgid "General journal:" msgid "General journal:"
msgstr "Classeur : " msgstr "Classeur : "
#: accounting/templates/accounting/journal_details.jinja:16 #: accounting/templates/accounting/journal_details.jinja:18
#: core/templates/core/user_account.jinja:36 #: core/templates/core/user_account.jinja:36
#: core/templates/core/user_account_detail.jinja:10 #: core/templates/core/user_account_detail.jinja:10
#: counter/templates/counter/counter_click.jinja:31 #: counter/templates/counter/counter_click.jinja:31
msgid "Amount: " msgid "Amount: "
msgstr "Montant: " msgstr "Montant: "
#: accounting/templates/accounting/journal_details.jinja:17 #: accounting/templates/accounting/journal_details.jinja:19
msgid "Effective amount: " msgid "Effective amount: "
msgstr "Montant effectif: " msgstr "Montant effectif: "
#: accounting/templates/accounting/journal_details.jinja:19 #: accounting/templates/accounting/journal_details.jinja:21
msgid "Journal is closed, you can not create operation" msgid "Journal is closed, you can not create operation"
msgstr "Le classeur est fermé, vous ne pouvez pas créer d'opération" msgstr "Le classeur est fermé, vous ne pouvez pas créer d'opération"
#: accounting/templates/accounting/journal_details.jinja:21 #: accounting/templates/accounting/journal_details.jinja:23
msgid "New operation" msgid "New operation"
msgstr "Nouvelle opération" msgstr "Nouvelle opération"
#: accounting/templates/accounting/journal_details.jinja:26 #: accounting/templates/accounting/journal_details.jinja:28
#: counter/templates/counter/stats.jinja:14 #: counter/templates/counter/stats.jinja:14
msgid "Nb" msgid "Nb"
msgstr "No" msgstr "No"
#: accounting/templates/accounting/journal_details.jinja:27 #: accounting/templates/accounting/journal_details.jinja:29
#: club/templates/club/club_sellings.jinja:18 #: club/templates/club/club_sellings.jinja:18
#: core/templates/core/user_account_detail.jinja:17 #: core/templates/core/user_account_detail.jinja:17
#: core/templates/core/user_account_detail.jinja:46 #: core/templates/core/user_account_detail.jinja:46
@ -478,32 +482,39 @@ msgstr "No"
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
#: accounting/templates/accounting/journal_details.jinja:29 #: accounting/templates/accounting/journal_details.jinja:30
#: club/templates/club/club_sellings.jinja:22
#: core/templates/core/user_account_detail.jinja:49
#: counter/templates/counter/last_ops.jinja:42
msgid "Label"
msgstr "Étiquette"
#: accounting/templates/accounting/journal_details.jinja:32
msgid "Payment mode" msgid "Payment mode"
msgstr "Méthode de paiement" msgstr "Méthode de paiement"
#: accounting/templates/accounting/journal_details.jinja:30 #: accounting/templates/accounting/journal_details.jinja:33
msgid "Target" msgid "Target"
msgstr "Cible" msgstr "Cible"
#: accounting/templates/accounting/journal_details.jinja:31 #: accounting/templates/accounting/journal_details.jinja:34
msgid "Code" msgid "Code"
msgstr "Code" msgstr "Code"
#: accounting/templates/accounting/journal_details.jinja:32 #: accounting/templates/accounting/journal_details.jinja:35
msgid "Nature" msgid "Nature"
msgstr "Nature" msgstr "Nature"
#: accounting/templates/accounting/journal_details.jinja:33 #: accounting/templates/accounting/journal_details.jinja:36
msgid "Done" msgid "Done"
msgstr "Effectué" msgstr "Effectué"
#: accounting/templates/accounting/journal_details.jinja:34 #: accounting/templates/accounting/journal_details.jinja:37
#: counter/templates/counter/cash_summary_list.jinja:32 counter/views.py:702 #: counter/templates/counter/cash_summary_list.jinja:32 counter/views.py:702
msgid "Comment" msgid "Comment"
msgstr "Commentaire" msgstr "Commentaire"
#: accounting/templates/accounting/journal_details.jinja:35 #: accounting/templates/accounting/journal_details.jinja:38
msgid "File" msgid "File"
msgstr "Fichier" msgstr "Fichier"
@ -603,8 +614,7 @@ msgstr "L'utilisateur est déjà membre de ce club"
msgid "past member" msgid "past member"
msgstr "Anciens membres" msgstr "Anciens membres"
#: club/templates/club/club_list.jinja:4 #: club/templates/club/club_list.jinja:4 club/templates/club/club_list.jinja:24
#: club/templates/club/club_list.jinja:24
msgid "Club list" msgid "Club list"
msgstr "Liste des clubs" msgstr "Liste des clubs"
@ -622,20 +632,26 @@ msgstr "Membres du club"
#: club/templates/club/club_members.jinja:9 #: club/templates/club/club_members.jinja:9
#: club/templates/club/club_old_members.jinja:9 #: club/templates/club/club_old_members.jinja:9
#: core/templates/core/user_clubs.jinja:16
#: core/templates/core/user_clubs.jinja:42
msgid "Role" msgid "Role"
msgstr "Rôle" msgstr "Rôle"
#: club/templates/club/club_members.jinja:10 #: club/templates/club/club_members.jinja:10
#: club/templates/club/club_old_members.jinja:10 #: club/templates/club/club_old_members.jinja:10
#: core/templates/core/user_clubs.jinja:17
#: core/templates/core/user_clubs.jinja:43
msgid "Description" msgid "Description"
msgstr "Description" msgstr "Description"
#: club/templates/club/club_members.jinja:11 #: club/templates/club/club_members.jinja:11
#: core/templates/core/user_clubs.jinja:18
#: launderette/templates/launderette/launderette_admin.jinja:45 #: launderette/templates/launderette/launderette_admin.jinja:45
msgid "Since" msgid "Since"
msgstr "Depuis" msgstr "Depuis"
#: club/templates/club/club_members.jinja:21 #: club/templates/club/club_members.jinja:21
#: core/templates/core/user_clubs.jinja:29
msgid "Mark as old" msgid "Mark as old"
msgstr "Marquer comme ancien" msgstr "Marquer comme ancien"
@ -650,10 +666,12 @@ msgid "Club old members"
msgstr "Anciens membres du club" msgstr "Anciens membres du club"
#: club/templates/club/club_old_members.jinja:11 #: club/templates/club/club_old_members.jinja:11
#: core/templates/core/user_clubs.jinja:44
msgid "From" msgid "From"
msgstr "Du" msgstr "Du"
#: club/templates/club/club_old_members.jinja:12 #: club/templates/club/club_old_members.jinja:12
#: core/templates/core/user_clubs.jinja:45
msgid "To" msgid "To"
msgstr "Au" msgstr "Au"
@ -704,12 +722,6 @@ msgstr "Barman"
msgid "Customer" msgid "Customer"
msgstr "Client" msgstr "Client"
#: club/templates/club/club_sellings.jinja:22
#: core/templates/core/user_account_detail.jinja:49
#: counter/templates/counter/last_ops.jinja:42
msgid "Label"
msgstr "Étiquette"
#: club/templates/club/club_sellings.jinja:23 #: club/templates/club/club_sellings.jinja:23
#: core/templates/core/user_account_detail.jinja:50 #: core/templates/core/user_account_detail.jinja:50
#: core/templates/core/user_stats.jinja:28 #: core/templates/core/user_stats.jinja:28
@ -759,7 +771,7 @@ msgstr "Membres"
msgid "Old members" msgid "Old members"
msgstr "Anciens membres" msgstr "Anciens membres"
#: club/views.py:48 core/templates/core/base.jinja:40 core/views/user.py:140 #: club/views.py:48 core/templates/core/base.jinja:40 core/views/user.py:141
msgid "Tools" msgid "Tools"
msgstr "Outils" msgstr "Outils"
@ -1394,13 +1406,11 @@ msgstr "login"
msgid "Lost password?" msgid "Lost password?"
msgstr "Mot de passe perdu ?" msgstr "Mot de passe perdu ?"
#: core/templates/core/macros.jinja:27 #: core/templates/core/macros.jinja:27 core/templates/core/user_detail.jinja:27
#: core/templates/core/user_detail.jinja:27
msgid "Born: " msgid "Born: "
msgstr "Né le : " msgstr "Né le : "
#: core/templates/core/macros.jinja:31 #: core/templates/core/macros.jinja:31 core/templates/core/user_detail.jinja:48
#: core/templates/core/user_detail.jinja:48
msgid "Promo: " msgid "Promo: "
msgstr "Promo : " msgstr "Promo : "
@ -1611,7 +1621,7 @@ msgstr "Résultat de la recherche"
msgid "Users" msgid "Users"
msgstr "Utilisateurs" msgstr "Utilisateurs"
#: core/templates/core/search.jinja:18 #: core/templates/core/search.jinja:18 core/views/user.py:158
#: counter/templates/counter/stats.jinja:17 #: counter/templates/counter/stats.jinja:17
msgid "Clubs" msgid "Clubs"
msgstr "Clubs" msgstr "Clubs"
@ -1670,6 +1680,23 @@ msgstr "Retour"
msgid "Items" msgid "Items"
msgstr "Articles" msgstr "Articles"
#: core/templates/core/user_clubs.jinja:4
#, python-format
msgid "%(user_name)s's club(s)"
msgstr "Clubs de %(user_name)s"
#: core/templates/core/user_clubs.jinja:8
msgid "Club(s)"
msgstr "Clubs"
#: core/templates/core/user_clubs.jinja:10
msgid "Current club(s) :"
msgstr "Clubs actuels : "
#: core/templates/core/user_clubs.jinja:36
msgid "Old club(s) :"
msgstr "Anciens clubs :"
#: core/templates/core/user_detail.jinja:5 #: core/templates/core/user_detail.jinja:5
#, python-format #, python-format
msgid "%(user_name)s's profile" msgid "%(user_name)s's profile"
@ -1748,7 +1775,7 @@ msgstr "Changer le mot de passe"
msgid "%(user_name)s's godfathers" msgid "%(user_name)s's godfathers"
msgstr "Parrains de %(user_name)s" msgstr "Parrains de %(user_name)s"
#: core/templates/core/user_godfathers.jinja:10 core/views/user.py:134 #: core/templates/core/user_godfathers.jinja:10 core/views/user.py:135
msgid "Godfathers" msgid "Godfathers"
msgstr "Parrains" msgstr "Parrains"
@ -1803,7 +1830,7 @@ msgstr "Outils utilisateurs"
msgid "Sith management" msgid "Sith management"
msgstr "Gestion de Sith" msgstr "Gestion de Sith"
#: core/templates/core/user_tools.jinja:14 core/views/user.py:157 #: core/templates/core/user_tools.jinja:14 core/views/user.py:164
msgid "Groups" msgid "Groups"
msgstr "Groupes" msgstr "Groupes"
@ -1842,7 +1869,7 @@ msgstr "Gestion des types de produit"
msgid "Cash register summaries" msgid "Cash register summaries"
msgstr "Relevés de caisse" msgstr "Relevés de caisse"
#: core/templates/core/user_tools.jinja:36 core/views/user.py:145 #: core/templates/core/user_tools.jinja:36 core/views/user.py:146
#: counter/templates/counter/counter_list.jinja:18 #: counter/templates/counter/counter_list.jinja:18
#: counter/templates/counter/counter_list.jinja:33 #: counter/templates/counter/counter_list.jinja:33
#: counter/templates/counter/counter_list.jinja:48 #: counter/templates/counter/counter_list.jinja:48
@ -1911,7 +1938,7 @@ msgstr "Parrain"
msgid "Godchild" msgid "Godchild"
msgstr "Fillot" msgstr "Fillot"
#: core/views/user.py:291 #: core/views/user.py:298
msgid "User already has a profile picture" msgid "User already has a profile picture"
msgstr "L'utilisateur a déjà une photo de profil" msgstr "L'utilisateur a déjà une photo de profil"