mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2024-11-27 00:47:10 +00:00
Simple library views
This commit is contained in:
parent
9f52bed890
commit
0c504e85fc
@ -13,19 +13,20 @@ class AuteurAdmin(VersionAdmin):
|
|||||||
|
|
||||||
|
|
||||||
class MediaAdmin(VersionAdmin):
|
class MediaAdmin(VersionAdmin):
|
||||||
list_display = ('titre', 'cote')
|
list_display = ('titre', 'authors', 'cote')
|
||||||
|
|
||||||
|
def authors(self, obj):
|
||||||
|
return ", ".join([a.nom for a in obj.auteur.all()])
|
||||||
|
|
||||||
|
|
||||||
class EmpruntAdmin(VersionAdmin):
|
class EmpruntAdmin(VersionAdmin):
|
||||||
list_display = (
|
list_display = ('media', 'user', 'date_emprunt', 'date_rendu',
|
||||||
'media', 'user', 'date_emprunt', 'date_rendu', 'permanencier_emprunt',
|
'permanencier_emprunt', 'permanencier_rendu')
|
||||||
'permanencier_rendu')
|
|
||||||
|
|
||||||
|
|
||||||
class JeuAdmin(VersionAdmin):
|
class JeuAdmin(VersionAdmin):
|
||||||
list_display = (
|
list_display = ('nom', 'proprietaire', 'duree', 'nombre_joueurs_min',
|
||||||
'nom', 'proprietaire', 'duree', 'nombre_joueurs_min', 'nombre_joueurs_max',
|
'nombre_joueurs_max', 'comment')
|
||||||
'comment')
|
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Auteur, AuteurAdmin)
|
admin.site.register(Auteur, AuteurAdmin)
|
||||||
|
@ -5,23 +5,7 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
|
|
||||||
from .models import Auteur, Media, Jeu, Emprunt
|
from .models import Jeu, Emprunt
|
||||||
|
|
||||||
|
|
||||||
class AuteurForm(ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = Auteur
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class MediaForm(ModelForm):
|
|
||||||
auteur = forms.ModelMultipleChoiceField(Auteur.objects.all(),
|
|
||||||
widget=forms.CheckboxSelectMultiple,
|
|
||||||
required=False)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Media
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class JeuForm(ModelForm):
|
class JeuForm(ModelForm):
|
||||||
@ -30,10 +14,10 @@ class JeuForm(ModelForm):
|
|||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
def clean_nombre_joueurs_max(self):
|
def clean_nombre_joueurs_max(self):
|
||||||
if self.cleaned_data['nombre_joueurs_max'] < self.cleaned_data[
|
max_player = self.cleaned_data['nombre_joueurs_max']
|
||||||
'nombre_joueurs_min']:
|
if max_player < self.cleaned_data['nombre_joueurs_min']:
|
||||||
raise forms.ValidationError("Max ne peut être inférieur à min")
|
raise forms.ValidationError("Max ne peut être inférieur à min")
|
||||||
return self.cleaned_data['nombre_joueurs_max']
|
return max_player
|
||||||
|
|
||||||
|
|
||||||
class EmpruntForm(ModelForm):
|
class EmpruntForm(ModelForm):
|
||||||
|
@ -10,24 +10,11 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Nom</th>
|
<th>Nom</th>
|
||||||
<th></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for auteur in auteurs_list %}
|
{% for auteur in auteurs_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ auteur.nom }}</td>
|
<td>{{ auteur.nom }}</td>
|
||||||
<td>
|
|
||||||
{% if perms.media.change_auteur %}
|
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'media:edit-auteur' auteur.id %}">
|
|
||||||
Éditer
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if perms.media.delete_auteur %}
|
|
||||||
<a class="btn btn-danger btn-sm" href="{% url 'media:del-auteur' auteur.id %}">
|
|
||||||
Supprimer
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
@ -21,9 +21,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% for emprunt in emprunts_list %}
|
{% for emprunt in emprunts_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ emprunt.media }}</td>
|
<td>{{ emprunt.media }}</td>
|
||||||
<td>
|
<td>{{ emprunt.user }}</td>
|
||||||
<a href="{% url 'users:profil' userid=emprunt.user.id %}"><b>{{ emprunt.user }}</b></a>
|
|
||||||
</td>
|
|
||||||
<td>{{ emprunt.date_emprunt }}</td>
|
<td>{{ emprunt.date_emprunt }}</td>
|
||||||
<td>{{ emprunt.permanencier_emprunt }}</td>
|
<td>{{ emprunt.permanencier_emprunt }}</td>
|
||||||
<td>
|
<td>
|
||||||
@ -40,9 +38,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% if perms.media.change_emprunt %}
|
{% if perms.media.change_emprunt %}
|
||||||
<a href="{% url 'media:edit-emprunt' emprunt.id %}">Editer</a>
|
<a href="{% url 'media:edit-emprunt' emprunt.id %}">Editer</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.media.delete_emprunt %}
|
|
||||||
<a href="{% url 'media:del-emprunt' emprunt.id %}">Supprimer</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -15,7 +15,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<th>Joueurs min</th>
|
<th>Joueurs min</th>
|
||||||
<th>Joueurs max</th>
|
<th>Joueurs max</th>
|
||||||
<th>Comment</th>
|
<th>Comment</th>
|
||||||
<th></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for jeu in jeux_list %}
|
{% for jeu in jeux_list %}
|
||||||
@ -26,18 +25,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<td>{{ jeu.nombre_joueurs_min }}</td>
|
<td>{{ jeu.nombre_joueurs_min }}</td>
|
||||||
<td>{{ jeu.nombre_joueurs_max }}</td>
|
<td>{{ jeu.nombre_joueurs_max }}</td>
|
||||||
<td>{{ jeu.comment }}</td>
|
<td>{{ jeu.comment }}</td>
|
||||||
<td>
|
|
||||||
{% if perms.media.change_jeu %}
|
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'media:edit-jeu' jeu.id %}">
|
|
||||||
Éditer
|
|
||||||
</a>
|
|
||||||
{% 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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
@ -12,7 +12,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<th>Titre</th>
|
<th>Titre</th>
|
||||||
<th>Auteur</th>
|
<th>Auteur</th>
|
||||||
<th>Cote</th>
|
<th>Cote</th>
|
||||||
<th></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for media in medias_list %}
|
{% for media in medias_list %}
|
||||||
@ -20,18 +19,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<td>{{ media.titre }}</td>
|
<td>{{ media.titre }}</td>
|
||||||
<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>
|
|
||||||
{% if perms.media.change_media %}
|
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'media:edit-media' media.id %}">
|
|
||||||
Éditer
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if perms.media.delete_media %}
|
|
||||||
<a class="btn btn-danger btn-sm" href="{% url 'media:del-media' media.id %}">
|
|
||||||
Supprimer
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
{% extends "media/sidebar.html" %}
|
|
||||||
{% comment %}
|
|
||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
{% endcomment %}
|
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
|
||||||
|
|
||||||
{% 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>
|
|
||||||
{% endblock %}
|
|
@ -3,12 +3,14 @@
|
|||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}Auteurs{% endblock %}
|
{% block title %}Auteurs{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Liste des auteurs</h2>
|
<h2>Liste des auteurs</h2>
|
||||||
{% if perms.media.add_auteur %}
|
{% if user.is_staff %}
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'media:add-auteur' %}">Ajouter un auteur</a>
|
<a class="changelink" href="{% url 'admin:media_auteur_changelist' %}">{% trans 'Go to admin' %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "media/aff_auteurs.html" with auteurs_list=auteurs_list %}
|
{% include "media/aff_auteurs.html" with auteurs_list=auteurs_list %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -3,9 +3,14 @@
|
|||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}Emprunts{% endblock %}
|
{% block title %}Emprunts{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Liste des emprunts</h2>
|
<h2>Liste des emprunts</h2>
|
||||||
|
{% if user.is_staff %}
|
||||||
|
<a class="changelink" href="{% url 'admin:media_emprunt_changelist' %}">{% trans 'Go to admin' %}</a>
|
||||||
|
{% endif %}
|
||||||
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
|
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}Jeux{% endblock %}
|
{% block title %}Jeux{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Liste des jeux</h2>
|
<h2>Liste des jeux</h2>
|
||||||
{% if perms.media.add_jeu %}
|
{% if user.is_staff %}
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'media:add-jeu' %}">Ajouter un jeu</a>
|
<a class="changelink" href="{% url 'admin:media_jeu_changelist' %}">{% trans 'Go to admin' %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "media/aff_jeux.html" with jeux_list=jeux_list %}
|
{% include "media/aff_jeux.html" with jeux_list=jeux_list %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}Media{% endblock %}
|
{% block title %}Media{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Liste des medias</h2>
|
<h2>Liste des medias</h2>
|
||||||
{% if perms.media.add_media %}
|
{% if user.is_staff %}
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'media:add-media' %}">Ajouter un media</a>
|
<a class="changelink" href="{% url 'admin:media_media_changelist' %}">{% trans 'Go to admin' %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "media/aff_medias.html" with medias_list=medias_list %}
|
{% include "media/aff_medias.html" with medias_list=medias_list %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -7,20 +7,8 @@ from django.conf.urls import url
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
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'^index_auteurs/$', views.index_auteurs, name='index-auteurs'),
|
url(r'^index_auteurs/$', views.index_auteurs, name='index-auteurs'),
|
||||||
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'^index_jeux/$', views.index_jeux, name='index-jeux'),
|
||||||
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'^del_media/(?P<mediaid>[0-9]+)$', views.del_media, name='del-media'),
|
|
||||||
url(r'^index_medias/$', views.index_medias, name='index-medias'),
|
url(r'^index_medias/$', views.index_medias, name='index-medias'),
|
||||||
url(r'^add_emprunt/(?P<userid>[0-9]+)$', views.add_emprunt,
|
url(r'^add_emprunt/(?P<userid>[0-9]+)$', views.add_emprunt,
|
||||||
name='add-emprunt'),
|
name='add-emprunt'),
|
||||||
@ -28,7 +16,5 @@ urlpatterns = [
|
|||||||
name='retour-emprunt'),
|
name='retour-emprunt'),
|
||||||
url(r'^edit_emprunt/(?P<empruntid>[0-9]+)$', views.edit_emprunt,
|
url(r'^edit_emprunt/(?P<empruntid>[0-9]+)$', views.edit_emprunt,
|
||||||
name='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_emprunt, name='index'),
|
url(r'^index_emprunts/$', views.index_emprunt, name='index'),
|
||||||
]
|
]
|
||||||
|
176
media/views.py
176
media/views.py
@ -13,7 +13,7 @@ from reversion import revisions as reversion
|
|||||||
|
|
||||||
from med.settings import PAGINATION_NUMBER
|
from med.settings import PAGINATION_NUMBER
|
||||||
from users.models import User
|
from users.models import User
|
||||||
from .forms import AuteurForm, MediaForm, JeuForm, EmpruntForm, EditEmpruntForm
|
from .forms import EmpruntForm, EditEmpruntForm
|
||||||
from .models import Auteur, Media, Jeu, Emprunt
|
from .models import Auteur, Media, Jeu, Emprunt
|
||||||
|
|
||||||
|
|
||||||
@ -23,162 +23,6 @@ def form(ctx, template, request):
|
|||||||
return render(request, template, c)
|
return render(request, template, c)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.add_auteur')
|
|
||||||
def add_auteur(request):
|
|
||||||
auteur = AuteurForm(request.POST or None)
|
|
||||||
if auteur.is_valid():
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
auteur.save()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment("Création")
|
|
||||||
messages.success(request, "L'auteur a été ajouté")
|
|
||||||
return redirect("/media/index_auteurs/")
|
|
||||||
return form({'mediaform': auteur}, 'media/media.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.change_auteur')
|
|
||||||
def edit_auteur(request, auteurid):
|
|
||||||
try:
|
|
||||||
auteur_instance = Auteur.objects.get(pk=auteurid)
|
|
||||||
except Auteur.DoesNotExist:
|
|
||||||
messages.error(request, u"Entrée inexistante")
|
|
||||||
return redirect("/media/index_auteurs/")
|
|
||||||
auteur = AuteurForm(request.POST or None, instance=auteur_instance)
|
|
||||||
if auteur.is_valid():
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
auteur.save()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
|
|
||||||
field for field in auteur.changed_data))
|
|
||||||
messages.success(request, "Auteur modifié")
|
|
||||||
return redirect("/media/index_auteurs/")
|
|
||||||
return form({'mediaform': auteur}, 'media/media.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.delete_auteur')
|
|
||||||
def del_auteur(request, auteurid):
|
|
||||||
try:
|
|
||||||
auteur_instance = Auteur.objects.get(pk=auteurid)
|
|
||||||
except Auteur.DoesNotExist:
|
|
||||||
messages.error(request, u"Entrée inexistante")
|
|
||||||
return redirect("/media/index_auteurs/")
|
|
||||||
if request.method == "POST":
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
auteur_instance.delete()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
messages.success(request, "L'auteur a été détruit")
|
|
||||||
return redirect("/media/index_auteurs")
|
|
||||||
return form({'objet': auteur_instance, 'objet_name': 'auteur'},
|
|
||||||
'media/delete.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.add_media')
|
|
||||||
def add_media(request):
|
|
||||||
media = MediaForm(request.POST or None)
|
|
||||||
if media.is_valid():
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
media.save()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment("Création")
|
|
||||||
messages.success(request, "Le media a été ajouté")
|
|
||||||
return redirect("/media/index_medias/")
|
|
||||||
return form({'mediaform': media}, 'media/media.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.change_media')
|
|
||||||
def edit_media(request, mediaid):
|
|
||||||
try:
|
|
||||||
media_instance = Media.objects.get(pk=mediaid)
|
|
||||||
except Media.DoesNotExist:
|
|
||||||
messages.error(request, u"Entrée inexistante")
|
|
||||||
return redirect("/media/index_medias/")
|
|
||||||
media = MediaForm(request.POST or None, instance=media_instance)
|
|
||||||
if media.is_valid():
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
media.save()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
|
|
||||||
field for field in media.changed_data))
|
|
||||||
messages.success(request, "Media modifié")
|
|
||||||
return redirect("/media/index_medias/")
|
|
||||||
return form({'mediaform': media}, 'media/media.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.delete_media')
|
|
||||||
def del_media(request, mediaid):
|
|
||||||
try:
|
|
||||||
media_instance = Media.objects.get(pk=mediaid)
|
|
||||||
except Media.DoesNotExist:
|
|
||||||
messages.error(request, u"Entrée inexistante")
|
|
||||||
return redirect("/media/index_medias/")
|
|
||||||
if request.method == "POST":
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
media_instance.delete()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
messages.success(request, "Le media a été détruit")
|
|
||||||
return redirect("/media/index_medias")
|
|
||||||
return form({'objet': media_instance, 'objet_name': 'media'},
|
|
||||||
'media/delete.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.add_jeu')
|
|
||||||
def add_jeu(request):
|
|
||||||
jeu = JeuForm(request.POST or None)
|
|
||||||
if jeu.is_valid():
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
jeu.save()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment("Création")
|
|
||||||
messages.success(request, "Le jeu a été ajouté")
|
|
||||||
return redirect("/media/index_jeux/")
|
|
||||||
return form({'mediaform': jeu}, 'media/media.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.change_jeu')
|
|
||||||
def edit_jeu(request, jeuid):
|
|
||||||
try:
|
|
||||||
jeu_instance = Jeu.objects.get(pk=jeuid)
|
|
||||||
except Jeu.DoesNotExist:
|
|
||||||
messages.error(request, u"Entrée inexistante")
|
|
||||||
return redirect("/media/index_jeux/")
|
|
||||||
jeu = JeuForm(request.POST or None, instance=jeu_instance)
|
|
||||||
if jeu.is_valid():
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
jeu.save()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
|
|
||||||
field for field in jeu.changed_data))
|
|
||||||
messages.success(request, "Media modifié")
|
|
||||||
return redirect("/media/index_jeux/")
|
|
||||||
return form({'mediaform': jeu}, 'media/media.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.delete_jeu')
|
|
||||||
def del_jeu(request, jeuid):
|
|
||||||
try:
|
|
||||||
jeu_instance = Jeu.objects.get(pk=jeuid)
|
|
||||||
except Jeu.DoesNotExist:
|
|
||||||
messages.error(request, u"Entrée inexistante")
|
|
||||||
return redirect("/media/index_jeux/")
|
|
||||||
if request.method == "POST":
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
jeu_instance.delete()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
messages.success(request, "Le jeu a été détruit")
|
|
||||||
return redirect("/media/index_jeux")
|
|
||||||
return form({'objet': jeu_instance, 'objet_name': 'jeu'},
|
|
||||||
'media/delete.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('media.add_emprunt')
|
@permission_required('media.add_emprunt')
|
||||||
def add_emprunt(request, userid):
|
def add_emprunt(request, userid):
|
||||||
@ -245,24 +89,6 @@ def retour_emprunt(request, empruntid):
|
|||||||
return redirect("/media/index_emprunts/")
|
return redirect("/media/index_emprunts/")
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
@permission_required('media.delete_emprunt')
|
|
||||||
def del_emprunt(request, empruntid):
|
|
||||||
try:
|
|
||||||
emprunt_instance = Emprunt.objects.get(pk=empruntid)
|
|
||||||
except Emprunt.DoesNotExist:
|
|
||||||
messages.error(request, u"Entrée inexistante")
|
|
||||||
return redirect("/media/index_emprunts/")
|
|
||||||
if request.method == "POST":
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
emprunt_instance.delete()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
messages.success(request, "L'emprunt a été détruit")
|
|
||||||
return redirect("/media/index_emprunts")
|
|
||||||
return form({'objet': emprunt_instance, 'objet_name': 'emprunt'},
|
|
||||||
'media/delete.html', request)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index_jeux(request):
|
def index_jeux(request):
|
||||||
jeux_list = Jeu.objects.all()
|
jeux_list = Jeu.objects.all()
|
||||||
|
@ -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-03 13:24+0200\n"
|
"POT-Creation-Date: 2019-08-08 20:49+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"
|
||||||
@ -18,22 +18,22 @@ msgid "Welcome,"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: templates/admin/base_site.html:29
|
#: templates/admin/base_site.html:29
|
||||||
msgid "My profile"
|
msgid "Library"
|
||||||
msgstr "Mon profil"
|
msgstr "Explorer la médiatèque"
|
||||||
|
|
||||||
#: templates/admin/base_site.html:41 templates/admin/base_site.html:60
|
#: templates/admin/base_site.html:42 templates/admin/base_site.html:61
|
||||||
msgid "View admin"
|
msgid "View admin"
|
||||||
msgstr "Administration"
|
msgstr "Administration"
|
||||||
|
|
||||||
#: templates/admin/base_site.html:53
|
#: templates/admin/base_site.html:54
|
||||||
msgid "Documentation"
|
msgid "Documentation"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: templates/admin/base_site.html:62
|
#: templates/admin/base_site.html:63
|
||||||
msgid "Log out"
|
msgid "Log out"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: templates/admin/base_site.html:64 templates/registration/login.html:8
|
#: templates/admin/base_site.html:65 templates/registration/login.html:8
|
||||||
msgid "Log in"
|
msgid "Log in"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -26,7 +26,15 @@ 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 "media:index" %}">{% trans 'Library' %}</a> /
|
<span class="dropdown">
|
||||||
|
<a href="{% url 'media:index' %}">{% trans 'Library' %}</a>
|
||||||
|
<span class="dropdown-content">
|
||||||
|
<a href="{% url "media:index" %}">Emprunts</a>
|
||||||
|
<a href="{% url "media:index-auteurs" %}">Auteurs</a>
|
||||||
|
<a href="{% url "media:index-medias" %}">Medias</a>
|
||||||
|
<a href="{% url "media:index-jeux" %}">Jeux</a>
|
||||||
|
</span>
|
||||||
|
</span> /
|
||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
{% if perms.users.add_user %}
|
{% if perms.users.add_user %}
|
||||||
|
Loading…
Reference in New Issue
Block a user