Continue to remove old perm system

This commit is contained in:
Alexandre Iooss 2019-08-08 19:16:54 +02:00
parent deb28aa93b
commit d0086c84e8
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
28 changed files with 423 additions and 695 deletions

View File

@ -2,7 +2,8 @@
# 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.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.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db.models import Count from django.db.models import Count
from django.shortcuts import render from django.shortcuts import render
@ -20,7 +21,7 @@ def form(ctx, template, request):
@login_required @login_required
@permission_required('perm') @staff_member_required
def index(request): def index(request):
revisions = Revision.objects.all().order_by( revisions = Revision.objects.all().order_by(
'date_created').reverse().select_related('user').prefetch_related( 'date_created').reverse().select_related('user').prefetch_related(
@ -39,7 +40,7 @@ def index(request):
@login_required @login_required
@permission_required('perm') @staff_member_required
def stats_actions(request): def stats_actions(request):
stats = { stats = {
'Utilisateur': { 'Utilisateur': {

View File

@ -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): def context_user(request):
user = request.user is_perm = request.user.has_perms(['perm'])
is_perm = user.has_perms(['perm'])
is_bureau = user.has_perms(['bureau'])
return { return {
'is_perm': is_perm, 'is_perm': is_perm,
'is_bureau': is_bureau,
'request_user': user,
'site_name': SITE_NAME,
} }

View File

@ -83,7 +83,6 @@ TEMPLATES = [
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request', 'django.template.context_processors.request',
'med.context_processors.context_user',
], ],
}, },
}, },

View File

@ -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 }}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}"/>
{% endblock %}
{% block coltype %}colMS{% endblock %}
{% block bodyclass %}{{ block.super }} dashboard{% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block content %}
<div id="content-main">
<h1>Bienvenue sur la base de données de la Mediatek.</h1>
<h1>Welcome to procrastination heaven !</h1>
<p>
Le site va subir progressivement des mises à jour pendant ces vacances.
Si vous rencontrez des instabilités,
veuillez nous faire remonter les problèmes <a href="mailto:a@crans.org,club-med@crans.org">au webmaster</a>.
</p>
<img src="{% static "images/splash.png" %}" class="poulpy" alt="Poulpy">
</div>
{% endblock %}
{% block sidebar %}
<div id="content-related">
<div class="module" id="recent-actions-module">
{% if request_user.is_authenticated %}
<h2>{{ request_user.first_name }} {{ request_user.last_name }}</h2>
<h3>{% trans 'My profile' %}</h3>
<ul>
<li>{% trans 'username' %} : {{ request_user.username }}</li>
</ul>
{% else %}
<p>Vous n'êtes pas connecté.</p>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -5,16 +5,9 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
from django.contrib.auth.views import password_reset from django.contrib.auth.views import password_reset
from django.shortcuts import render
from django.views.generic import RedirectView from django.views.generic import RedirectView
from media.views import index
def index(request):
"""
Static home page
"""
return render(request, 'med/index.html', {})
urlpatterns = [ urlpatterns = [
url(r'^$', index, name='index'), url(r'^$', index, name='index'),

View File

@ -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-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" "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,34 +13,106 @@ 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"
#: models.py:13 #: models.py:17
msgid "author" msgid "author"
msgstr "" msgstr "auteur"
#: models.py:14 #: models.py:18
msgid "authors" msgid "authors"
msgstr "" msgstr "auteurs"
#: models.py:26 #: models.py:30
msgid "medium" msgid "medium"
msgstr "" msgstr "medium"
#: models.py:27 #: models.py:31
msgid "media" msgid "media"
msgstr "" msgstr "media"
#: models.py:44 #: models.py:60
msgid "borrowed item" msgid "borrowed item"
msgstr "" msgstr "emprunt"
#: models.py:45 #: models.py:61
msgid "borrowed items" msgid "borrowed items"
msgstr "" msgstr "emprunts"
#: models.py:68 #: models.py:85
msgid "game" 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 "" msgstr ""
#: models.py:69 #: templates/media/index.html:48
msgid "games" msgid "email"
msgstr "" 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é."

View File

@ -1,25 +1,5 @@
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% if auteurs_list.paginator %} {% if auteurs_list.paginator %}
@ -37,14 +17,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr> <tr>
<td>{{ auteur.nom }}</td> <td>{{ auteur.nom }}</td>
<td> <td>
{% if is_perm %} {% if perms.media.change_auteur %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer" <a class="btn btn-primary btn-sm" href="{% url 'media:edit-auteur' auteur.id %}">
href="{% url 'media:edit-auteur' auteur.id %}"> Éditer
<i class="glyphicon glyphicon-edit"></i>
</a> </a>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'media:del-auteur' auteur.id %}" {% endif %}
title="Supprimer"> {% if perms.media.delete_auteur %}
<i class="glyphicon glyphicon-trash"></i> <a class="btn btn-danger btn-sm" href="{% url 'media:del-auteur' auteur.id %}">
Supprimer
</a> </a>
{% endif %} {% endif %}
</td> </td>

View File

@ -1,44 +1,24 @@
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% if emprunts_list.paginator %} {% if emprunts_list.paginator %}
{% include "pagination.html" with list=emprunts_list %} {% include "pagination.html" with list=emprunts_list %}
{% endif %} {% endif %}
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>Media</th> <th>Media</th>
<th>Utilisateur</th> <th>Utilisateur</th>
<th>Date emprunt</th> <th>Date emprunt</th>
<th>Permanencier emprunt</th> <th>Permanencier emprunt</th>
<th>Date rendu</th> <th>Date rendu</th>
<th>Permanencier rendu</th> <th>Permanencier rendu</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
{% for emprunt in emprunts_list %} {% for emprunt in emprunts_list %}
<tr> <tr>
<td>{{ emprunt.media }}</td> <td>{{ emprunt.media }}</td>
<td> <td>
@ -46,23 +26,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</td> </td>
<td>{{ emprunt.date_emprunt }}</td> <td>{{ emprunt.date_emprunt }}</td>
<td>{{ emprunt.permanencier_emprunt }}</td> <td>{{ emprunt.permanencier_emprunt }}</td>
<td>{% if not emprunt.date_rendu %}{% if is_perm %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'media:retour-emprunt' emprunt.id %}"><i class="glyphicon glyphicon-ok"></i> Retour</a>{% endif %}{% else %}{{ emprunt.date_rendu }}{% endif %}</td> <td>
{% if not emprunt.date_rendu %}
{% if perms.media.change_emprunt %}
<a class="btn btn-primary btn-sm" href="{% url 'media:retour-emprunt' emprunt.id %}">Retour</a>
{% endif %}
{% else %}
{{ emprunt.date_rendu }}
{% endif %}
</td>
<td>{{ emprunt.permanencier_rendu }}</td> <td>{{ emprunt.permanencier_rendu }}</td>
<td> <td>
<div class="dropdown"> {% if perms.media.change_emprunt %}
<button class="btn btn-default dropdown-toggle" type="button" id="editionemprunt" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <a href="{% url 'media:edit-emprunt' emprunt.id %}">Editer</a>
Modifier {% endif %}
<span class="caret"></span> {% if perms.media.delete_emprunt %}
</button> <a href="{% url 'media:del-emprunt' emprunt.id %}">Supprimer</a>
<ul class="dropdown-menu" aria-labelledby="editionemprunt"> {% endif %}
{% if is_perm %} </td>
<li><a href="{% url 'media:edit-emprunt' emprunt.id %}"><i class="glyphicon glyphicon-edit"></i> Editer</a></li>
<li><a href="{% url 'media:del-emprunt' emprunt.id %}"><i class="glyphicon glyphicon-trash"></i> Supprimer</a></li>
{% endif %}
<li><a href="{% url 'media:history' 'emprunt' emprunt.id %}"><i class="glyphicon glyphicon-time"></i> Historique</a></li>
</ul>
</div>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@ -1,44 +1,24 @@
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% if jeux_list.paginator %} {% if jeux_list.paginator %}
{% include "pagination.html" with list=jeux_list %} {% include "pagination.html" with list=jeux_list %}
{% endif %} {% endif %}
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>Nom</th> <th>Nom</th>
<th>Proprietaire</th> <th>Proprietaire</th>
<th>Durée</th> <th>Durée</th>
<th>Joueurs min</th> <th>Joueurs min</th>
<th>Joueurs max</th> <th>Joueurs max</th>
<th>Comment</th> <th>Comment</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
{% for jeu in jeux_list %} {% for jeu in jeux_list %}
<tr> <tr>
<td>{{ jeu.nom }}</td> <td>{{ jeu.nom }}</td>
<td>{{ jeu.proprietaire }}</td> <td>{{ jeu.proprietaire }}</td>
@ -47,17 +27,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ jeu.nombre_joueurs_max }}</td> <td>{{ jeu.nombre_joueurs_max }}</td>
<td>{{ jeu.comment }}</td> <td>{{ jeu.comment }}</td>
<td> <td>
{% if is_perm %} {% if perms.media.change_jeu %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer" <a class="btn btn-primary btn-sm" href="{% url 'media:edit-jeu' jeu.id %}">
href="{% url 'media:edit-jeu' jeu.id %}"> Éditer
<i class="glyphicon glyphicon-edit"></i>
</a> </a>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'media:del-jeu' jeu.id %}" {% endif %}
title="Supprimer"> {% if perms.media.delete_jeu %}
<i class="glyphicon glyphicon-trash"></i> <a class="btn btn-danger btn-sm" href="{% url 'media:del-jeu' jeu.id %}">
Supprimer
</a> </a>
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@ -1,25 +1,5 @@
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% if medias_list.paginator %} {% if medias_list.paginator %}
@ -41,14 +21,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{% for aut in media.auteur.all %}{{ aut }}, {% endfor %}</td> <td>{% for aut in media.auteur.all %}{{ aut }}, {% endfor %}</td>
<td>{{ media.cote }}</td> <td>{{ media.cote }}</td>
<td> <td>
{% if is_perm %} {% if perms.media.change_media %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer" <a class="btn btn-primary btn-sm" href="{% url 'media:edit-media' media.id %}">
href="{% url 'media:edit-media' media.id %}"> Éditer
<i class="glyphicon glyphicon-edit"></i>
</a> </a>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'media:del-media' media.id %}" {% endif %}
title="Supprimer"> {% if perms.media.delete_media %}
<i class="glyphicon glyphicon-trash"></i> <a class="btn btn-danger btn-sm" href="{% url 'media:del-media' media.id %}">
Supprimer
</a> </a>
{% endif %} {% endif %}
</td> </td>

View File

@ -1,26 +1,6 @@
{% extends "media/sidebar.html" %} {% extends "media/sidebar.html" %}
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% load bootstrap3 %} {% 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 title %}Création et modification de media{% endblock %}
{% block content %} {% block content %}
<form class="form" method="post">
<form class="form" method="post"> {% csrf_token %}
{% csrf_token %} <h4>Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?</h4>
<h4>Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?</h4> {% bootstrap_button "Confirmer" button_type="submit" icon="trash" %}
{% bootstrap_button "Confirmer" button_type="submit" icon="trash" %} </form>
</form>
<br />
<br />
<br />
{% endblock %} {% endblock %}

View File

@ -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 }}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}"/>
{% endblock %}
{% block coltype %}colMS{% endblock %}
{% block bodyclass %}{{ block.super }} dashboard{% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block content %}
<div id="content-main">
<h1>Bienvenue sur la base de données de la Mediatek.</h1>
<h1>Welcome to procrastination heaven !</h1>
<p>
Le site va subir progressivement des mises à jour pendant ces vacances.
Si vous rencontrez des instabilités,
veuillez nous faire remonter les problèmes <a href="mailto:a@crans.org,club-med@crans.org">au webmaster</a>.
</p>
<img src="{% static "images/splash.png" %}" class="poulpy" alt="Poulpy">
</div>
{% endblock %}
{% block sidebar %}
<div id="content-related">
<div class="module" id="recent-actions-module">
{% if user.is_authenticated %}
<h2>{{ user.first_name }} {{ user.last_name }}</h2>
<h3>
{% trans 'My profile' %}
<small><a class="changelink" href="{% url 'users:edit-info' %}">
{% trans 'Edit' %}
</a></small>
</h3>
<ul>
<li><strong>{% trans 'username' %}</strong> : {{ user.username }}</li>
<li><strong>{% trans 'email' %}</strong> : {{ user.email }}</li>
<li><strong>{% trans 'comment' %}</strong> : {{ user.comment }}</li>
<li><strong>{% trans 'date joined' %}</strong> : {{ user.date_joined }}</li>
<li><strong>{% trans 'last login' %}</strong> : {{ user.last_login }}</li>
<li><strong>{% trans 'address' %}</strong> : {{ user.address }}</li>
<li><strong>{% trans 'phone number' %}</strong> : {{ user.telephone }}</li>
<li><strong>{% trans 'groups' %}</strong> : {% for g in user.groups.all %}{{ g.name }} {% endfor %}</li>
<li><strong>{% trans 'maximum borrowed' %}</strong> : {{ user.maxemprunt }}</li>
<li>
<strong>{% trans 'membership for current year' %}</strong> :
{% if user.is_adherent %}
<span style="color:green">{% trans 'yes' %}</span>
{% else %}
<span style="color:red">{% trans 'no' %}</span>
{% endif %}
</li>
</ul>
<h3>{% trans 'Current borrowed items' %}</h3>
{% if borrowed_items %}
<ul>
{% for emprunt in borrowed_items %}
<li>{{ emprunt.media }} ({% trans 'since' %} {{ emprunt.date_emprunt }})</li>
{% endfor %}
</ul>
{% else %}
<p>{% trans 'No current borrowed items.' %}</p>
{% endif %}
{% else %}
<p>{% trans 'You are not logged in.' %}</p>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -1,39 +1,14 @@
{% extends "media/sidebar.html" %} {% extends "media/sidebar.html" %}
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% load bootstrap3 %}
{% block title %}Auteurs{% endblock %} {% block title %}Auteurs{% endblock %}
{% block content %} {% block content %}
<h2>Liste des auteurs</h2> <h2>Liste des auteurs</h2>
{% if is_perm %} {% if perms.media.add_auteur %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-auteur' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un auteur</a> <a class="btn btn-primary btn-sm" href="{% url 'media:add-auteur' %}">Ajouter un auteur</a>
{% endif %} {% endif %}
{% include "media/aff_auteurs.html" with auteurs_list=auteurs_list %} {% include "media/aff_auteurs.html" with auteurs_list=auteurs_list %}
<br />
<br />
<br />
{% endblock %} {% endblock %}

View File

@ -1,36 +1,11 @@
{% extends "media/sidebar.html" %} {% extends "media/sidebar.html" %}
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% load bootstrap3 %}
{% block title %}Emprunts{% endblock %} {% block title %}Emprunts{% endblock %}
{% block content %} {% block content %}
<h2>Liste des emprunts</h2> <h2>Liste des emprunts</h2>
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %} {% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
<br />
<br />
<br />
{% endblock %} {% endblock %}

View File

@ -1,39 +1,14 @@
{% extends "media/sidebar.html" %} {% extends "media/sidebar.html" %}
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% load bootstrap3 %}
{% block title %}Jeux{% endblock %} {% block title %}Jeux{% endblock %}
{% block content %} {% block content %}
<h2>Liste des jeux</h2> <h2>Liste des jeux</h2>
{% if is_perm %} {% if perms.media.add_jeu %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-jeu' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un jeu</a> <a class="btn btn-primary btn-sm" href="{% url 'media:add-jeu' %}">Ajouter un jeu</a>
{% endif %} {% endif %}
{% include "media/aff_jeux.html" with jeux_list=jeux_list %} {% include "media/aff_jeux.html" with jeux_list=jeux_list %}
<br />
<br />
<br />
{% endblock %} {% endblock %}

View File

@ -1,39 +1,14 @@
{% extends "media/sidebar.html" %} {% extends "media/sidebar.html" %}
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% load bootstrap3 %}
{% block title %}Media{% endblock %} {% block title %}Media{% endblock %}
{% block content %} {% block content %}
<h2>Liste des medias</h2> <h2>Liste des medias</h2>
{% if is_perm %} {% if perms.media.add_media %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-media' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un media</a> <a class="btn btn-primary btn-sm" href="{% url 'media:add-media' %}">Ajouter un media</a>
{% endif %} {% endif %}
{% include "media/aff_medias.html" with medias_list=medias_list %} {% include "media/aff_medias.html" with medias_list=medias_list %}
<br />
<br />
<br />
{% endblock %} {% endblock %}

View File

@ -1,26 +1,6 @@
{% extends "media/sidebar.html" %} {% extends "media/sidebar.html" %}
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% load bootstrap3 %} {% 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 title %}Création et modification de media{% endblock %}
{% block content %} {% block content %}
{% bootstrap_form_errors mediaform %} {% bootstrap_form_errors mediaform %}
<form class="form" method="post">
<form class="form" method="post"> {% csrf_token %}
{% csrf_token %} {% bootstrap_form mediaform %}
{% bootstrap_form mediaform %} {% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %} </form>
</form>
<br />
<br />
<br />
{% endblock %} {% endblock %}

View File

@ -1,29 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% comment %} {% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il SPDX-License-Identifier: GPL-3.0-or-later
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.
{% endcomment %} {% endcomment %}
{% block sidebar %} {% block sidebar %}
<a class="list-group-item list-group-item-info" href="{% url "media:index" %}"> <a class="list-group-item list-group-item-info" href="{% url "media:index" %}">
<i class="glyphicon glyphicon-list"></i> <i class="glyphicon glyphicon-list"></i>

View File

@ -30,6 +30,5 @@ urlpatterns = [
name='edit-emprunt'), name='edit-emprunt'),
url(r'^del_emprunt/(?P<empruntid>[0-9]+)$', views.del_emprunt, url(r'^del_emprunt/(?P<empruntid>[0-9]+)$', views.del_emprunt,
name='del-emprunt'), name='del-emprunt'),
url(r'^index_emprunts/$', views.index, name='index'), url(r'^index_emprunts/$', views.index_emprunt, name='index'),
url(r'^$', views.index, name='index'),
] ]

View File

@ -38,7 +38,7 @@ def add_auteur(request):
@login_required @login_required
@permission_required('media.edit_auteur') @permission_required('media.change_auteur')
def edit_auteur(request, auteurid): def edit_auteur(request, auteurid):
try: try:
auteur_instance = Auteur.objects.get(pk=auteurid) auteur_instance = Auteur.objects.get(pk=auteurid)
@ -90,7 +90,7 @@ def add_media(request):
@login_required @login_required
@permission_required('media.edit_media') @permission_required('media.change_media')
def edit_media(request, mediaid): def edit_media(request, mediaid):
try: try:
media_instance = Media.objects.get(pk=mediaid) media_instance = Media.objects.get(pk=mediaid)
@ -142,7 +142,7 @@ def add_jeu(request):
@login_required @login_required
@permission_required('media.edit_jeu') @permission_required('media.change_jeu')
def edit_jeu(request, jeuid): def edit_jeu(request, jeuid):
try: try:
jeu_instance = Jeu.objects.get(pk=jeuid) jeu_instance = Jeu.objects.get(pk=jeuid)
@ -209,7 +209,7 @@ def add_emprunt(request, userid):
@login_required @login_required
@permission_required('media.edit_emprunt') @permission_required('media.change_emprunt')
def edit_emprunt(request, empruntid): def edit_emprunt(request, empruntid):
try: try:
emprunt_instance = Emprunt.objects.get(pk=empruntid) emprunt_instance = Emprunt.objects.get(pk=empruntid)
@ -229,7 +229,7 @@ def edit_emprunt(request, empruntid):
@login_required @login_required
@permission_required('media.edit_emprunt') @permission_required('media.change_emprunt')
def retour_emprunt(request, empruntid): def retour_emprunt(request, empruntid):
try: try:
emprunt_instance = Emprunt.objects.get(pk=empruntid) emprunt_instance = Emprunt.objects.get(pk=empruntid)
@ -314,7 +314,7 @@ def index_medias(request):
@login_required @login_required
def index(request): def index_emprunt(request):
if request.user.has_perms(['perm']): if request.user.has_perms(['perm']):
emprunts_list = Emprunt.objects.all() emprunts_list = Emprunt.objects.all()
else: else:
@ -332,3 +332,17 @@ def index(request):
emprunts_list = paginator.page(paginator.num_pages) emprunts_list = paginator.page(paginator.num_pages)
return render(request, 'media/index_emprunts.html', return render(request, 'media/index_emprunts.html',
{'emprunts_list': emprunts_list}) {'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,
})

View File

@ -29,120 +29,122 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
{# Load CSS and JavaScript #} {# Load CSS and JavaScript #}
{% bootstrap_css %} {% bootstrap_css %}
{% bootstrap_javascript %} {% bootstrap_javascript %}
<link rel="stylesheet" href="{% static "/css/base.css" %}"> <link rel="stylesheet" href="{% static "/css/base.css" %}">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ request.site.name }} : {% block title %}Accueil{% endblock %}</title> <title>{{ request.site.name }} : {% block title %}Accueil{% endblock %}</title>
</head> </head>
<body> <body>
<div id="wrap"> <div id="wrap">
<nav class="navbar navbar-inverse"> <nav class="navbar navbar-inverse">
<div class="container-fluid"> <div class="container-fluid">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="/">{{ request.site.name }}</a> <a class="navbar-brand" href="/">{{ request.site.name }}</a>
</div> </div>
<div class="collapse navbar-collapse" id="myNavbar"> <div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="{% url "users:profil" %}">Mon profil</a></li> {% if perms.users.add_user %}
{% if is_perm %} <li><a href="{% url "users:new-user" %}">Utilisateurs</a></li>
<li><a href="{% url "users:new-user" %}">Utilisateurs</a></li> {% endif %}
{% endif %} <li><a href="{% url "media:index" %}">Media</a></li>
<li><a href="{% url "media:index" %}">Media</a></li> {% if user.is_staff %}
{% if is_perm %} <li><a href="{% url "logs:index" %}">Statistiques</a></li>
<li><a href="{% url "logs:index" %}">Statistiques</a></li> {% endif %}
{% endif %} </ul>
</ul> <div class="col-sm-3 col-md-3 navbar-right">
<div class="col-sm-3 col-md-3 navbar-right"> <form action="{% url "search:search" %}" method="POST" class="navbar-form" role="search">
<form action="{% url "search:search"%}" method="POST" class="navbar-form" role="search"> {% csrf_token %}
{% csrf_token %} <div class="input-group">
<div class="input-group"> <input type="text" class="form-control" placeholder="Search" name="search_field"
<input type="text" class="form-control" placeholder="Search" name="search_field" id="search-term"> id="search-term">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button> <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i>
<a href="{% url "search:searchp" %}" class="btn btn-default" role="button"><i class="glyphicon glyphicon-plus"></i></a> </button>
</div> <a href="{% url "search:searchp" %}" class="btn btn-default" role="button"><i
</div> class="glyphicon glyphicon-plus"></i></a>
</form> </div>
</div> </div>
<ul class="nav navbar-nav navbar-right"> </form>
<li> </div>
{% if request.user.is_authenticated %} <ul class="nav navbar-nav navbar-right">
<a href="{% url 'logout' %}"> <li>
<span class="glyphicon glyphicon-log-out"></span> Logout {% if user.is_authenticated %}
</a> <a href="{% url 'logout' %}">
{% else %} <span class="glyphicon glyphicon-log-out"></span> Logout
<a href="{% url 'login' %}"> </a>
<span class="glyphicon glyphicon-log-in"></span> Login {% else %}
</a> <a href="{% url 'login' %}">
{% endif %} <span class="glyphicon glyphicon-log-in"></span> Login
</li> </a>
</ul> {% endif %}
</li>
</ul>
</div>
</div>
</nav>
<div id="main" class="container-fluid text-center">
<div class="row content">
<div class="col-sm-2 sidenav">
<div class="panel panel-default">
<div class="text-left list-group">
{% block sidebar %}
{% endblock %}
</div> </div>
</div> </div>
</nav> </div>
<div class="col-sm-8 text-left">
{# Display django.contrib.messages as Bootstrap alerts #}
{% bootstrap_messages %}
<div id="main" class="container-fluid text-center"> {% block content %}{% endblock %}
<div class="row content"> </div>
<div class="col-sm-2 sidenav"> <div class="col-sm-2 sidenav">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="text-left list-group"> {% if user.is_authenticated %}
{% block sidebar %} <div class="panel-heading">
{% endblock %} <h4>{{ user.first_name }} {{ user.last_name }}</h4>
</div>
</div> </div>
</div> <table class="table">
<div class="col-sm-8 text-left"> <tr>
{# Display django.contrib.messages as Bootstrap alerts #} <th scope="row">Pseudo</th>
{% bootstrap_messages %} <td class="text-right">{{ user.username }}</td>
</tr>
{% block content %}{% endblock %} <tr>
</div> <th scope="row">Nom</th>
<div class="col-sm-2 sidenav"> <td class="text-right">{{ user.last_name }}</td>
<div class="panel panel-default"> </tr>
{% if request_user.is_authenticated %} <tr>
<div class="panel-heading"> <th scope="row">Prénom</th>
<h4>{{ request_user.first_name }} {{ request_user.last_name }}</h4> <td class="text-right">{{ user.first_name }}</td>
</div> </tr>
<table class="table"> </table>
<tr> {% else %}
<th scope="row">Pseudo</th> <p>Vous n'êtes pas authentifié</p>
<td class="text-right">{{ request_user.username }}</td> {% endif %}
</tr>
<tr>
<th scope="row">Nom</th>
<td class="text-right">{{ request_user.last_name }}</td>
</tr>
<tr>
<th scope="row">Prénom</th>
<td class="text-right">{{ request_user.first_name }}</td>
</tr>
</table>
{% else %}
<p>Vous n'êtes pas authentifié</p>
{% endif %}
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
<footer class="navbar"> <footer class="navbar">
<div class="container-fluid text-center"> <div class="container-fluid text-center">
<p>Mediatek 2017-2020 &mdash; <a href="mailto:club-med@crans.org">Nous contactez</a></p> <p>Mediatek 2017-2020 &mdash; <a href="mailto:club-med@crans.org">Nous contactez</a></p>
</div> </div>
</footer> </footer>
{# Read the documentation for more information #} {# Read the documentation for more information #}
</body> </body>
</html> </html>

View File

@ -26,12 +26,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endblock %} {% endblock %}
{% block userlinks %} {% block userlinks %}
{# Link to our apps outside of admin #} {# Link to our apps outside of admin #}
<a href="{% url "users:profil" %}">{% trans 'My profile' %}</a> / <a href="{% url "media:index" %}">{% trans 'Library' %}</a> /
<a href="{% url "media:index" %}">Media</a> /
{% if user.is_authenticated %} {% if user.is_authenticated %}
{% if is_perm %} {% if perms.users.add_user %}
<a href="{% url "users:new-user" %}">Nouveau utilisateur</a> / <a href="{% url "users:new-user" %}">Nouveau utilisateur</a> /
{% endif %}
{% if user.is_staff %}
<a href="{% url "logs:index" %}">Statistiques</a> / <a href="{% url "logs:index" %}">Statistiques</a> /
{% endif %} {% endif %}

View File

@ -7,17 +7,13 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
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 .models import Adhesion, Clef, ListRight, Request, Right, User from .models import Adhesion, Clef, Request, User
class RequestAdmin(admin.ModelAdmin): class RequestAdmin(admin.ModelAdmin):
list_display = ('user', 'type', 'created_at', 'expires_at') list_display = ('user', 'type', 'created_at', 'expires_at')
class RightAdmin(VersionAdmin):
list_display = ('user', 'right')
class ClefAdmin(VersionAdmin): class ClefAdmin(VersionAdmin):
list_display = ('nom', 'proprio', 'commentaire') list_display = ('nom', 'proprio', 'commentaire')
# TODO order by nom # TODO order by nom
@ -27,10 +23,6 @@ class AdhesionAdmin(VersionAdmin):
list_display = ('annee_debut', 'annee_fin') list_display = ('annee_debut', 'annee_fin')
class ListRightAdmin(VersionAdmin):
list_display = ('listright',)
class IsAdherentFilter(admin.SimpleListFilter): class IsAdherentFilter(admin.SimpleListFilter):
title = _('adherent status') title = _('adherent status')
parameter_name = 'is_adherent' parameter_name = 'is_adherent'
@ -44,7 +36,7 @@ class IsAdherentFilter(admin.SimpleListFilter):
value = self.value() value = self.value()
if value == 'Yes': if value == 'Yes':
# Get current membership year and list all members # 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() .reverse().first()
return last_adh_year.adherent return last_adh_year.adherent
return queryset return queryset
@ -70,17 +62,20 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
""" """
Get current membership year and check if user is there 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() .reverse().first()
return last_adh_year and obj in last_adh_year.adherent.all() return last_adh_year and obj in last_adh_year.adherent.all()
is_adherent.boolean = True is_adherent.boolean = True
is_adherent.short_description = _('is adherent') 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(User, UserAdmin)
admin.site.register(Request, RequestAdmin) admin.site.register(Request, RequestAdmin)
admin.site.register(ListRight, ListRightAdmin)
admin.site.register(Right, RightAdmin)
admin.site.register(Adhesion, AdhesionAdmin) admin.site.register(Adhesion, AdhesionAdmin)
admin.site.register(Clef, ClefAdmin) admin.site.register(Clef, ClefAdmin)

View File

@ -41,14 +41,6 @@ class User(AbstractUser):
REQUIRED_FIELDS = ['first_name', 'last_name', 'email'] 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 @property
def is_adherent(self): def is_adherent(self):
last_adh_year = Adhesion.objects.all().order_by( last_adh_year = Adhesion.objects.all().order_by(

View File

@ -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 %}
<h2>Compte</h2>
<div>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' %}">
<i class="glyphicon glyphicon-edit"></i>
Editer
</a>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:password' %}">
<i class="glyphicon glyphicon-lock"></i>
Changer le mot de passe
</a>
</div>
<p>
<br/>
</p>
<table class="table table-striped">
<tr>
<th>Prénom</th>
<td>{{ user.first_name }}</td>
<th>Nom</th>
<td>{{ user.last_name }}</td>
</tr>
<tr>
<th>Pseudo</th>
<td>{{ user.username }}</td>
<th>E-mail</th>
<td>{{ user.email }}</td>
</tr>
<tr>
<th>Commentaire</th>
<td>{{ user.comment }}</td>
<th>Date d'inscription</th>
<td>{{ user.date_joined }}</td>
</tr>
<tr>
<th>Adresse</th>
<td>{{ user.address }}</td>
<th>Telephone</th>
<td>{{ user.telephone }}</td>
</tr>
<tr>
<th>Emprunts maximums autorisés</th>
<td>{{ user.maxemprunt }}</td>
<th>Droits</th>
{% if list_droits %}
<td>{% for droit in list_droits %}{{ droit.right }}{% if list_droits|length != forloop.counter %} -
{% endif %} {% endfor %}</td>
{% else %}
<td>Aucun</td>
{% endif %}
</tr>
<tr>
<th>Statut</th>
{% if user.is_active %}
<td><font color="green">Actif</font></td>
{% else %}
<td><font color="red">Désactivé</font></td>
{% endif %}
<th>Dernière connexion</th>
<td>{{ user.last_login }}</td>
</tr>
<tr>
<th>Adherent pour l'année en cours</th>
{% if user.is_adherent %}
<td><font color="green">Oui</font></td>
{% else %}
<td><font color="red">Non</font></td>
{% endif %}
{% if not user.is_adherent and is_bureau %}
<th></th>
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'users:adherer' user.id %}"><i
class="glyphicon glyphicon-flag"></i> Adhérer</a></td>
{% endif %}
</tr>
</table>
<h2>Emprunts</h2>
{% if is_perm or is_bureau %}
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-emprunt' user.id %}"><i
class="glyphicon glyphicon-flag"></i> Ajouter</a></h4>
{% endif %}
{% if emprunts_list %}
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
{% else %}
<p>Aucun emprunt</p>
{% endif %}
{% endblock %}

View File

@ -10,6 +10,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% block content %} {% block content %}
{% bootstrap_form_errors userform %} {% bootstrap_form_errors userform %}
<a href="{% url 'users:password' %}">
Changer le mot de passe
</a>
<form class="form" method="post"> <form class="form" method="post">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form userform %} {% bootstrap_form userform %}

View File

@ -11,7 +11,6 @@ urlpatterns = [
url(r'^new_user/$', views.new_user, name='new-user'), url(r'^new_user/$', views.new_user, name='new-user'),
url(r'^edit_info/$', views.edit_info, name='edit-info'), url(r'^edit_info/$', views.edit_info, name='edit-info'),
url(r'^password/$', views.password, name='password'), url(r'^password/$', views.password, name='password'),
url(r'^profil/$', views.profil, name='profil'),
url(r'^adherer/(?P<userid>[0-9]+)$', views.adherer, name='adherer'), url(r'^adherer/(?P<userid>[0-9]+)$', views.adherer, name='adherer'),
url(r'^process/(?P<token>[a-z0-9]{32})/$', views.process, name='process'), url(r'^process/(?P<token>[a-z0-9]{32})/$', views.process, name='process'),
] ]

View File

@ -115,24 +115,6 @@ def password(request):
return form({'userform': u_form}, 'users/user.html', 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 @login_required
@permission_required('users.add_adhesion') @permission_required('users.add_adhesion')
def adherer(request, userid): def adherer(request, userid):