diff --git a/logs/views.py b/logs/views.py index b1c32a5..82cbd27 100644 --- a/logs/views.py +++ b/logs/views.py @@ -2,7 +2,8 @@ # Copyright (C) 2017-2019 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from django.contrib.auth.decorators import login_required, permission_required +from django.contrib.admin.views.decorators import staff_member_required +from django.contrib.auth.decorators import login_required from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.db.models import Count from django.shortcuts import render @@ -20,7 +21,7 @@ def form(ctx, template, request): @login_required -@permission_required('perm') +@staff_member_required def index(request): revisions = Revision.objects.all().order_by( 'date_created').reverse().select_related('user').prefetch_related( @@ -39,7 +40,7 @@ def index(request): @login_required -@permission_required('perm') +@staff_member_required def stats_actions(request): stats = { 'Utilisateur': { diff --git a/med/context_processors.py b/med/context_processors.py index 040a070..880fd9b 100644 --- a/med/context_processors.py +++ b/med/context_processors.py @@ -1,17 +1,5 @@ -# -*- mode: python; coding: utf-8 -*- -# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay -# SPDX-License-Identifier: GPL-3.0-or-later - -from .settings import SITE_NAME - - def context_user(request): - user = request.user - is_perm = user.has_perms(['perm']) - is_bureau = user.has_perms(['bureau']) + is_perm = request.user.has_perms(['perm']) return { 'is_perm': is_perm, - 'is_bureau': is_bureau, - 'request_user': user, - 'site_name': SITE_NAME, } diff --git a/med/settings.py b/med/settings.py index 840e291..955fded 100644 --- a/med/settings.py +++ b/med/settings.py @@ -83,7 +83,6 @@ TEMPLATES = [ 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.request', - 'med.context_processors.context_user', ], }, }, diff --git a/med/templates/med/index.html b/med/templates/med/index.html deleted file mode 100644 index 95af05d..0000000 --- a/med/templates/med/index.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends "admin/base_site.html" %} -{% comment %} -SPDX-License-Identifier: GPL-3.0-or-later -{% endcomment %} - -{% load i18n static %} - -{% block title %}Base de donnée de la Mediatek{% endblock %} - -{% block extrastyle %} - {{ block.super }} - -{% endblock %} - -{% block coltype %}colMS{% endblock %} - -{% block bodyclass %}{{ block.super }} dashboard{% endblock %} - -{% block breadcrumbs %}{% endblock %} - -{% block content %} -
-

Bienvenue sur la base de données de la Mediatek.

-

Welcome to procrastination heaven !

-

- Le site va subir progressivement des mises à jour pendant ces vacances. - Si vous rencontrez des instabilités, - veuillez nous faire remonter les problèmes au webmaster. -

