mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
Historique générique dans cotisations.
This commit is contained in:
parent
75948450dd
commit
da382fbeb6
3 changed files with 11 additions and 73 deletions
|
@ -24,6 +24,7 @@ from __future__ import unicode_literals
|
|||
|
||||
from django.conf.urls import url
|
||||
|
||||
import re2o
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
|
@ -99,21 +100,11 @@ urlpatterns = [
|
|||
views.index_paiement,
|
||||
name='index-paiement'
|
||||
),
|
||||
url(r'^history/(?P<object_name>facture)/(?P<object_id>[0-9]+)$',
|
||||
views.history,
|
||||
name='history'
|
||||
),
|
||||
url(r'^history/(?P<object_name>article)/(?P<object_id>[0-9]+)$',
|
||||
views.history,
|
||||
name='history'
|
||||
),
|
||||
url(r'^history/(?P<object_name>paiement)/(?P<object_id>[0-9]+)$',
|
||||
views.history,
|
||||
name='history'),
|
||||
url(r'^history/(?P<object_name>banque)/(?P<object_id>[0-9]+)$',
|
||||
views.history,
|
||||
name='history'
|
||||
),
|
||||
url(
|
||||
r'history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$',
|
||||
re2o.views.history,
|
||||
name='history',
|
||||
),
|
||||
url(r'^control/$',
|
||||
views.control,
|
||||
name='control'
|
||||
|
|
|
@ -590,60 +590,3 @@ def index(request):
|
|||
return render(request, 'cotisations/index.html', {
|
||||
'facture_list': facture_list
|
||||
})
|
||||
|
||||
|
||||
@login_required
|
||||
def history(request, object_name, object_id):
|
||||
"""Affiche l'historique de chaque objet"""
|
||||
if object_name == 'facture':
|
||||
try:
|
||||
object_instance = Facture.objects.get(pk=object_id)
|
||||
except Facture.DoesNotExist:
|
||||
messages.error(request, "Facture inexistante")
|
||||
return redirect(reverse('cotisations:index'))
|
||||
if not request.user.has_perms(('cableur',))\
|
||||
and object_instance.user != request.user:
|
||||
messages.error(request, "Vous ne pouvez pas afficher l'historique\
|
||||
d'une facture d'un autre user que vous sans droit cableur")
|
||||
return redirect(reverse(
|
||||
'users:profil',
|
||||
kwargs={'userid':str(request.user.id)}
|
||||
))
|
||||
elif object_name == 'paiement' and request.user.has_perms(('cableur',)):
|
||||
try:
|
||||
object_instance = Paiement.objects.get(pk=object_id)
|
||||
except Paiement.DoesNotExist:
|
||||
messages.error(request, "Paiement inexistant")
|
||||
return redirect(reverse('cotisations:index'))
|
||||
elif object_name == 'article' and request.user.has_perms(('cableur',)):
|
||||
try:
|
||||
object_instance = Article.objects.get(pk=object_id)
|
||||
except Article.DoesNotExist:
|
||||
messages.error(request, "Article inexistante")
|
||||
return redirect(reverse('cotisations:index'))
|
||||
elif object_name == 'banque' and request.user.has_perms(('cableur',)):
|
||||
try:
|
||||
object_instance = Banque.objects.get(pk=object_id)
|
||||
except Banque.DoesNotExist:
|
||||
messages.error(request, "Banque inexistante")
|
||||
return redirect(reverse('cotisations:index'))
|
||||
else:
|
||||
messages.error(request, "Objet inconnu")
|
||||
return redirect(reverse('cotisations:index'))
|
||||
options, _created = GeneralOption.objects.get_or_create()
|
||||
pagination_number = options.pagination_number
|
||||
reversions = Version.objects.get_for_object(object_instance)
|
||||
paginator = Paginator(reversions, pagination_number)
|
||||
page = request.GET.get('page')
|
||||
try:
|
||||
reversions = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
# If page is not an integer, deliver first page.
|
||||
reversions = paginator.page(1)
|
||||
except EmptyPage:
|
||||
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||
reversions = paginator.page(paginator.num_pages)
|
||||
return render(request, 're2o/history.html', {
|
||||
'reversions': reversions,
|
||||
'object': object_instance
|
||||
})
|
||||
|
|
|
@ -35,7 +35,7 @@ from reversion.models import Version
|
|||
from django.contrib import messages
|
||||
from preferences.models import Service
|
||||
from preferences.models import OptionalUser, GeneralOption
|
||||
import users, preferences
|
||||
import users, preferences, cotisations
|
||||
|
||||
def form(ctx, template, request):
|
||||
"""Form générique, raccourci importé par les fonctions views du site"""
|
||||
|
@ -60,6 +60,10 @@ HISTORY_BIND = {
|
|||
'listright' : users.models.ListRight,
|
||||
'serviceuser' : users.models.ServiceUser,
|
||||
'service' : preferences.models.Service,
|
||||
'facture' : cotisations.models.Facture,
|
||||
'article' : cotisations.models.Article,
|
||||
'paiement' : cotisations.models.Paiement,
|
||||
'banque' : cotisations.models.Banque,
|
||||
}
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in a new issue