diff --git a/cotisations/urls.py b/cotisations/urls.py index f59fd678..d3e56f36 100644 --- a/cotisations/urls.py +++ b/cotisations/urls.py @@ -99,18 +99,18 @@ urlpatterns = [ views.index_paiement, name='index-paiement' ), - url(r'^history/(?Pfacture)/(?P[0-9]+)$', + url(r'^history/(?Pfacture)/(?P[0-9]+)$', views.history, name='history' ), - url(r'^history/(?Particle)/(?P[0-9]+)$', + url(r'^history/(?Particle)/(?P[0-9]+)$', views.history, name='history' ), - url(r'^history/(?Ppaiement)/(?P[0-9]+)$', + url(r'^history/(?Ppaiement)/(?P[0-9]+)$', views.history, name='history'), - url(r'^history/(?Pbanque)/(?P[0-9]+)$', + url(r'^history/(?Pbanque)/(?P[0-9]+)$', views.history, name='history' ), diff --git a/cotisations/views.py b/cotisations/views.py index e44eee65..fc4469aa 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -603,9 +603,9 @@ def index(request): @login_required -def history(request, object, object_id): +def history(request, object_name, object_id): """Affiche l'historique de chaque objet""" - if object == 'facture': + if object_name == 'facture': try: object_instance = Facture.objects.get(pk=object_id) except Facture.DoesNotExist: @@ -616,19 +616,19 @@ def history(request, object, object_id): messages.error(request, "Vous ne pouvez pas afficher l'historique\ d'une facture d'un autre user que vous sans droit cableur") return redirect("/users/profil/" + str(request.user.id)) - elif object == 'paiement' and request.user.has_perms(('cableur',)): + 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("/cotisations/") - elif object == 'article' and request.user.has_perms(('cableur',)): + 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("/cotisations/") - elif object == 'banque' and request.user.has_perms(('cableur',)): + elif object_name == 'banque' and request.user.has_perms(('cableur',)): try: object_instance = Banque.objects.get(pk=object_id) except Banque.DoesNotExist: diff --git a/machines/views.py b/machines/views.py index 41cea7b9..dc3e0406 100644 --- a/machines/views.py +++ b/machines/views.py @@ -1056,7 +1056,7 @@ def history(request, object, id): @login_required @permission_required('cableur') def index_portlist(request): - port_list = OuverturePortList.objects.prefetch_related('ouvertureport_set').prefetch_related('interface_set').order_by('name') + port_list = OuverturePortList.objects.prefetch_related('ouvertureport_set').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__machine__user').order_by('name') return render(request, "machines/index_portlist.html", {'port_list':port_list}) @login_required diff --git a/preferences/migrations/0021_auto_20171015_1741.py b/preferences/migrations/0021_auto_20171015_1741.py new file mode 100644 index 00000000..cc94720a --- /dev/null +++ b/preferences/migrations/0021_auto_20171015_1741.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-10-15 15:41 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0020_optionalmachine_ipv6'), + ] + + operations = [ + migrations.AlterField( + model_name='optionaltopologie', + name='radius_general_policy', + field=models.CharField(choices=[('MACHINE', 'Sur le vlan de la plage ip machine'), ('DEFINED', 'Prédéfini dans "Vlan où placer les machines après acceptation RADIUS"')], default='DEFINED', max_length=32), + ), + ] diff --git a/preferences/migrations/0022_auto_20171015_1758.py b/preferences/migrations/0022_auto_20171015_1758.py new file mode 100644 index 00000000..ea389a32 --- /dev/null +++ b/preferences/migrations/0022_auto_20171015_1758.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-10-15 15:58 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0021_auto_20171015_1741'), + ] + + operations = [ + migrations.AlterField( + model_name='optionaltopologie', + name='radius_general_policy', + field=models.CharField(choices=[('MACHINE', 'Sur le vlan de la plage ip machine'), ('DEFINED', 'Prédéfini dans "Vlan où placer les machines après acceptation RADIUS"')], default='DEFINED', max_length=32), + ), + ] diff --git a/preferences/migrations/0023_auto_20171015_2033.py b/preferences/migrations/0023_auto_20171015_2033.py new file mode 100644 index 00000000..3235e49f --- /dev/null +++ b/preferences/migrations/0023_auto_20171015_2033.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-10-15 18:33 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0022_auto_20171015_1758'), + ] + + operations = [ + migrations.AlterField( + model_name='optionaltopologie', + name='radius_general_policy', + field=models.CharField(choices=[('MACHINE', 'Sur le vlan de la plage ip machine'), ('DEFINED', 'Prédéfini dans "Vlan où placer les machines après acceptation RADIUS"')], default='DEFINED', max_length=32), + ), + ] diff --git a/preferences/urls.py b/preferences/urls.py index 2169f83c..f10d25a0 100644 --- a/preferences/urls.py +++ b/preferences/urls.py @@ -69,7 +69,7 @@ urlpatterns = [ ), url(r'^del_services/$', views.del_services, name='del-services'), url( - r'^history/(?Pservice)/(?P[0-9]+)$', + r'^history/(?Pservice)/(?P[0-9]+)$', views.history, name='history' ), diff --git a/topologie/urls.py b/topologie/urls.py index 4d0a6779..77a78b97 100644 --- a/topologie/urls.py +++ b/topologie/urls.py @@ -42,16 +42,16 @@ urlpatterns = [ url(r'^switch/(?P[0-9]+)$', views.index_port, name='index-port'), - url(r'^history/(?Pswitch)/(?P[0-9]+)$', + url(r'^history/(?Pswitch)/(?P[0-9]+)$', views.history, name='history'), - url(r'^history/(?Pport)/(?P[0-9]+)$', + url(r'^history/(?Pport)/(?P[0-9]+)$', views.history, name='history'), - url(r'^history/(?Proom)/(?P[0-9]+)$', + url(r'^history/(?Proom)/(?P[0-9]+)$', views.history, name='history'), - url(r'^history/(?Pstack)/(?P[0-9]+)$', + url(r'^history/(?Pstack)/(?P[0-9]+)$', views.history, name='history'), url(r'^edit_port/(?P[0-9]+)$', views.edit_port, name='edit-port'), diff --git a/topologie/views.py b/topologie/views.py index 686685e9..5eb2de74 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -135,7 +135,8 @@ def index_port(request, switch_id): port_list = Port.objects.filter(switch=switch)\ .select_related('room')\ .select_related('machine_interface__domain__extension')\ - .select_related('related')\ + .select_related('machine_interface__machine__user')\ + .select_related('related__switch__switch_interface__domain__extension')\ .select_related('switch')\ .order_by('port') return render(request, 'topologie/index_p.html', { diff --git a/users/forms.py b/users/forms.py index fd81b426..93ef35b5 100644 --- a/users/forms.py +++ b/users/forms.py @@ -452,13 +452,14 @@ class RightForm(ModelForm): class DelRightForm(Form): """Suppression d'un droit d'un user""" rights = forms.ModelMultipleChoiceField( - queryset=Right.objects.all(), + queryset=Right.objects.select_related('user'), widget=forms.CheckboxSelectMultiple ) def __init__(self, right, *args, **kwargs): super(DelRightForm, self).__init__(*args, **kwargs) - self.fields['rights'].queryset = Right.objects.filter(right=right) + self.fields['rights'].queryset = Right.objects.select_related('user')\ + .select_related('right').filter(right=right) class BanForm(ModelForm): diff --git a/users/urls.py b/users/urls.py index 531e0826..201568cd 100644 --- a/users/urls.py +++ b/users/urls.py @@ -88,32 +88,32 @@ urlpatterns = [ url(r'^reset_password/$', views.reset_password, name='reset-password'), url(r'^mass_archive/$', views.mass_archive, name='mass-archive'), url( - r'^history/(?Puser)/(?P[0-9]+)$', + r'^history/(?Puser)/(?P[0-9]+)$', views.history, name='history' ), url( - r'^history/(?Pban)/(?P[0-9]+)$', + r'^history/(?Pban)/(?P[0-9]+)$', views.history, name='history' ), url( - r'^history/(?Pwhitelist)/(?P[0-9]+)$', + r'^history/(?Pwhitelist)/(?P[0-9]+)$', views.history, name='history' ), url( - r'^history/(?Pschool)/(?P[0-9]+)$', + r'^history/(?Pschool)/(?P[0-9]+)$', views.history, name='history' ), url( - r'^history/(?Plistright)/(?P[0-9]+)$', + r'^history/(?Plistright)/(?P[0-9]+)$', views.history, name='history' ), url( - r'^history/(?Pserviceuser)/(?P[0-9]+)$', + r'^history/(?Pserviceuser)/(?P[0-9]+)$', views.history, name='history' ),