8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 11:53:12 +00:00

Fix list usable machine by rights

This commit is contained in:
Gabriel Detraz 2019-09-17 18:41:41 +02:00 committed by chirac
parent 40258bfd76
commit 7fb5f786fd

View file

@ -104,7 +104,7 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
self.fields['ipv4'].queryset = IpList.objects.filter( self.fields['ipv4'].queryset = IpList.objects.filter(
interface__isnull=True 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: if not can_use_all_iptype:
self.fields['ipv4'].queryset = IpList.objects.filter( self.fields['ipv4'].queryset = IpList.objects.filter(
interface__isnull=True interface__isnull=True
@ -120,7 +120,7 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
if "machine" in self.fields: if "machine" in self.fields:
self.fields['machine'].queryset = Machine.objects.all() \ self.fields['machine'].queryset = Machine.objects.all() \
.select_related('user') .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: if not can_use_all_machinetype:
self.fields['machine_type'].queryset = MachineType.objects.filter( self.fields['machine_type'].queryset = MachineType.objects.filter(
ip_type__in=IpType.objects.filter(need_infra=False) 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__) prefix = kwargs.pop('prefix', self.Meta.model.__name__)
user = kwargs.pop('user') user = kwargs.pop('user')
super(AliasForm, self).__init__(*args, prefix=prefix, **kwargs) 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: if not can_use_all:
self.fields['extension'].queryset = Extension.objects.filter( self.fields['extension'].queryset = Extension.objects.filter(
need_infra=False need_infra=False