- Poulpy -
-{% endblock %} - -{% block sidebar %} - -{% endblock %} diff --git a/med/urls.py b/med/urls.py index b728fe8..68dcb48 100644 --- a/med/urls.py +++ b/med/urls.py @@ -5,16 +5,9 @@ from django.conf.urls import include, url from django.contrib import admin from django.contrib.auth.views import password_reset -from django.shortcuts import render from django.views.generic import RedirectView - -def index(request): - """ - Static home page - """ - return render(request, 'med/index.html', {}) - +from media.views import index urlpatterns = [ url(r'^$', index, name='index'), diff --git a/media/locale/fr/LC_MESSAGES/django.po b/media/locale/fr/LC_MESSAGES/django.po index 260d53d..ac3aad8 100644 --- a/media/locale/fr/LC_MESSAGES/django.po +++ b/media/locale/fr/LC_MESSAGES/django.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-08-02 14:47+0200\n" +"POT-Creation-Date: 2019-08-08 18:54+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -13,34 +13,106 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: models.py:13 +#: models.py:17 msgid "author" -msgstr "" +msgstr "auteur" -#: models.py:14 +#: models.py:18 msgid "authors" -msgstr "" +msgstr "auteurs" -#: models.py:26 +#: models.py:30 msgid "medium" -msgstr "" +msgstr "medium" -#: models.py:27 +#: models.py:31 msgid "media" -msgstr "" +msgstr "media" -#: models.py:44 +#: models.py:60 msgid "borrowed item" -msgstr "" +msgstr "emprunt" -#: models.py:45 +#: models.py:61 msgid "borrowed items" -msgstr "" +msgstr "emprunts" -#: models.py:68 +#: models.py:85 msgid "game" +msgstr "jeu" + +#: models.py:86 +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 "" -#: models.py:69 -msgid "games" +#: 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é." \ No newline at end of file diff --git a/media/templates/media/aff_auteurs.html b/media/templates/media/aff_auteurs.html index c3d0615..d81c5d1 100644 --- a/media/templates/media/aff_auteurs.html +++ b/media/templates/media/aff_auteurs.html @@ -1,25 +1,5 @@ {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} {% if auteurs_list.paginator %} @@ -37,14 +17,14 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ auteur.nom }} - {% if is_perm %} - - + {% if perms.media.change_auteur %} + + Éditer - - + {% endif %} + {% if perms.media.delete_auteur %} + + Supprimer {% endif %} diff --git a/media/templates/media/aff_emprunts.html b/media/templates/media/aff_emprunts.html index 43d49af..ee227c6 100644 --- a/media/templates/media/aff_emprunts.html +++ b/media/templates/media/aff_emprunts.html @@ -1,44 +1,24 @@ {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} {% if emprunts_list.paginator %} -{% include "pagination.html" with list=emprunts_list %} + {% include "pagination.html" with list=emprunts_list %} {% endif %} - - - - - - - - - - - - - {% for emprunt in emprunts_list %} +
MediaUtilisateurDate empruntPermanencier empruntDate renduPermanencier rendu
+ + + + + + + + + + + + {% for emprunt in emprunts_list %} - + + {% if perms.media.change_emprunt %} + Editer + {% endif %} + {% if perms.media.delete_emprunt %} + Supprimer + {% endif %} + - {% endfor %} -
MediaUtilisateurDate empruntPermanencier empruntDate renduPermanencier rendu
{{ emprunt.media }} @@ -46,23 +26,24 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ emprunt.date_emprunt }} {{ emprunt.permanencier_emprunt }}{% if not emprunt.date_rendu %}{% if is_perm %} Retour{% endif %}{% else %}{{ emprunt.date_rendu }}{% endif %} + {% if not emprunt.date_rendu %} + {% if perms.media.change_emprunt %} + Retour + {% endif %} + {% else %} + {{ emprunt.date_rendu }} + {% endif %} + {{ emprunt.permanencier_rendu }} - -
+ {% endfor %} + diff --git a/media/templates/media/aff_jeux.html b/media/templates/media/aff_jeux.html index 2d9e999..6cc3a9a 100644 --- a/media/templates/media/aff_jeux.html +++ b/media/templates/media/aff_jeux.html @@ -1,44 +1,24 @@ {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} {% if jeux_list.paginator %} -{% include "pagination.html" with list=jeux_list %} + {% include "pagination.html" with list=jeux_list %} {% endif %} - - - - - - - - - - - - - {% for jeu in jeux_list %} +
NomProprietaireDuréeJoueurs minJoueurs maxComment
+ + + + + + + + + + + + {% for jeu in jeux_list %} @@ -47,17 +27,17 @@ with this program; if not, write to the Free Software Foundation, Inc., - {% endfor %} -
NomProprietaireDuréeJoueurs minJoueurs maxComment
{{ jeu.nom }} {{ jeu.proprietaire }}{{ jeu.nombre_joueurs_max }} {{ jeu.comment }} - {% if is_perm %} - - + {% if perms.media.change_jeu %} + + Éditer - - + {% endif %} + {% if perms.media.delete_jeu %} + + Supprimer {% endif %}
+ {% endfor %} + diff --git a/media/templates/media/aff_medias.html b/media/templates/media/aff_medias.html index 28664b6..bca63da 100644 --- a/media/templates/media/aff_medias.html +++ b/media/templates/media/aff_medias.html @@ -1,25 +1,5 @@ {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} {% if medias_list.paginator %} @@ -41,14 +21,14 @@ with this program; if not, write to the Free Software Foundation, Inc., {% for aut in media.auteur.all %}{{ aut }}, {% endfor %} {{ media.cote }} - {% if is_perm %} - - + {% if perms.media.change_media %} + + Éditer - - + {% endif %} + {% if perms.media.delete_media %} + + Supprimer {% endif %} diff --git a/media/templates/media/delete.html b/media/templates/media/delete.html index 1ca4061..da24ea7 100644 --- a/media/templates/media/delete.html +++ b/media/templates/media/delete.html @@ -1,26 +1,6 @@ {% extends "media/sidebar.html" %} {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} {% load bootstrap3 %} @@ -28,13 +8,9 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}Création et modification de media{% endblock %} {% block content %} - -
- {% csrf_token %} -

Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?

