8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-04 17:06:27 +00:00

Fix: récupère plus proprement l'id de l'instance en train d'être éditée

This commit is contained in:
Maël Kervella 2017-10-07 17:45:22 +00:00
parent 547b863828
commit 75ed68df1b

View file

@ -65,7 +65,7 @@ class EditInterfaceForm(ModelForm):
self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4"
self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True).annotate(mtype_id=F('ip_type__machinetype__id'))
# Add it's own address
self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.fields['ipv4'].get_bound_field(self, 'ipv4').value()).annotate(mtype_id=F('ip_type__machinetype__id'))
self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.instance.id).annotate(mtype_id=F('ip_type__machinetype__id'))
if "machine" in self.fields:
self.fields['machine'].queryset = Machine.objects.all().select_related('user')
@ -99,10 +99,10 @@ class BaseEditInterfaceForm(EditInterfaceForm):
self.fields['type'].queryset = MachineType.objects.filter(ip_type__in=IpType.objects.filter(need_infra=False))
self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True).filter(ip_type__in=IpType.objects.filter(need_infra=False)).annotate(mtype_id=F('ip_type__machinetype__id'))
# Add it's own address
self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.fields['ipv4'].get_bound_field(self, 'ipv4').value()).annotate(mtype_id=F('ip_type__machinetype__id'))
self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.instance.id).annotate(mtype_id=F('ip_type__machinetype__id'))
else:
self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True).annotate(mtype_id=F('ip_type__machinetype__id'))
self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.fields['ipv4'].get_bound_field(self, 'ipv4').value()).annotate(mtype_id=F('ip_type__machinetype__id'))
self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.instance.id).annotate(mtype_id=F('ip_type__machinetype__id'))
class AliasForm(ModelForm):
class Meta: