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
# 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': {

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):
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,
}

View File

@ -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',
],
},
},

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.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'),

View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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é."

View File

@ -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.,
<tr>
<td>{{ auteur.nom }}</td>
<td>
{% if is_perm %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer"
href="{% url 'media:edit-auteur' auteur.id %}">
<i class="glyphicon glyphicon-edit"></i>
{% if perms.media.change_auteur %}
<a class="btn btn-primary btn-sm" href="{% url 'media:edit-auteur' auteur.id %}">
Éditer
</a>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'media:del-auteur' auteur.id %}"
title="Supprimer">
<i class="glyphicon glyphicon-trash"></i>
{% endif %}
{% if perms.media.delete_auteur %}
<a class="btn btn-danger btn-sm" href="{% url 'media:del-auteur' auteur.id %}">
Supprimer
</a>
{% endif %}
</td>

View File

@ -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 %}
<table class="table table-striped">
<thead>
<tr>
<th>Media</th>
<th>Utilisateur</th>
<th>Date emprunt</th>
<th>Permanencier emprunt</th>
<th>Date rendu</th>
<th>Permanencier rendu</th>
<th></th>
</tr>
</thead>
{% for emprunt in emprunts_list %}
<table class="table table-striped">
<thead>
<tr>
<th>Media</th>
<th>Utilisateur</th>
<th>Date emprunt</th>
<th>Permanencier emprunt</th>
<th>Date rendu</th>
<th>Permanencier rendu</th>
<th></th>
</tr>
</thead>
{% for emprunt in emprunts_list %}
<tr>
<td>{{ emprunt.media }}</td>
<td>
@ -46,23 +26,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</td>
<td>{{ emprunt.date_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>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="editionemprunt" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Modifier
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="editionemprunt">
{% if is_perm %}
<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>
{% if perms.media.change_emprunt %}
<a href="{% url 'media:edit-emprunt' emprunt.id %}">Editer</a>
{% endif %}
{% if perms.media.delete_emprunt %}
<a href="{% url 'media:del-emprunt' emprunt.id %}">Supprimer</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</table>

View File

@ -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 %}
<table class="table table-striped">
<thead>
<tr>
<th>Nom</th>
<th>Proprietaire</th>
<th>Durée</th>
<th>Joueurs min</th>
<th>Joueurs max</th>
<th>Comment</th>
<th></th>
</tr>
</thead>
{% for jeu in jeux_list %}
<table class="table table-striped">
<thead>
<tr>
<th>Nom</th>
<th>Proprietaire</th>
<th>Durée</th>
<th>Joueurs min</th>
<th>Joueurs max</th>
<th>Comment</th>
<th></th>
</tr>
</thead>
{% for jeu in jeux_list %}
<tr>
<td>{{ jeu.nom }}</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.comment }}</td>
<td>
{% if is_perm %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer"
href="{% url 'media:edit-jeu' jeu.id %}">
<i class="glyphicon glyphicon-edit"></i>
{% if perms.media.change_jeu %}
<a class="btn btn-primary btn-sm" href="{% url 'media:edit-jeu' jeu.id %}">
Éditer
</a>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'media:del-jeu' jeu.id %}"
title="Supprimer">
<i class="glyphicon glyphicon-trash"></i>
{% endif %}
{% if perms.media.delete_jeu %}
<a class="btn btn-danger btn-sm" href="{% url 'media:del-jeu' jeu.id %}">
Supprimer
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</table>

View File

@ -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.,
<td>{% for aut in media.auteur.all %}{{ aut }}, {% endfor %}</td>
<td>{{ media.cote }}</td>
<td>
{% if is_perm %}
<a class="btn btn-primary btn-sm" role="button" title="Éditer"
href="{% url 'media:edit-media' media.id %}">
<i class="glyphicon glyphicon-edit"></i>
{% if perms.media.change_media %}
<a class="btn btn-primary btn-sm" href="{% url 'media:edit-media' media.id %}">
Éditer
</a>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'media:del-media' media.id %}"
title="Supprimer">
<i class="glyphicon glyphicon-trash"></i>
{% endif %}
{% if perms.media.delete_media %}
<a class="btn btn-danger btn-sm" href="{% url 'media:del-media' media.id %}">
Supprimer
</a>
{% endif %}
</td>

View File

@ -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 %}
<form class="form" method="post">
{% csrf_token %}
<h4>Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?</h4>
{% bootstrap_button "Confirmer" button_type="submit" icon="trash" %}
</form>
<br />
<br />
<br />
<form class="form" method="post">
{% csrf_token %}
<h4>Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?</h4>
{% bootstrap_button "Confirmer" button_type="submit" icon="trash" %}
</form>
{% 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" %}
{% 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 %}
<h2>Liste des auteurs</h2>
{% if is_perm %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-auteur' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un auteur</a>
{% endif %}
{% include "media/aff_auteurs.html" with auteurs_list=auteurs_list %}
<br />
<br />
<br />
<h2>Liste des auteurs</h2>
{% if perms.media.add_auteur %}
<a class="btn btn-primary btn-sm" href="{% url 'media:add-auteur' %}">Ajouter un auteur</a>
{% endif %}
{% include "media/aff_auteurs.html" with auteurs_list=auteurs_list %}
{% endblock %}

View File

@ -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 %}
<h2>Liste des emprunts</h2>
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
<br />
<br />
<br />
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
{% endblock %}

View File

@ -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 %}
<h2>Liste des jeux</h2>
{% if is_perm %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-jeu' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un jeu</a>
{% endif %}
{% include "media/aff_jeux.html" with jeux_list=jeux_list %}
<br />
<br />
<br />
<h2>Liste des jeux</h2>
{% if perms.media.add_jeu %}
<a class="btn btn-primary btn-sm" href="{% url 'media:add-jeu' %}">Ajouter un jeu</a>
{% endif %}
{% include "media/aff_jeux.html" with jeux_list=jeux_list %}
{% endblock %}

View File

@ -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 %}
<h2>Liste des medias</h2>
{% if is_perm %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-media' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un media</a>
{% endif %}
{% include "media/aff_medias.html" with medias_list=medias_list %}
<br />
<br />
<br />
<h2>Liste des medias</h2>
{% if perms.media.add_media %}
<a class="btn btn-primary btn-sm" href="{% url 'media:add-media' %}">Ajouter un media</a>
{% endif %}
{% include "media/aff_medias.html" with medias_list=medias_list %}
{% endblock %}

View File

@ -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 %}
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_form mediaform %}
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
</form>
<br />
<br />
<br />
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_form mediaform %}
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
</form>
{% endblock %}

View File

@ -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 %}
<a class="list-group-item list-group-item-info" href="{% url "media:index" %}">
<i class="glyphicon glyphicon-list"></i>

View File

@ -30,6 +30,5 @@ urlpatterns = [
name='edit-emprunt'),
url(r'^del_emprunt/(?P<empruntid>[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'),
]

View File

@ -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,
})

View File

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

View File

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

View File

@ -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(

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 %}
{% bootstrap_form_errors userform %}
<a href="{% url 'users:password' %}">
Changer le mot de passe
</a>
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_form userform %}

View File

@ -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<userid>[0-9]+)$', views.adherer, name='adherer'),
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)
@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):