- {% bootstrap_button "Confirmer" button_type="submit" icon="trash" %} -
-
-
-
+
+ {% csrf_token %} +

Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?

+ {% bootstrap_button "Confirmer" button_type="submit" icon="trash" %} +
{% endblock %} diff --git a/media/templates/media/index.html b/media/templates/media/index.html new file mode 100644 index 0000000..41d12c4 --- /dev/null +++ b/media/templates/media/index.html @@ -0,0 +1,81 @@ +{% extends "admin/base_site.html" %} +{% comment %} +SPDX-License-Identifier: GPL-3.0-or-later +{% endcomment %} + +{% load i18n static %} + +{% block title %}Base de donnée de la Mediatek{% endblock %} + +{% block extrastyle %} + {{ block.super }} + +{% endblock %} + +{% block coltype %}colMS{% endblock %} + +{% block bodyclass %}{{ block.super }} dashboard{% endblock %} + +{% block breadcrumbs %}{% endblock %} + +{% block content %} +
+

Bienvenue sur la base de données de la Mediatek.

+

Welcome to procrastination heaven !

+

+ Le site va subir progressivement des mises à jour pendant ces vacances. + Si vous rencontrez des instabilités, + veuillez nous faire remonter les problèmes au webmaster. +

+ Poulpy +
+{% endblock %} + +{% block sidebar %} + +{% endblock %} diff --git a/media/templates/media/index_auteurs.html b/media/templates/media/index_auteurs.html index fb8e304..a051707 100644 --- a/media/templates/media/index_auteurs.html +++ b/media/templates/media/index_auteurs.html @@ -1,39 +1,14 @@ {% extends "media/sidebar.html" %} {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} -{% load bootstrap3 %} - {% block title %}Auteurs{% endblock %} {% block content %} -

Liste des auteurs

- {% if is_perm %} - Ajouter un auteur - {% endif %} - {% include "media/aff_auteurs.html" with auteurs_list=auteurs_list %} -
-
-
+

Liste des auteurs

+ {% if perms.media.add_auteur %} + Ajouter un auteur + {% endif %} + {% include "media/aff_auteurs.html" with auteurs_list=auteurs_list %} {% endblock %} diff --git a/media/templates/media/index_emprunts.html b/media/templates/media/index_emprunts.html index 16fb9f9..39254af 100644 --- a/media/templates/media/index_emprunts.html +++ b/media/templates/media/index_emprunts.html @@ -1,36 +1,11 @@ {% extends "media/sidebar.html" %} {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} -{% load bootstrap3 %} - {% block title %}Emprunts{% endblock %} {% block content %}

Liste des emprunts

- {% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %} -
-
-
+ {% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %} {% endblock %} diff --git a/media/templates/media/index_jeux.html b/media/templates/media/index_jeux.html index 0c130c2..9aa09ce 100644 --- a/media/templates/media/index_jeux.html +++ b/media/templates/media/index_jeux.html @@ -1,39 +1,14 @@ {% extends "media/sidebar.html" %} {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} -{% load bootstrap3 %} - {% block title %}Jeux{% endblock %} {% block content %} -

Liste des jeux

- {% if is_perm %} - Ajouter un jeu - {% endif %} - {% include "media/aff_jeux.html" with jeux_list=jeux_list %} -
-
-
+

Liste des jeux

+ {% if perms.media.add_jeu %} + Ajouter un jeu + {% endif %} + {% include "media/aff_jeux.html" with jeux_list=jeux_list %} {% endblock %} diff --git a/media/templates/media/index_medias.html b/media/templates/media/index_medias.html index 4c7a4b0..2b681fe 100644 --- a/media/templates/media/index_medias.html +++ b/media/templates/media/index_medias.html @@ -1,39 +1,14 @@ {% extends "media/sidebar.html" %} {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} -{% load bootstrap3 %} - {% block title %}Media{% endblock %} {% block content %} -

