diff --git a/users/templates/users/aff_users.html b/search/templates/search/aff_users.html
similarity index 100%
rename from users/templates/users/aff_users.html
rename to search/templates/search/aff_users.html
diff --git a/search/templates/search/index.html b/search/templates/search/index.html
index 74c4479..9e516c8 100644
--- a/search/templates/search/index.html
+++ b/search/templates/search/index.html
@@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block content %}
{% if users_list %}
Résultats dans les utilisateurs
- {% include "users/aff_users.html" with users_list=users_list %}
+ {% include "search/aff_users.html" with users_list=users_list %}
{% endif%}
{% if emprunts_list %}
Résultats dans les emprunt :
diff --git a/users/admin.py b/users/admin.py
index 0fc53ff..8c23c4c 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -4,6 +4,8 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
+from django.core.urlresolvers import reverse
+from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from reversion.admin import VersionAdmin
@@ -54,7 +56,7 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
)
list_display = ('username', 'email', 'first_name', 'last_name',
- 'maxemprunt', 'is_adherent', 'is_staff')
+ 'maxemprunt', 'is_adherent', 'is_staff', 'actions_btn')
list_filter = (IsAdherentFilter, 'is_staff', 'is_superuser', 'is_active',
'groups')
@@ -64,15 +66,33 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
"""
last_adh_year = Adhesion.objects.all().order_by('annee_debut') \
.reverse().first()
- return last_adh_year and obj in last_adh_year.adherent.all()
+ is_member = last_adh_year and obj in last_adh_year.adherent.all()
+ if is_member:
+ return format_html(
+ ''
+ )
+ else:
+ # TODO permit adhere only if perms.users.add_user
+ return format_html(
+ ' '
+ '{}',
+ reverse('users:adherer', args=[obj.pk]),
+ _('Adhere')
+ )
- is_adherent.boolean = True
is_adherent.short_description = _('is adherent')
+ is_adherent.allow_tags = True
- # TODO {% if not user.is_adherent and perms.users.add_user %}
- # {% url 'users:adherer' user.id %}
- # TODO {% if perms.media.add_emprunt %}
- # {% url 'media:add-emprunt' user.id %}">
+ def actions_btn(self, obj):
+ # TODO permit adhere only if perms.media.add_emprunt
+ return format_html(
+ '{}',
+ reverse('media:add-emprunt', args=[obj.pk]),
+ _('Register borrowed item')
+ )
+
+ actions_btn.short_description = _('actions')
+ actions_btn.allow_tags = True
admin.site.register(User, UserAdmin)
diff --git a/users/forms.py b/users/forms.py
index ed6d5b8..6fbf008 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -28,10 +28,10 @@ class BaseInfoForm(ModelForm):
class Meta:
model = User
fields = [
- 'first_name',
'username',
- 'last_name',
'email',
- 'telephone',
+ 'first_name',
+ 'last_name',
'address',
+ 'telephone',
]
diff --git a/users/templates/users/user.html b/users/templates/users/user.html
index 195f057..b2b3849 100644
--- a/users/templates/users/user.html
+++ b/users/templates/users/user.html
@@ -1,21 +1,72 @@
-{% extends "base.html" %}
+{% extends "admin/base_site.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
-{% load bootstrap3 %}
+{% load i18n static %}
-{% block title %}Création et modification d'utilisateur{% endblock %}
+{% block breadcrumbs %}
+