From 7fb5f786fdffca076cdf3c178516520713df337d Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Tue, 17 Sep 2019 18:41:41 +0200 Subject: [PATCH 1/6] Fix list usable machine by rights --- machines/forms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/machines/forms.py b/machines/forms.py index af05a48e..c89334dd 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -104,7 +104,7 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): self.fields['ipv4'].queryset = IpList.objects.filter( interface__isnull=True ) - can_use_all_iptype, _reason = IpType.can_use_all(user) + can_use_all_iptype, _reason, _message = IpType.can_use_all(user) if not can_use_all_iptype: self.fields['ipv4'].queryset = IpList.objects.filter( interface__isnull=True @@ -120,7 +120,7 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): if "machine" in self.fields: self.fields['machine'].queryset = Machine.objects.all() \ .select_related('user') - can_use_all_machinetype, _reason = MachineType.can_use_all(user) + can_use_all_machinetype, _reason, _message = MachineType.can_use_all(user) if not can_use_all_machinetype: self.fields['machine_type'].queryset = MachineType.objects.filter( ip_type__in=IpType.objects.filter(need_infra=False) @@ -146,7 +146,7 @@ class AliasForm(FormRevMixin, ModelForm): prefix = kwargs.pop('prefix', self.Meta.model.__name__) user = kwargs.pop('user') super(AliasForm, self).__init__(*args, prefix=prefix, **kwargs) - can_use_all, _reason = Extension.can_use_all(user) + can_use_all, _reason, _message = Extension.can_use_all(user) if not can_use_all: self.fields['extension'].queryset = Extension.objects.filter( need_infra=False From d3310866cdd651f13c87f539abcb1936aad0ae1b Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Tue, 17 Sep 2019 02:51:00 +0200 Subject: [PATCH 2/6] Rend l'API fonctionnelle sous buster --- api/routers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/routers.py b/api/routers.py index 7c9e4a0f..bb2411f5 100644 --- a/api/routers.py +++ b/api/routers.py @@ -76,7 +76,7 @@ class AllViewsRouter(DefaultRouter): """ return pattern.split('/')[-1] - def get_api_root_view(self, schema_urls=None): + def get_api_root_view(self, schema_urls=None, api_urls=None): """Create a class-based view to use as the API root. Highly inspired by the base class. See details on the implementation From 17704fce9cca8d1867d8c01eaa0d173a80bd02a1 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Tue, 17 Sep 2019 19:09:31 +0200 Subject: [PATCH 3/6] Fix can_view extra arg for logs --- logs/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logs/views.py b/logs/views.py index 28205063..5d8cf1a9 100644 --- a/logs/views.py +++ b/logs/views.py @@ -521,7 +521,7 @@ def history(request, application, object_name, object_id): 'users:profil', kwargs={'userid': str(request.user.id)} )) - can, msg = instance.can_view(request.user) + can, msg, _extra_msg = instance.can_view(request.user) if not can: messages.error(request, msg or _("You don't have the right to access this menu.")) return redirect(reverse( From 6c476f080e69f2507b0593750f25ff25d403bdf4 Mon Sep 17 00:00:00 2001 From: klafyvel Date: Thu, 19 Sep 2019 23:14:33 +0200 Subject: [PATCH 4/6] Better naming --- logs/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logs/views.py b/logs/views.py index 5d8cf1a9..47ceab06 100644 --- a/logs/views.py +++ b/logs/views.py @@ -521,7 +521,7 @@ def history(request, application, object_name, object_id): 'users:profil', kwargs={'userid': str(request.user.id)} )) - can, msg, _extra_msg = instance.can_view(request.user) + can, msg, _permissions = instance.can_view(request.user) if not can: messages.error(request, msg or _("You don't have the right to access this menu.")) return redirect(reverse( From 1c2ce26060dbcf6d66250cd3388e03719cf086e3 Mon Sep 17 00:00:00 2001 From: klafyvel Date: Thu, 19 Sep 2019 23:15:11 +0200 Subject: [PATCH 5/6] Better naming --- machines/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machines/forms.py b/machines/forms.py index c89334dd..a56ecbf3 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -104,7 +104,7 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): self.fields['ipv4'].queryset = IpList.objects.filter( interface__isnull=True ) - can_use_all_iptype, _reason, _message = IpType.can_use_all(user) + can_use_all_iptype, _reason, _permissions = IpType.can_use_all(user) if not can_use_all_iptype: self.fields['ipv4'].queryset = IpList.objects.filter( interface__isnull=True From 4f1102c0c5502461f5d97f6071281f056b4f844a Mon Sep 17 00:00:00 2001 From: klafyvel Date: Thu, 19 Sep 2019 23:16:02 +0200 Subject: [PATCH 6/6] Better naming --- machines/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machines/forms.py b/machines/forms.py index a56ecbf3..4ea2323b 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -120,7 +120,7 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): if "machine" in self.fields: self.fields['machine'].queryset = Machine.objects.all() \ .select_related('user') - can_use_all_machinetype, _reason, _message = MachineType.can_use_all(user) + can_use_all_machinetype, _reason, _permissions = MachineType.can_use_all(user) if not can_use_all_machinetype: self.fields['machine_type'].queryset = MachineType.objects.filter( ip_type__in=IpType.objects.filter(need_infra=False) @@ -146,7 +146,7 @@ class AliasForm(FormRevMixin, ModelForm): prefix = kwargs.pop('prefix', self.Meta.model.__name__) user = kwargs.pop('user') super(AliasForm, self).__init__(*args, prefix=prefix, **kwargs) - can_use_all, _reason, _message = Extension.can_use_all(user) + can_use_all, _reason, _permissions = Extension.can_use_all(user) if not can_use_all: self.fields['extension'].queryset = Extension.objects.filter( need_infra=False