Liste des medias

- {% if is_perm %} - Ajouter un media - {% endif %} - {% include "media/aff_medias.html" with medias_list=medias_list %} -
-
-
+

Liste des medias

+ {% if perms.media.add_media %} + Ajouter un media + {% endif %} + {% include "media/aff_medias.html" with medias_list=medias_list %} {% endblock %} diff --git a/media/templates/media/media.html b/media/templates/media/media.html index fd0de88..2ee600a 100644 --- a/media/templates/media/media.html +++ b/media/templates/media/media.html @@ -1,26 +1,6 @@ {% extends "media/sidebar.html" %} {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} {% load bootstrap3 %} @@ -28,15 +8,11 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}Création et modification de media{% endblock %} {% block content %} -{% bootstrap_form_errors mediaform %} + {% bootstrap_form_errors mediaform %} - -
- {% csrf_token %} - {% bootstrap_form mediaform %} - {% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %} -
-
-
-
+
+ {% csrf_token %} + {% bootstrap_form mediaform %} + {% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %} +
{% endblock %} diff --git a/media/templates/media/sidebar.html b/media/templates/media/sidebar.html index a63b8dc..880d56b 100644 --- a/media/templates/media/sidebar.html +++ b/media/templates/media/sidebar.html @@ -1,29 +1,8 @@ {% extends "base.html" %} {% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} - {% block sidebar %} diff --git a/media/urls.py b/media/urls.py index 61176b1..600fb3e 100644 --- a/media/urls.py +++ b/media/urls.py @@ -30,6 +30,5 @@ urlpatterns = [ name='edit-emprunt'), url(r'^del_emprunt/(?P[0-9]+)$', views.del_emprunt, name='del-emprunt'), - url(r'^index_emprunts/$', views.index, name='index'), - url(r'^$', views.index, name='index'), + url(r'^index_emprunts/$', views.index_emprunt, name='index'), ] diff --git a/media/views.py b/media/views.py index 1d19b33..f7a8927 100644 --- a/media/views.py +++ b/media/views.py @@ -38,7 +38,7 @@ def add_auteur(request): @login_required -@permission_required('media.edit_auteur') +@permission_required('media.change_auteur') def edit_auteur(request, auteurid): try: auteur_instance = Auteur.objects.get(pk=auteurid) @@ -90,7 +90,7 @@ def add_media(request): @login_required -@permission_required('media.edit_media') +@permission_required('media.change_media') def edit_media(request, mediaid): try: media_instance = Media.objects.get(pk=mediaid) @@ -142,7 +142,7 @@ def add_jeu(request): @login_required -@permission_required('media.edit_jeu') +@permission_required('media.change_jeu') def edit_jeu(request, jeuid): try: jeu_instance = Jeu.objects.get(pk=jeuid) @@ -209,7 +209,7 @@ def add_emprunt(request, userid): @login_required -@permission_required('media.edit_emprunt') +@permission_required('media.change_emprunt') def edit_emprunt(request, empruntid): try: emprunt_instance = Emprunt.objects.get(pk=empruntid) @@ -229,7 +229,7 @@ def edit_emprunt(request, empruntid): @login_required -@permission_required('media.edit_emprunt') +@permission_required('media.change_emprunt') def retour_emprunt(request, empruntid): try: emprunt_instance = Emprunt.objects.get(pk=empruntid) @@ -314,7 +314,7 @@ def index_medias(request): @login_required -def index(request): +def index_emprunt(request): if request.user.has_perms(['perm']): emprunts_list = Emprunt.objects.all() else: @@ -332,3 +332,17 @@ def index(request): emprunts_list = paginator.page(paginator.num_pages) return render(request, 'media/index_emprunts.html', {'emprunts_list': emprunts_list}) + + +def index(request): + """ + Home page with user's borrowed items + """ + if request.user.is_authenticated: + borrowed_items = Emprunt.objects.filter(user=request.user) + else: + borrowed_items = [] + + return render(request, 'media/index.html', { + 'borrowed_items': borrowed_items, + }) diff --git a/templates/base.html b/templates/base.html index 69e5e5b..7ceb4b5 100644 --- a/templates/base.html +++ b/templates/base.html @@ -29,120 +29,122 @@ with this program; if not, write to the Free Software Foundation, Inc., - - {# Load CSS and JavaScript #} - {% bootstrap_css %} + + {# Load CSS and JavaScript #} + {% bootstrap_css %} - {% bootstrap_javascript %} - - - {{ request.site.name }} : {% block title %}Accueil{% endblock %} - + {% bootstrap_javascript %} + + + {{ request.site.name }} : {% block title %}Accueil{% endblock %} + - -
- +
+
+ {# Display django.contrib.messages as Bootstrap alerts #} + {% bootstrap_messages %} -
-
-
-
-
- {% block sidebar %} - {% endblock %} -
+ {% block content %}{% endblock %} +
+
+
+ {% if user.is_authenticated %} +
+

{{ user.first_name }} {{ user.last_name }}

-
-
- {# Display django.contrib.messages as Bootstrap alerts #} - {% bootstrap_messages %} - - {% block content %}{% endblock %} -
-
-
- {% if request_user.is_authenticated %} -
-

{{ request_user.first_name }} {{ request_user.last_name }}

-
- - - - - - - - - - - - - -
Pseudo{{ request_user.username }}
Nom{{ request_user.last_name }}
Prénom{{ request_user.first_name }}
- {% else %} -

Vous n'êtes pas authentifié

- {% endif %} -
-
+ + + + + + + + + + + + + +
Pseudo{{ user.username }}
Nom{{ user.last_name }}
Prénom{{ user.first_name }}
+ {% else %} +

Vous n'êtes pas authentifié

+ {% endif %}
+
+
- + - {# Read the documentation for more information #} - +{# Read the documentation for more information #} + diff --git a/theme/templates/admin/base_site.html b/theme/templates/admin/base_site.html index 1199750..f8ee871 100644 --- a/theme/templates/admin/base_site.html +++ b/theme/templates/admin/base_site.html @@ -26,12 +26,13 @@ SPDX-License-Identifier: GPL-3.0-or-later {% endblock %} {% block userlinks %} {# Link to our apps outside of admin #} - {% trans 'My profile' %} / - Media / + {% trans 'Library' %} / {% if user.is_authenticated %} - {% if is_perm %} + {% if perms.users.add_user %} Nouveau utilisateur / + {% endif %} + {% if user.is_staff %} Statistiques / {% endif %} diff --git a/users/admin.py b/users/admin.py index 1d9121a..0fc53ff 100644 --- a/users/admin.py +++ b/users/admin.py @@ -7,17 +7,13 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from django.utils.translation import ugettext_lazy as _ from reversion.admin import VersionAdmin -from .models import Adhesion, Clef, ListRight, Request, Right, User +from .models import Adhesion, Clef, Request, User class RequestAdmin(admin.ModelAdmin): list_display = ('user', 'type', 'created_at', 'expires_at') -class RightAdmin(VersionAdmin): - list_display = ('user', 'right') - - class ClefAdmin(VersionAdmin): list_display = ('nom', 'proprio', 'commentaire') # TODO order by nom @@ -27,10 +23,6 @@ class AdhesionAdmin(VersionAdmin): list_display = ('annee_debut', 'annee_fin') -class ListRightAdmin(VersionAdmin): - list_display = ('listright',) - - class IsAdherentFilter(admin.SimpleListFilter): title = _('adherent status') parameter_name = 'is_adherent' @@ -44,7 +36,7 @@ class IsAdherentFilter(admin.SimpleListFilter): value = self.value() if value == 'Yes': # Get current membership year and list all members - last_adh_year = Adhesion.objects.all().order_by('annee_debut')\ + last_adh_year = Adhesion.objects.all().order_by('annee_debut') \ .reverse().first() return last_adh_year.adherent return queryset @@ -70,17 +62,20 @@ class UserAdmin(VersionAdmin, BaseUserAdmin): """ Get current membership year and check if user is there """ - last_adh_year = Adhesion.objects.all().order_by('annee_debut')\ + 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_adherent.boolean = True is_adherent.short_description = _('is adherent') + # 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 %}"> + admin.site.register(User, UserAdmin) admin.site.register(Request, RequestAdmin) -admin.site.register(ListRight, ListRightAdmin) -admin.site.register(Right, RightAdmin) admin.site.register(Adhesion, AdhesionAdmin) admin.site.register(Clef, ClefAdmin) diff --git a/users/models.py b/users/models.py index bb921bd..8d771f6 100644 --- a/users/models.py +++ b/users/models.py @@ -41,14 +41,6 @@ class User(AbstractUser): REQUIRED_FIELDS = ['first_name', 'last_name', 'email'] - def has_perms(self, perms, obj=None): - for perm in perms: - try: - Right.objects.get(user=self, right__listright=perm) - return True - except Right.DoesNotExist: - return False - @property def is_adherent(self): last_adh_year = Adhesion.objects.all().order_by( diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html deleted file mode 100644 index 709b605..0000000 --- a/users/templates/users/profil.html +++ /dev/null @@ -1,96 +0,0 @@ -{% extends "base.html" %} -{% comment %} -SPDX-License-Identifier: GPL-3.0-or-later -{% endcomment %} - -{% load bootstrap3 %} - -{% block title %}Profil{% endblock %} - -{% block content %} -

Compte

-
- - - Editer - - - - Changer le mot de passe - -
-

-
-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if list_droits %} - - {% else %} - - {% endif %} - - - - {% if user.is_active %} - - {% else %} - - {% endif %} - - - - - - {% if user.is_adherent %} - - {% else %} - - {% endif %} - {% if not user.is_adherent and is_bureau %} - - - {% endif %} - -
Prénom{{ user.first_name }}Nom{{ user.last_name }}
Pseudo{{ user.username }}E-mail{{ user.email }}
Commentaire{{ user.comment }}Date d'inscription{{ user.date_joined }}
Adresse{{ user.address }}Telephone{{ user.telephone }}
Emprunts maximums autorisés{{ user.maxemprunt }}Droits{% for droit in list_droits %}{{ droit.right }}{% if list_droits|length != forloop.counter %} - - {% endif %} {% endfor %}Aucun
StatutActifDésactivéDernière connexion{{ user.last_login }}
Adherent pour l'année en coursOuiNon Adhérer
-

Emprunts

- {% if is_perm or is_bureau %} -

Ajouter

- {% endif %} - {% if emprunts_list %} - {% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %} - {% else %} -

Aucun emprunt

- {% endif %} -{% endblock %} - diff --git a/users/templates/users/user.html b/users/templates/users/user.html index 66cd359..195f057 100644 --- a/users/templates/users/user.html +++ b/users/templates/users/user.html @@ -10,6 +10,9 @@ SPDX-License-Identifier: GPL-3.0-or-later {% block content %} {% bootstrap_form_errors userform %} + + Changer le mot de passe +
{% csrf_token %} {% bootstrap_form userform %} diff --git a/users/urls.py b/users/urls.py index 6ffef04..48f95fd 100644 --- a/users/urls.py +++ b/users/urls.py @@ -11,7 +11,6 @@ urlpatterns = [ url(r'^new_user/$', views.new_user, name='new-user'), url(r'^edit_info/$', views.edit_info, name='edit-info'), url(r'^password/$', views.password, name='password'), - url(r'^profil/$', views.profil, name='profil'), url(r'^adherer/(?P[0-9]+)$', views.adherer, name='adherer'), url(r'^process/(?P[a-z0-9]{32})/$', views.process, name='process'), ] diff --git a/users/views.py b/users/views.py index 18c4802..42a27a8 100644 --- a/users/views.py +++ b/users/views.py @@ -115,24 +115,6 @@ def password(request): return form({'userform': u_form}, 'users/user.html', request) -@login_required -def profil(request): - """ - Voir son profil - """ - emprunts_list = Emprunt.objects.filter(user=request.user) - list_droits = Right.objects.filter(user=request.user) - return render( - request, - 'users/profil.html', - { - 'user': request.user, - 'emprunts_list': emprunts_list, - 'list_droits': list_droits, - } - ) - - @login_required @permission_required('users.add_adhesion') def adherer(request, userid):