Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mediatek
Base de données Mediatek
Commits
a6dc8653
Verified
Commit
a6dc8653
authored
Aug 10, 2019
by
erdnaxe
🦋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Django upgrade
parent
80055771
Pipeline
#1408
passed with stage
in 3 minutes and 22 seconds
Changes
19
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
240 additions
and
137 deletions
+240
-137
README.md
README.md
+15
-0
logs/urls.py
logs/urls.py
+1
-0
med/urls.py
med/urls.py
+13
-14
media/admin.py
media/admin.py
+5
-0
media/locale/fr/LC_MESSAGES/django.po
media/locale/fr/LC_MESSAGES/django.po
+5
-73
media/urls.py
media/urls.py
+1
-0
media/views.py
media/views.py
+5
-5
requirements.txt
requirements.txt
+1
-1
theme/locale/fr/LC_MESSAGES/django.po
theme/locale/fr/LC_MESSAGES/django.po
+102
-12
theme/static/css/admin.css
theme/static/css/admin.css
+0
-6
theme/tests/test_templates.py
theme/tests/test_templates.py
+3
-3
users/__init__.py
users/__init__.py
+5
-0
users/admin.py
users/admin.py
+3
-2
users/apps.py
users/apps.py
+19
-0
users/forms.py
users/forms.py
+6
-0
users/locale/fr/LC_MESSAGES/django.po
users/locale/fr/LC_MESSAGES/django.po
+18
-18
users/migrations/0028_auto_20190810_1003.py
users/migrations/0028_auto_20190810_1003.py
+18
-0
users/signals.py
users/signals.py
+14
-0
users/views.py
users/views.py
+6
-3
No files found.
README.md
View file @
a6dc8653
...
...
@@ -39,29 +39,44 @@ FLUSH PRIVILEGES;
```
bureau
Can view borrowed item
Can add borrowed item
Can change borrowed item
Can delete borrowed item
Can view adhesion
Can add adhesion
Can change adhesion
Can delete adhesion
Can view clef
Can add clef
Can change clef
Can delete clef
Can view user
Can add user
Can change user
keyholder
Can view auteur
Can add auteur
Can change auteur
Can delete auteur
Can view media
Can add media
Can change media
Can delete media
Can view jeu
Can add jeu
Can change jeu
Can delete jeu
Can view emprunt
Can add emprunt
Can change emprunt
Can delete emprunt
Can view user
Can view clef
users
Can view auteur
Can view media
Can view jeu
```
logs/urls.py
View file @
a6dc8653
...
...
@@ -6,6 +6,7 @@ from django.conf.urls import url
from
.
import
views
app_name
=
'logs'
urlpatterns
=
[
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r
'^stats_actions/$'
,
views
.
stats_actions
,
name
=
'stats-actions'
),
...
...
med/urls.py
View file @
a6dc8653
...
...
@@ -2,28 +2,27 @@
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from
django.con
f.urls
import
include
,
url
from
django.
contrib.auth.views
import
password_reset
from
django.con
trib.auth.views
import
PasswordResetView
from
django.
urls
import
include
,
path
from
django.views.generic
import
RedirectView
from
media.views
import
index
from
.admin
import
admin_site
urlpatterns
=
[
url
(
r
'^$
'
,
index
,
name
=
'index'
),
path
(
'
'
,
index
,
name
=
'index'
),
# Include project routers
url
(
r
'^
users/'
,
include
(
'users.urls'
,
namespace
=
'users'
)),
url
(
r
'^
media/'
,
include
(
'media.urls'
,
namespace
=
'media'
)),
url
(
r
'^
logs/'
,
include
(
'logs.urls'
,
namespace
=
'logs'
)),
path
(
'
users/'
,
include
(
'users.urls'
)),
path
(
'
media/'
,
include
(
'media.urls'
)),
path
(
'
logs/'
,
include
(
'logs.urls'
)),
# Include Django Contrib and Core routers
url
(
r
'^accounts/password_reset/$'
,
password_reset
,
name
=
'admin_password_reset'
),
url
(
r
'^i18n/'
,
include
(
'django.conf.urls.i18n'
)),
url
(
r
'^accounts/'
,
include
(
'django.contrib.auth.urls'
)),
url
(
r
'^accounts/profile/'
,
RedirectView
.
as_view
(
pattern_name
=
'index'
)),
url
(
r
'^database/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
url
(
r
'^database/'
,
admin_site
.
urls
),
path
(
'accounts/password_reset/'
,
PasswordResetView
.
as_view
(),
name
=
'admin_password_reset'
),
path
(
'i18n/'
,
include
(
'django.conf.urls.i18n'
)),
path
(
'accounts/'
,
include
(
'django.contrib.auth.urls'
)),
path
(
'accounts/profile/'
,
RedirectView
.
as_view
(
pattern_name
=
'index'
)),
path
(
'database/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
path
(
'database/'
,
admin_site
.
urls
),
]
media/admin.py
View file @
a6dc8653
...
...
@@ -10,10 +10,12 @@ from .models import Auteur, Emprunt, Jeu, Media
class
AuteurAdmin
(
VersionAdmin
):
list_display
=
(
'nom'
,)
search_fields
=
(
'nom'
,)
class
MediaAdmin
(
VersionAdmin
):
list_display
=
(
'titre'
,
'authors'
,
'cote'
)
search_fields
=
(
'titre'
,
'authors'
,
'cote'
)
def
authors
(
self
,
obj
):
return
", "
.
join
([
a
.
nom
for
a
in
obj
.
auteur
.
all
()])
...
...
@@ -22,11 +24,14 @@ class MediaAdmin(VersionAdmin):
class
EmpruntAdmin
(
VersionAdmin
):
list_display
=
(
'media'
,
'user'
,
'date_emprunt'
,
'date_rendu'
,
'permanencier_emprunt'
,
'permanencier_rendu'
)
search_fields
=
(
'media'
,
'user'
,
'date_emprunt'
,
'date_rendu'
)
date_hierarchy
=
'date_emprunt'
class
JeuAdmin
(
VersionAdmin
):
list_display
=
(
'nom'
,
'proprietaire'
,
'duree'
,
'nombre_joueurs_min'
,
'nombre_joueurs_max'
,
'comment'
)
search_fields
=
(
'nom'
,
'proprietaire'
,
'duree'
,
'comment'
)
admin_site
.
register
(
Auteur
,
AuteurAdmin
)
...
...
media/locale/fr/LC_MESSAGES/django.po
View file @
a6dc8653
...
...
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-
09 22
:2
5
+0200\n"
"POT-Creation-Date: 2019-08-
10 10
:2
4
+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
@@ -45,78 +45,10 @@ msgstr "jeu"
msgid "games"
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
msgid "Save"
msgstr "Enregistrer"
#: views.py:80
msgid "Welcome to the Mediatek database"
msgstr "Bienvenue sur la base de données de la Mediatek"
media/urls.py
View file @
a6dc8653
...
...
@@ -6,6 +6,7 @@ from django.conf.urls import url
from
.
import
views
app_name
=
'media'
urlpatterns
=
[
url
(
r
'^add_emprunt/(?P<userid>[0-9]+)$'
,
views
.
add_emprunt
,
name
=
'add-emprunt'
),
...
...
media/views.py
View file @
a6dc8653
...
...
@@ -29,14 +29,14 @@ def add_emprunt(request, userid):
user
=
User
.
objects
.
get
(
pk
=
userid
)
except
User
.
DoesNotExist
:
messages
.
error
(
request
,
u
"Entrée inexistante"
)
return
redirect
(
"
/
"
)
return
redirect
(
"
admin:media_emprunt_changelist
"
)
emprunts_en_cours
=
Emprunt
.
objects
.
filter
(
date_rendu
=
None
,
user
=
user
).
count
()
if
emprunts_en_cours
>=
user
.
maxemprunt
:
messages
.
error
(
request
,
"Maximum d'emprunts atteint de "
"l'user %s"
%
user
.
maxemprunt
)
return
redirect
(
"
/
"
)
return
redirect
(
"
admin:media_emprunt_changelist
"
)
emprunt
=
EmpruntForm
(
request
.
POST
or
None
)
if
emprunt
.
is_valid
():
emprunt
=
emprunt
.
save
(
commit
=
False
)
...
...
@@ -48,7 +48,7 @@ def add_emprunt(request, userid):
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
messages
.
success
(
request
,
"Le emprunt a été ajouté"
)
return
redirect
(
"
/
"
)
return
redirect
(
"
admin:media_emprunt_changelist
"
)
return
form
({
'form'
:
emprunt
},
'media/media.html'
,
request
)
...
...
@@ -59,14 +59,14 @@ def retour_emprunt(request, empruntid):
emprunt_instance
=
Emprunt
.
objects
.
get
(
pk
=
empruntid
)
except
Emprunt
.
DoesNotExist
:
messages
.
error
(
request
,
u
"Entrée inexistante"
)
return
redirect
(
"
/
"
)
return
redirect
(
"
admin:media_emprunt_changelist
"
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
emprunt_instance
.
permanencier_rendu
=
request
.
user
emprunt_instance
.
date_rendu
=
timezone
.
now
()
emprunt_instance
.
save
()
reversion
.
set_user
(
request
.
user
)
messages
.
success
(
request
,
"Retour enregistré"
)
return
redirect
(
"
/
"
)
return
redirect
(
"
admin:media_emprunt_changelist
"
)
def
index
(
request
):
...
...
requirements.txt
View file @
a6dc8653
Django
==
1.11.22
Django
==
2.2.4
docutils
==0.14
Pillow
==5.4.1
pytz
==2019.1
...
...
theme/locale/fr/LC_MESSAGES/django.po
View file @
a6dc8653
...
...
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-
09 22:1
4+0200\n"
"POT-Creation-Date: 2019-08-
10 10:2
4+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
@@ -17,26 +17,119 @@ msgstr ""
msgid "Welcome,"
msgstr ""
#: templates/admin/base_site.html:30
msgid "Explore the library"
msgstr "Explorer la médiatèque"
#: templates/admin/base_site.html:50 templates/admin/base_site.html:69
#: templates/admin/base_site.html:31 templates/admin/base_site.html:51
msgid "Explore database"
msgstr "Explorer la base de données"
#: templates/admin/base_site.html:
62
#: templates/admin/base_site.html:
44
msgid "Documentation"
msgstr ""
#: templates/admin/base_site.html:
71
#: templates/admin/base_site.html:
54
msgid "Log out"
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"
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/registration/password_change_done.html:9
#: templates/registration/password_change_form.html:9
...
...
@@ -89,6 +182,3 @@ msgstr ""
#, python-format
msgid "The %(site_name)s team"
msgstr ""
#~ msgid "View admin"
#~ msgstr "Administration"
theme/static/css/admin.css
View file @
a6dc8653
...
...
@@ -128,12 +128,6 @@ input[type=button]:focus, .button:hover, input[type=submit]:hover, input[type=bu
min-height
:
0
;
}
/* Recenter login button */
.login
.submit-row
{
padding
:
1em
0
0
0
!important
;
text-align
:
center
!important
;
}
/* Branding logo */
#branding
img
{
vertical-align
:
middle
;
...
...
theme/tests/test_templates.py
View file @
a6dc8653
...
...
@@ -11,7 +11,7 @@ Test that every themed page still works
class
TemplateLoggedOutTests
(
TestCase
):
def
test_login_page
(
self
):
response
=
self
.
client
.
get
(
'/
admin
/login/'
)
response
=
self
.
client
.
get
(
'/
database
/login/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
@@ -28,11 +28,11 @@ class TemplateLoggedInTests(TestCase):
"""
Login page should redirect
"""
response
=
self
.
client
.
get
(
'/
admin
/login/'
)
response
=
self
.
client
.
get
(
'/
database
/login/'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_admin_index
(
self
):
response
=
self
.
client
.
get
(
'/
admin
/'
)
response
=
self
.
client
.
get
(
'/
database
/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_accounts_password_reset
(
self
):
...
...
users/__init__.py
View file @
a6dc8653
# -*- 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'
users/admin.py
View file @
a6dc8653
...
...
@@ -6,19 +6,20 @@ from django.contrib import admin
from
django.contrib
import
messages
from
django.contrib.auth.admin
import
UserAdmin
as
BaseUserAdmin
from
django.contrib.auth.forms
import
PasswordResetForm
from
django.
core.urlresolver
s
import
reverse
from
django.
url
s
import
reverse
from
django.utils.html
import
format_html
from
django.utils.translation
import
ugettext_lazy
as
_
from
reversion.admin
import
VersionAdmin
from
med.admin
import
admin_site
from
.forms
import
UserCreationAdminForm
from
.models
import
Adhesion
,
Clef
,
User
from
med.admin
import
admin_site
class
ClefAdmin
(
VersionAdmin
):
list_display
=
(
'nom'
,
'proprio'
,
'commentaire'
)
ordering
=
(
'nom'
,)
search_fields
=
(
'nom'
,
'proprio'
,
'commentaire'
)
class
AdhesionAdmin
(
VersionAdmin
):
...
...
users/apps.py
0 → 100644
View file @
a6dc8653
# -*- 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
)
users/forms.py
View file @
a6dc8653
...
...
@@ -44,6 +44,12 @@ class UserCreationAdminForm(ModelForm):
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
:
model
=
User
fields
=
(
"username"
,
"email"
,
"first_name"
,
"last_name"
,
"address"
,
...
...
users/locale/fr/LC_MESSAGES/django.po
View file @
a6dc8653
...
...
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
@@ -13,71 +13,71 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: admin.py:
3
2
#: admin.py:2
9
msgid "adherent status"
msgstr "statut adhérent"
#: admin.py:3
7
#: admin.py:3
4
msgid "Yes"
msgstr ""
#: admin.py:5
4
#: admin.py:5
1
msgid "Personal info"
msgstr ""
#: admin.py:5
6
#: admin.py:5
3
msgid "Permissions"
msgstr ""
#: admin.py:5
9
#: admin.py:5
6
msgid "Important dates"
msgstr ""
#: admin.py:8
9
#: admin.py:8
6
msgid "An email to set the password was sent."
msgstr "Un mail pour initialiser le mot de passe a été envoyé."
#: admin.py:9
2
#: admin.py:
8
9
msgid "The email is invalid."
msgstr "L'adresse mail est invalide."
#: admin.py:1
11
#: admin.py:1
08
msgid "Adhere"
msgstr "Adhérer"
#: admin.py:11
4
#: admin.py:11
1
msgid "is adherent"
msgstr "statut adhérent"
#: admin.py:1
22
#: admin.py:1
19
msgid "Register borrowed item"
msgstr "Enregistrer emprunt"
#: admin.py:12
5
#: admin.py:12
2
msgid "actions"
msgstr "actions"
#: models.py:1
8
#: models.py:1
4
msgid "phone number"
msgstr "numéro de téléphone"
#: models.py:2
4
#: models.py:2
0
msgid "address"
msgstr "adresse"
#: models.py:
30
#: models.py:
26
msgid "maximum borrowed"
msgstr "emprunts maximal"
#: models.py:
31
#: models.py:
27
msgid "Maximal amount of simultaneous borrowed item authorized."
msgstr "Nombre maximal d'objets empruntés en même temps."
#: models.py:3
6
#: models.py:3
2
msgid "comment"
msgstr "commentaire"
#: models.py:3
7
#: models.py:3
3
msgid "Promotion..."
msgstr ""
...
...
users/migrations/0028_auto_20190810_1003.py
0 → 100644
View file @
a6dc8653
# 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'
),