Commit deb28aa9 authored by erdnaxe's avatar erdnaxe 🎇

Change media permissions

parent 8a1af4c2
......@@ -17,11 +17,15 @@ class MediaAdmin(VersionAdmin):
class EmpruntAdmin(VersionAdmin):
list_display = ('media', 'user', 'date_emprunt', 'date_rendu', 'permanencier_emprunt', 'permanencier_rendu')
list_display = (
'media', 'user', 'date_emprunt', 'date_rendu', 'permanencier_emprunt',
'permanencier_rendu')
class JeuAdmin(VersionAdmin):
list_display = ('nom', 'proprietaire', 'duree', 'nombre_joueurs_min', 'nombre_joueurs_max', 'comment')
list_display = (
'nom', 'proprietaire', 'duree', 'nombre_joueurs_min', 'nombre_joueurs_max',
'comment')
admin.site.register(Auteur, AuteurAdmin)
......
......@@ -15,7 +15,9 @@ class AuteurForm(ModelForm):
class MediaForm(ModelForm):
auteur = forms.ModelMultipleChoiceField(Auteur.objects.all(), widget=forms.CheckboxSelectMultiple, required=False)
auteur = forms.ModelMultipleChoiceField(Auteur.objects.all(),
widget=forms.CheckboxSelectMultiple,
required=False)
class Meta:
model = Media
......@@ -28,7 +30,8 @@ class JeuForm(ModelForm):
fields = '__all__'
def clean_nombre_joueurs_max(self):
if self.cleaned_data['nombre_joueurs_max'] < self.cleaned_data['nombre_joueurs_min']:
if self.cleaned_data['nombre_joueurs_max'] < self.cleaned_data[
'nombre_joueurs_min']:
raise forms.ValidationError("Max ne peut être inférieur à min")
return self.cleaned_data['nombre_joueurs_max']
......@@ -42,4 +45,5 @@ class EmpruntForm(ModelForm):
class EditEmpruntForm(ModelForm):
class Meta:
model = Emprunt
fields = ['media', 'permanencier_emprunt', 'permanencier_rendu', 'date_rendu']
fields = ['media', 'permanencier_emprunt', 'permanencier_rendu',
'date_rendu']
......@@ -35,11 +35,23 @@ class Emprunt(models.Model):
media = models.ForeignKey('Media', on_delete=models.PROTECT)
user = models.ForeignKey('users.User', on_delete=models.PROTECT)
date_emprunt = models.DateTimeField(help_text='%d/%m/%y %H:%M:%S')
date_rendu = models.DateTimeField(help_text='%d/%m/%y %H:%M:%S', blank=True, null=True)
permanencier_emprunt = models.ForeignKey('users.User', on_delete=models.PROTECT,
related_name='user_permanencier_emprunt')
permanencier_rendu = models.ForeignKey('users.User', on_delete=models.PROTECT,
related_name='user_permanencier_rendu', blank=True, null=True)
date_rendu = models.DateTimeField(
help_text='%d/%m/%y %H:%M:%S',
blank=True,
null=True,
)
permanencier_emprunt = models.ForeignKey(
'users.User',
on_delete=models.PROTECT,
related_name='user_permanencier_emprunt',
)
permanencier_rendu = models.ForeignKey(
'users.User',
on_delete=models.PROTECT,
related_name='user_permanencier_rendu',
blank=True,
null=True,
)
def __str__(self):
return str(self.media) + str(self.user)
......@@ -63,7 +75,8 @@ class Jeu(models.Model):
duree = models.CharField(choices=DUREE, max_length=255)
nombre_joueurs_min = models.IntegerField(validators=[MinValueValidator(1)])
nombre_joueurs_max = models.IntegerField(validators=[MinValueValidator(1)])
comment = models.CharField(help_text="Commentaire", max_length=255, blank=True, null=True)
comment = models.CharField(help_text="Commentaire", max_length=255,
blank=True, null=True)
def __str__(self):
return str(self.nom)
......
......@@ -23,22 +23,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% if auteurs_list.paginator %}
{% include "pagination.html" with list=auteurs_list %}
{% include "pagination.html" with list=auteurs_list %}
{% endif %}
<table class="table table-striped">
<thead>
<tr>
<th>Nom</th>
<th></th>
</tr>
</thead>
{% for auteur in auteurs_list %}
<table class="table table-striped">
<thead>
<tr>
<th>Nom</th>
<th></th>
</tr>
</thead>
{% for auteur in auteurs_list %}
<tr>
<td>{{ auteur.nom }}</td>
<td>{% if is_perm %}{% include 'buttons/edit.html' with href='media:edit-auteur' id=auteur.id %}
{% include 'buttons/suppr.html' with href='media:del-auteur' id=auteur.id %}{% endif %}
{% include 'buttons/history.html' with href='media:history' name='auteur' id=auteur.id %}</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>
</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>
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</table>
......@@ -46,9 +46,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ jeu.nombre_joueurs_min }}</td>
<td>{{ jeu.nombre_joueurs_max }}</td>
<td>{{ jeu.comment }}</td>
<td>{% if is_perm %}{% include 'buttons/edit.html' with href='media:edit-jeu' id=jeu.id %}
{% include 'buttons/suppr.html' with href='media:del-jeu' id=jeu.id %}{% endif %}
{% include 'buttons/history.html' with href='media:history' name='jeu' id=jeu.id %}</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>
</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>
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
......@@ -23,26 +23,35 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% if medias_list.paginator %}
{% include "pagination.html" with list=medias_list %}
{% include "pagination.html" with list=medias_list %}
{% endif %}
<table class="table table-striped">
<thead>
<tr>
<th>Titre</th>
<th>Auteur</th>
<th>Cote</th>
<th></th>
</tr>
</thead>
{% for media in medias_list %}
<table class="table table-striped">
<thead>
<tr>
<th>Titre</th>
<th>Auteur</th>
<th>Cote</th>
<th></th>
</tr>
</thead>
{% for media in medias_list %}
<tr>
<td>{{ media.titre }}</td>
<td>{% for aut in media.auteur.all %}{{ aut }}, {% endfor %}</td>
<td>{{ media.cote }}</td>
<td>{% if is_perm %}{% include 'buttons/edit.html' with href='media:edit-media' id=media.id %}
{% include 'buttons/suppr.html' with href='media:del-media' id=media.id %}{% endif %}
{% include 'buttons/history.html' with href='media:history' name='media' id=media.id %}</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>
</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>
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</table>
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load bootstrap3 %}
{% block title %}Historique{% endblock %}
{% block content %}
<h2>Historique de {{ object }}</h2>
{% if reversions.paginator %}
<ul class="pagination nav navbar-nav">
{% if reversions.has_previous %}
<li><a href="?page={{ reversions.previous_page_number }}">Suivants</a></li>
{% endif %}
{% for page in reversions.paginator.page_range %}
<li class="{% if reversions.number == page %}active{% endif %}"><a
href="?page={{ page }}">{{ page }}</a></li>
{% endfor %}
{% if reversions.has_next %}
<li><a href="?page={{ reversions.next_page_number }}">Précédents</a></li>
{% endif %}
</ul>
{% endif %}
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Cableur</th>
<th>Commentaire</th>
</tr>
</thead>
{% for rev in reversions %}
<tr>
<td>{{ rev.revision.date_created }}</td>
<td>{{ rev.revision.user }}</td>
<td>{{ rev.revision.comment }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
......@@ -8,25 +8,28 @@ from . import views
urlpatterns = [
url(r'^add_auteur/$', views.add_auteur, name='add-auteur'),
url(r'^edit_auteur/(?P<auteurid>[0-9]+)$', views.edit_auteur, name='edit-auteur'),
url(r'^del_auteur/(?P<auteurid>[0-9]+)$', views.del_auteur, name='del-auteur'),
url(r'^edit_auteur/(?P<auteurid>[0-9]+)$', views.edit_auteur,
name='edit-auteur'),
url(r'^del_auteur/(?P<auteurid>[0-9]+)$', views.del_auteur,
name='del-auteur'),
url(r'^index_auteurs/$', views.index_auteurs, name='index-auteurs'),
url(r'^history/(?P<object>auteur)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^add_jeu/$', views.add_jeu, name='add-jeu'),
url(r'^edit_jeu/(?P<jeuid>[0-9]+)$', views.edit_jeu, name='edit-jeu'),
url(r'^del_jeu/(?P<jeuid>[0-9]+)$', views.del_jeu, name='del-jeu'),
url(r'^index_jeux/$', views.index_jeux, name='index-jeux'),
url(r'^history/(?P<object>jeu)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^add_media/$', views.add_media, name='add-media'),
url(r'^edit_media/(?P<mediaid>[0-9]+)$', views.edit_media, name='edit-media'),
url(r'^edit_media/(?P<mediaid>[0-9]+)$', views.edit_media,
name='edit-media'),
url(r'^del_media/(?P<mediaid>[0-9]+)$', views.del_media, name='del-media'),
url(r'^index_medias/$', views.index_medias, name='index-medias'),
url(r'^history/(?P<object>media)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^add_emprunt/(?P<userid>[0-9]+)$', views.add_emprunt, name='add-emprunt'),
url(r'^retour_emprunt/(?P<empruntid>[0-9]+)$', views.retour_emprunt, name='retour-emprunt'),
url(r'^edit_emprunt/(?P<empruntid>[0-9]+)$', views.edit_emprunt, name='edit-emprunt'),
url(r'^del_emprunt/(?P<empruntid>[0-9]+)$', views.del_emprunt, name='del-emprunt'),
url(r'^add_emprunt/(?P<userid>[0-9]+)$', views.add_emprunt,
name='add-emprunt'),
url(r'^retour_emprunt/(?P<empruntid>[0-9]+)$', views.retour_emprunt,
name='retour-emprunt'),
url(r'^edit_emprunt/(?P<empruntid>[0-9]+)$', views.edit_emprunt,
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'^history/(?P<object>emprunt)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^$', views.index, name='index'),
]
This diff is collapsed.
{% 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.
{% endcomment %}
<a class="btn btn-primary btn-sm" role="button" href="{% url href id %}" title="{{ desc|default:"Ajouter" }}">
<i class="glyphicon glyphicon-plus"></i>
</a>
{% 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.
{% endcomment %}
<a class="btn btn-primary btn-sm" role="button" title="{{ desc|default:"Éditer" }}" href="{% url href id %}">
<i class="glyphicon glyphicon-edit"></i>
</a>
{% 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.
{% endcomment %}
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url href name id %}">
<i class="glyphicon glyphicon-time"></i>
</a>
{% 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.
{% endcomment %}
<a class="btn btn-danger btn-sm" role="button" href="{% url href id %}" title="{{ desc|default:"Supprimer" }}">
<i class="glyphicon glyphicon-trash"></i>
</a>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment