Django upgrade
This commit is contained in:
parent
80055771e9
commit
a6dc8653af
15
README.md
15
README.md
|
@ -39,29 +39,44 @@ FLUSH PRIVILEGES;
|
||||||
|
|
||||||
```
|
```
|
||||||
bureau
|
bureau
|
||||||
|
Can view borrowed item
|
||||||
Can add borrowed item
|
Can add borrowed item
|
||||||
Can change borrowed item
|
Can change borrowed item
|
||||||
Can delete borrowed item
|
Can delete borrowed item
|
||||||
|
Can view adhesion
|
||||||
Can add adhesion
|
Can add adhesion
|
||||||
Can change adhesion
|
Can change adhesion
|
||||||
Can delete adhesion
|
Can delete adhesion
|
||||||
|
Can view clef
|
||||||
Can add clef
|
Can add clef
|
||||||
Can change clef
|
Can change clef
|
||||||
Can delete clef
|
Can delete clef
|
||||||
|
Can view user
|
||||||
Can add user
|
Can add user
|
||||||
Can change user
|
Can change user
|
||||||
|
|
||||||
keyholder
|
keyholder
|
||||||
|
Can view auteur
|
||||||
Can add auteur
|
Can add auteur
|
||||||
Can change auteur
|
Can change auteur
|
||||||
Can delete auteur
|
Can delete auteur
|
||||||
|
Can view media
|
||||||
Can add media
|
Can add media
|
||||||
Can change media
|
Can change media
|
||||||
Can delete media
|
Can delete media
|
||||||
|
Can view jeu
|
||||||
Can add jeu
|
Can add jeu
|
||||||
Can change jeu
|
Can change jeu
|
||||||
Can delete jeu
|
Can delete jeu
|
||||||
|
Can view emprunt
|
||||||
Can add emprunt
|
Can add emprunt
|
||||||
Can change emprunt
|
Can change emprunt
|
||||||
Can delete emprunt
|
Can delete emprunt
|
||||||
|
Can view user
|
||||||
|
Can view clef
|
||||||
|
|
||||||
|
users
|
||||||
|
Can view auteur
|
||||||
|
Can view media
|
||||||
|
Can view jeu
|
||||||
```
|
```
|
||||||
|
|
|
@ -6,6 +6,7 @@ from django.conf.urls import url
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
app_name = 'logs'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.index, name='index'),
|
url(r'^$', views.index, name='index'),
|
||||||
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
|
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
|
||||||
|
|
27
med/urls.py
27
med/urls.py
|
@ -2,28 +2,27 @@
|
||||||
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.conf.urls import include, url
|
from django.contrib.auth.views import PasswordResetView
|
||||||
from django.contrib.auth.views import password_reset
|
from django.urls import include, path
|
||||||
from django.views.generic import RedirectView
|
from django.views.generic import RedirectView
|
||||||
|
|
||||||
from media.views import index
|
from media.views import index
|
||||||
from .admin import admin_site
|
from .admin import admin_site
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', index, name='index'),
|
path('', index, name='index'),
|
||||||
|
|
||||||
# Include project routers
|
# Include project routers
|
||||||
url(r'^users/', include('users.urls', namespace='users')),
|
path('users/', include('users.urls')),
|
||||||
url(r'^media/', include('media.urls', namespace='media')),
|
path('media/', include('media.urls')),
|
||||||
url(r'^logs/', include('logs.urls', namespace='logs')),
|
path('logs/', include('logs.urls')),
|
||||||
|
|
||||||
# Include Django Contrib and Core routers
|
# Include Django Contrib and Core routers
|
||||||
url(r'^accounts/password_reset/$',
|
path('accounts/password_reset/', PasswordResetView.as_view(),
|
||||||
password_reset, name='admin_password_reset'),
|
name='admin_password_reset'),
|
||||||
url(r'^i18n/', include('django.conf.urls.i18n')),
|
path('i18n/', include('django.conf.urls.i18n')),
|
||||||
url(r'^accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
url(r'^accounts/profile/',
|
path('accounts/profile/', RedirectView.as_view(pattern_name='index')),
|
||||||
RedirectView.as_view(pattern_name='index')),
|
path('database/doc/', include('django.contrib.admindocs.urls')),
|
||||||
url(r'^database/doc/', include('django.contrib.admindocs.urls')),
|
path('database/', admin_site.urls),
|
||||||
url(r'^database/', admin_site.urls),
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,10 +10,12 @@ from .models import Auteur, Emprunt, Jeu, Media
|
||||||
|
|
||||||
class AuteurAdmin(VersionAdmin):
|
class AuteurAdmin(VersionAdmin):
|
||||||
list_display = ('nom',)
|
list_display = ('nom',)
|
||||||
|
search_fields = ('nom',)
|
||||||
|
|
||||||
|
|
||||||
class MediaAdmin(VersionAdmin):
|
class MediaAdmin(VersionAdmin):
|
||||||
list_display = ('titre', 'authors', 'cote')
|
list_display = ('titre', 'authors', 'cote')
|
||||||
|
search_fields = ('titre', 'authors', 'cote')
|
||||||
|
|
||||||
def authors(self, obj):
|
def authors(self, obj):
|
||||||
return ", ".join([a.nom for a in obj.auteur.all()])
|
return ", ".join([a.nom for a in obj.auteur.all()])
|
||||||
|
@ -22,11 +24,14 @@ class MediaAdmin(VersionAdmin):
|
||||||
class EmpruntAdmin(VersionAdmin):
|
class EmpruntAdmin(VersionAdmin):
|
||||||
list_display = ('media', 'user', 'date_emprunt', 'date_rendu',
|
list_display = ('media', 'user', 'date_emprunt', 'date_rendu',
|
||||||
'permanencier_emprunt', 'permanencier_rendu')
|
'permanencier_emprunt', 'permanencier_rendu')
|
||||||
|
search_fields = ('media', 'user', 'date_emprunt', 'date_rendu')
|
||||||
|
date_hierarchy = 'date_emprunt'
|
||||||
|
|
||||||
|
|
||||||
class JeuAdmin(VersionAdmin):
|
class JeuAdmin(VersionAdmin):
|
||||||
list_display = ('nom', 'proprietaire', 'duree', 'nombre_joueurs_min',
|
list_display = ('nom', 'proprietaire', 'duree', 'nombre_joueurs_min',
|
||||||
'nombre_joueurs_max', 'comment')
|
'nombre_joueurs_max', 'comment')
|
||||||
|
search_fields = ('nom', 'proprietaire', 'duree', 'comment')
|
||||||
|
|
||||||
|
|
||||||
admin_site.register(Auteur, AuteurAdmin)
|
admin_site.register(Auteur, AuteurAdmin)
|
||||||
|
|
|
@ -3,7 +3,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2019-08-09 22:25+0200\n"
|
"POT-Creation-Date: 2019-08-10 10:24+0200\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -45,78 +45,10 @@ msgstr "jeu"
|
||||||
msgid "games"
|
msgid "games"
|
||||||
msgstr "jeux"
|
msgstr "jeux"
|
||||||
|
|
||||||
#: templates/media/index.html:41
|
|
||||||
msgid "My profile"
|
|
||||||
msgstr "Mon profil"
|
|
||||||
|
|
||||||
#: templates/media/index.html:43
|
|
||||||
msgid "Edit"
|
|
||||||
msgstr "Éditer"
|
|
||||||
|
|
||||||
#: templates/media/index.html:47
|
|
||||||
msgid "username"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: templates/media/index.html:48
|
|
||||||
msgid "email"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: templates/media/index.html:49
|
|
||||||
msgid "comment"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: templates/media/index.html:50
|
|
||||||
msgid "date joined"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: templates/media/index.html:51
|
|
||||||
msgid "last login"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: templates/media/index.html:52
|
|
||||||
msgid "address"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: templates/media/index.html:53
|
|
||||||
msgid "phone number"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: templates/media/index.html:54
|
|
||||||
msgid "groups"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: templates/media/index.html:55
|
|
||||||
msgid "maximum borrowed"
|
|
||||||
msgstr "emprunts maximal"
|
|
||||||
|
|
||||||
#: templates/media/index.html:57
|
|
||||||
msgid "membership for current year"
|
|
||||||
msgstr "membre pour cette année"
|
|
||||||
|
|
||||||
#: templates/media/index.html:59
|
|
||||||
msgid "yes"
|
|
||||||
msgstr "oui"
|
|
||||||
|
|
||||||
#: templates/media/index.html:61
|
|
||||||
msgid "no"
|
|
||||||
msgstr "non"
|
|
||||||
|
|
||||||
#: templates/media/index.html:66
|
|
||||||
msgid "Current borrowed items"
|
|
||||||
msgstr "Emprunts en cours"
|
|
||||||
|
|
||||||
#: templates/media/index.html:70
|
|
||||||
msgid "since"
|
|
||||||
msgstr "depuis"
|
|
||||||
|
|
||||||
#: templates/media/index.html:74
|
|
||||||
msgid "No current borrowed items."
|
|
||||||
msgstr "Pas d'emprunts en cours."
|
|
||||||
|
|
||||||
#: templates/media/index.html:77
|
|
||||||
msgid "You are not logged in."
|
|
||||||
msgstr "Vous n'êtes pas identifié."
|
|
||||||
|
|
||||||
#: templates/media/media.html:37
|
#: templates/media/media.html:37
|
||||||
msgid "Save"
|
msgid "Save"
|
||||||
msgstr "Enregistrer"
|
msgstr "Enregistrer"
|
||||||
|
|
||||||
|
#: views.py:80
|
||||||
|
msgid "Welcome to the Mediatek database"
|
||||||
|
msgstr "Bienvenue sur la base de données de la Mediatek"
|
||||||
|
|
|
@ -6,6 +6,7 @@ from django.conf.urls import url
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
app_name = 'media'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^add_emprunt/(?P<userid>[0-9]+)$', views.add_emprunt,
|
url(r'^add_emprunt/(?P<userid>[0-9]+)$', views.add_emprunt,
|
||||||
name='add-emprunt'),
|
name='add-emprunt'),
|
||||||
|
|
|
@ -29,14 +29,14 @@ def add_emprunt(request, userid):
|
||||||
user = User.objects.get(pk=userid)
|
user = User.objects.get(pk=userid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
messages.error(request, u"Entrée inexistante")
|
messages.error(request, u"Entrée inexistante")
|
||||||
return redirect("/")
|
return redirect("admin:media_emprunt_changelist")
|
||||||
emprunts_en_cours = Emprunt.objects.filter(date_rendu=None,
|
emprunts_en_cours = Emprunt.objects.filter(date_rendu=None,
|
||||||
user=user).count()
|
user=user).count()
|
||||||
if emprunts_en_cours >= user.maxemprunt:
|
if emprunts_en_cours >= user.maxemprunt:
|
||||||
messages.error(request,
|
messages.error(request,
|
||||||
"Maximum d'emprunts atteint de "
|
"Maximum d'emprunts atteint de "
|
||||||
"l'user %s" % user.maxemprunt)
|
"l'user %s" % user.maxemprunt)
|
||||||
return redirect("/")
|
return redirect("admin:media_emprunt_changelist")
|
||||||
emprunt = EmpruntForm(request.POST or None)
|
emprunt = EmpruntForm(request.POST or None)
|
||||||
if emprunt.is_valid():
|
if emprunt.is_valid():
|
||||||
emprunt = emprunt.save(commit=False)
|
emprunt = emprunt.save(commit=False)
|
||||||
|
@ -48,7 +48,7 @@ def add_emprunt(request, userid):
|
||||||
reversion.set_user(request.user)
|
reversion.set_user(request.user)
|
||||||
reversion.set_comment("Création")
|
reversion.set_comment("Création")
|
||||||
messages.success(request, "Le emprunt a été ajouté")
|
messages.success(request, "Le emprunt a été ajouté")
|
||||||
return redirect("/")
|
return redirect("admin:media_emprunt_changelist")
|
||||||
return form({'form': emprunt}, 'media/media.html', request)
|
return form({'form': emprunt}, 'media/media.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,14 +59,14 @@ def retour_emprunt(request, empruntid):
|
||||||
emprunt_instance = Emprunt.objects.get(pk=empruntid)
|
emprunt_instance = Emprunt.objects.get(pk=empruntid)
|
||||||
except Emprunt.DoesNotExist:
|
except Emprunt.DoesNotExist:
|
||||||
messages.error(request, u"Entrée inexistante")
|
messages.error(request, u"Entrée inexistante")
|
||||||
return redirect("/")
|
return redirect("admin:media_emprunt_changelist")
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
emprunt_instance.permanencier_rendu = request.user
|
emprunt_instance.permanencier_rendu = request.user
|
||||||
emprunt_instance.date_rendu = timezone.now()
|
emprunt_instance.date_rendu = timezone.now()
|
||||||
emprunt_instance.save()
|
emprunt_instance.save()
|
||||||
reversion.set_user(request.user)
|
reversion.set_user(request.user)
|
||||||
messages.success(request, "Retour enregistré")
|
messages.success(request, "Retour enregistré")
|
||||||
return redirect("/")
|
return redirect("admin:media_emprunt_changelist")
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Django==1.11.22
|
Django==2.2.4
|
||||||
docutils==0.14
|
docutils==0.14
|
||||||
Pillow==5.4.1
|
Pillow==5.4.1
|
||||||
pytz==2019.1
|
pytz==2019.1
|
||||||
|
|
|
@ -3,7 +3,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2019-08-09 22:14+0200\n"
|
"POT-Creation-Date: 2019-08-10 10:24+0200\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -17,26 +17,119 @@ msgstr ""
|
||||||
msgid "Welcome,"
|
msgid "Welcome,"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: templates/admin/base_site.html:30
|
#: templates/admin/base_site.html:31 templates/admin/base_site.html:51
|
||||||
msgid "Explore the library"
|
|
||||||
msgstr "Explorer la médiatèque"
|
|
||||||
|
|
||||||
#: templates/admin/base_site.html:50 templates/admin/base_site.html:69
|
|
||||||
msgid "Explore database"
|
msgid "Explore database"
|
||||||
msgstr "Explorer la base de données"
|
msgstr "Explorer la base de données"
|
||||||
|
|
||||||
#: templates/admin/base_site.html:62
|
#: templates/admin/base_site.html:44
|
||||||
msgid "Documentation"
|
msgid "Documentation"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: templates/admin/base_site.html:71
|
#: templates/admin/base_site.html:54
|
||||||
msgid "Log out"
|
msgid "Log out"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: templates/admin/base_site.html:73 templates/registration/login.html:8
|
#: templates/admin/base_site.html:56 templates/registration/login.html:8
|
||||||
msgid "Log in"
|
msgid "Log in"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:23
|
||||||
|
#, python-format
|
||||||
|
msgid "Models in the %(name)s application"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:34
|
||||||
|
msgid "Add"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:40
|
||||||
|
msgid "Change"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:63
|
||||||
|
msgid "My profile"
|
||||||
|
msgstr "Mon profil"
|
||||||
|
|
||||||
|
#: templates/admin/index.html:65
|
||||||
|
msgid "Edit"
|
||||||
|
msgstr "Éditer"
|
||||||
|
|
||||||
|
#: templates/admin/index.html:69
|
||||||
|
msgid "username"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:70
|
||||||
|
msgid "email"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:71
|
||||||
|
msgid "comment"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:72
|
||||||
|
msgid "date joined"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:73
|
||||||
|
msgid "last login"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:74
|
||||||
|
msgid "address"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:75
|
||||||
|
msgid "phone number"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:76
|
||||||
|
msgid "groups"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:78
|
||||||
|
msgid "maximum borrowed"
|
||||||
|
msgstr "emprunts maximal"
|
||||||
|
|
||||||
|
#: templates/admin/index.html:80
|
||||||
|
msgid "membership for current year"
|
||||||
|
msgstr "membre pour cette année"
|
||||||
|
|
||||||
|
#: templates/admin/index.html:82
|
||||||
|
msgid "yes"
|
||||||
|
msgstr "oui"
|
||||||
|
|
||||||
|
#: templates/admin/index.html:84
|
||||||
|
msgid "no"
|
||||||
|
msgstr "non"
|
||||||
|
|
||||||
|
#: templates/admin/index.html:89
|
||||||
|
msgid "Current borrowed items"
|
||||||
|
msgstr "Emprunts en cours"
|
||||||
|
|
||||||
|
#: templates/admin/index.html:93
|
||||||
|
msgid "since"
|
||||||
|
msgstr "depuis"
|
||||||
|
|
||||||
|
#: templates/admin/index.html:97
|
||||||
|
msgid "No current borrowed items."
|
||||||
|
msgstr "Pas d'emprunts en cours."
|
||||||
|
|
||||||
|
#: templates/admin/index.html:100
|
||||||
|
msgid "My actions"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:104
|
||||||
|
msgid "None available"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:119
|
||||||
|
msgid "Unknown content"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/admin/index.html:126
|
||||||
|
msgid "You are not logged in."
|
||||||
|
msgstr "Vous n'êtes pas identifié."
|
||||||
|
|
||||||
#: templates/base.html:10 templates/registration/logged_out.html:9
|
#: templates/base.html:10 templates/registration/logged_out.html:9
|
||||||
#: templates/registration/password_change_done.html:9
|
#: templates/registration/password_change_done.html:9
|
||||||
#: templates/registration/password_change_form.html:9
|
#: templates/registration/password_change_form.html:9
|
||||||
|
@ -89,6 +182,3 @@ msgstr ""
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "The %(site_name)s team"
|
msgid "The %(site_name)s team"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#~ msgid "View admin"
|
|
||||||
#~ msgstr "Administration"
|
|
||||||
|
|
|
@ -128,12 +128,6 @@ input[type=button]:focus, .button:hover, input[type=submit]:hover, input[type=bu
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recenter login button */
|
|
||||||
.login .submit-row {
|
|
||||||
padding: 1em 0 0 0 !important;
|
|
||||||
text-align: center !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Branding logo */
|
/* Branding logo */
|
||||||
#branding img {
|
#branding img {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|
|
@ -11,7 +11,7 @@ Test that every themed page still works
|
||||||
|
|
||||||
class TemplateLoggedOutTests(TestCase):
|
class TemplateLoggedOutTests(TestCase):
|
||||||
def test_login_page(self):
|
def test_login_page(self):
|
||||||
response = self.client.get('/admin/login/')
|
response = self.client.get('/database/login/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@ class TemplateLoggedInTests(TestCase):
|
||||||
"""
|
"""
|
||||||
Login page should redirect
|
Login page should redirect
|
||||||
"""
|
"""
|
||||||
response = self.client.get('/admin/login/')
|
response = self.client.get('/database/login/')
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
|
|
||||||
def test_admin_index(self):
|
def test_admin_index(self):
|
||||||
response = self.client.get('/admin/')
|
response = self.client.get('/database/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_accounts_password_reset(self):
|
def test_accounts_password_reset(self):
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
default_app_config = 'users.apps.UsersConfig'
|
|
@ -6,19 +6,20 @@ from django.contrib import admin
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||||
from django.contrib.auth.forms import PasswordResetForm
|
from django.contrib.auth.forms import PasswordResetForm
|
||||||
from django.core.urlresolvers import reverse
|
from django.urls import reverse
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from reversion.admin import VersionAdmin
|
from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
|
from med.admin import admin_site
|
||||||
from .forms import UserCreationAdminForm
|
from .forms import UserCreationAdminForm
|
||||||
from .models import Adhesion, Clef, User
|
from .models import Adhesion, Clef, User
|
||||||
from med.admin import admin_site
|
|
||||||
|
|
||||||
|
|
||||||
class ClefAdmin(VersionAdmin):
|
class ClefAdmin(VersionAdmin):
|
||||||
list_display = ('nom', 'proprio', 'commentaire')
|
list_display = ('nom', 'proprio', 'commentaire')
|
||||||
ordering = ('nom',)
|
ordering = ('nom',)
|
||||||
|
search_fields = ('nom', 'proprio', 'commentaire')
|
||||||
|
|
||||||
|
|
||||||
class AdhesionAdmin(VersionAdmin):
|
class AdhesionAdmin(VersionAdmin):
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from django.apps import AppConfig
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db.models.signals import post_save
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from .signals import add_to_default_group
|
||||||
|
|
||||||
|
|
||||||
|
class UsersConfig(AppConfig):
|
||||||
|
name = 'users'
|
||||||
|
verbose_name = _('users')
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
post_save.connect(add_to_default_group,
|
||||||
|
sender=settings.AUTH_USER_MODEL)
|
|
@ -44,6 +44,12 @@ class UserCreationAdminForm(ModelForm):
|
||||||
from the given information.
|
from the given information.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['email'].required = True
|
||||||
|
self.fields['first_name'].required = True
|
||||||
|
self.fields['last_name'].required = True
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ("username", "email", "first_name", "last_name", "address",
|
fields = ("username", "email", "first_name", "last_name", "address",
|
||||||
|
|
|
@ -3,7 +3,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2019-08-09 23:09+0200\n"
|
"POT-Creation-Date: 2019-08-10 10:21+0200\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -13,71 +13,71 @@ msgstr ""
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#: admin.py:32
|
#: admin.py:29
|
||||||
msgid "adherent status"
|
msgid "adherent status"
|
||||||
msgstr "statut adhérent"
|
msgstr "statut adhérent"
|
||||||
|
|
||||||
#: admin.py:37
|
#: admin.py:34
|
||||||
msgid "Yes"
|
msgid "Yes"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: admin.py:54
|
#: admin.py:51
|
||||||
msgid "Personal info"
|
msgid "Personal info"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: admin.py:56
|
#: admin.py:53
|
||||||
msgid "Permissions"
|
msgid "Permissions"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: admin.py:59
|
#: admin.py:56
|
||||||
msgid "Important dates"
|
msgid "Important dates"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: admin.py:89
|
#: admin.py:86
|
||||||
msgid "An email to set the password was sent."
|
msgid "An email to set the password was sent."
|
||||||
msgstr "Un mail pour initialiser le mot de passe a été envoyé."
|
msgstr "Un mail pour initialiser le mot de passe a été envoyé."
|
||||||
|
|
||||||
#: admin.py:92
|
#: admin.py:89
|
||||||
msgid "The email is invalid."
|
msgid "The email is invalid."
|
||||||
msgstr "L'adresse mail est invalide."
|
msgstr "L'adresse mail est invalide."
|
||||||
|
|
||||||
#: admin.py:111
|
#: admin.py:108
|
||||||
msgid "Adhere"
|
msgid "Adhere"
|
||||||
msgstr "Adhérer"
|
msgstr "Adhérer"
|
||||||
|
|
||||||
#: admin.py:114
|
#: admin.py:111
|
||||||
msgid "is adherent"
|
msgid "is adherent"
|
||||||
msgstr "statut adhérent"
|
msgstr "statut adhérent"
|
||||||
|
|
||||||
#: admin.py:122
|
#: admin.py:119
|
||||||
msgid "Register borrowed item"
|
msgid "Register borrowed item"
|
||||||
msgstr "Enregistrer emprunt"
|
msgstr "Enregistrer emprunt"
|
||||||
|
|
||||||
#: admin.py:125
|
#: admin.py:122
|
||||||
msgid "actions"
|
msgid "actions"
|
||||||
msgstr "actions"
|
msgstr "actions"
|
||||||
|
|
||||||
#: models.py:18
|
#: models.py:14
|
||||||
msgid "phone number"
|
msgid "phone number"
|
||||||
msgstr "numéro de téléphone"
|
msgstr "numéro de téléphone"
|
||||||
|
|
||||||
#: models.py:24
|
#: models.py:20
|
||||||
msgid "address"
|
msgid "address"
|
||||||
msgstr "adresse"
|
msgstr "adresse"
|
||||||
|
|
||||||
#: models.py:30
|
#: models.py:26
|
||||||
msgid "maximum borrowed"
|
msgid "maximum borrowed"
|
||||||
msgstr "emprunts maximal"
|
msgstr "emprunts maximal"
|
||||||
|
|
||||||
#: models.py:31
|
#: models.py:27
|
||||||
msgid "Maximal amount of simultaneous borrowed item authorized."
|
msgid "Maximal amount of simultaneous borrowed item authorized."
|
||||||
msgstr "Nombre maximal d'objets empruntés en même temps."
|
msgstr "Nombre maximal d'objets empruntés en même temps."
|
||||||
|
|
||||||
#: models.py:36
|
#: models.py:32
|
||||||
msgid "comment"
|
msgid "comment"
|
||||||
msgstr "commentaire"
|
msgstr "commentaire"
|
||||||
|
|
||||||
#: models.py:37
|
#: models.py:33
|
||||||
msgid "Promotion..."
|
msgid "Promotion..."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-08-10 08:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('users', '0027_auto_20190809_2317'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='user',
|
||||||
|
name='last_name',
|
||||||
|
field=models.CharField(blank=True, max_length=150, verbose_name='last name'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,14 @@
|
||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
|
||||||
|
def add_to_default_group(sender, **kwargs):
|
||||||
|
"""
|
||||||
|
When creating a new user, add it to users group
|
||||||
|
"""
|
||||||
|
user = kwargs["instance"]
|
||||||
|
if kwargs["created"]:
|
||||||
|
from django.contrib.auth.models import Group
|
||||||
|
group, group_created = Group.objects.get_or_create(name='users')
|
||||||
|
user.groups.add(group)
|
|
@ -33,7 +33,7 @@ def edit_info(request):
|
||||||
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
|
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
|
||||||
field for field in user.changed_data))
|
field for field in user.changed_data))
|
||||||
messages.success(request, "L'user a bien été modifié")
|
messages.success(request, "L'user a bien été modifié")
|
||||||
return redirect("/")
|
return redirect("index")
|
||||||
return form({
|
return form({
|
||||||
'form': user,
|
'form': user,
|
||||||
'password_change': True,
|
'password_change': True,
|
||||||
|
@ -48,12 +48,15 @@ def adherer(request, userid):
|
||||||
users = User.objects.get(pk=userid)
|
users = User.objects.get(pk=userid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
messages.error(request, "Utilisateur inexistant")
|
messages.error(request, "Utilisateur inexistant")
|
||||||
return redirect("/")
|
return redirect("admin:users_user_changelist")
|
||||||
adh_year = Adhesion.objects.all().order_by('annee_debut').reverse().first()
|
adh_year = Adhesion.objects.all().order_by('annee_debut').reverse().first()
|
||||||
|
if not adh_year:
|
||||||
|
messages.error(request, "Année d'adhésion non définie")
|
||||||
|
return redirect("admin:users_user_changelist")
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
reversion.set_user(request.user)
|
reversion.set_user(request.user)
|
||||||
adh_year.adherent.add(users)
|
adh_year.adherent.add(users)
|
||||||
adh_year.save()
|
adh_year.save()
|
||||||
reversion.set_comment("Adhesion de %s" % users)
|
reversion.set_comment("Adhesion de %s" % users)
|
||||||
messages.success(request, "Adhesion effectuee")
|
messages.success(request, "Adhesion effectuee")
|
||||||
return redirect("/")
|
return redirect("admin:users_user_changelist")
|
||||||
|
|
Loading…
Reference in New Issue