Loading services/admin.py +3 −2 Original line number Diff line number Diff line Loading @@ -338,7 +338,8 @@ class ServicePortInline(PortInline): class ServiceForm(ModelForm): def clean_adhesion(self): if self.instance.adhesion.pk != self.cleaned_data['adhesion'].pk \ if hasattr(self.instance, 'adhesion') \ and self.instance.adhesion.pk != self.cleaned_data['adhesion'].pk \ and not self.instance.is_active(): raise ValidationError('Il n’est pas possible de ré-affecter à un autre adhérent un service inactif (i.e. sans allocations actives).') return self.cleaned_data['adhesion'] Loading @@ -361,7 +362,7 @@ class ServiceAdmin(admin.ModelAdmin): form = ServiceForm def save_model(self, request, srv, form, change): if 'adhesion' in form.changed_data: if srv.pk and 'adhesion' in form.changed_data: with transaction.atomic(): old_srv = Service.objects.get(pk=srv.pk) adhesion = srv.adhesion Loading Loading
services/admin.py +3 −2 Original line number Diff line number Diff line Loading @@ -338,7 +338,8 @@ class ServicePortInline(PortInline): class ServiceForm(ModelForm): def clean_adhesion(self): if self.instance.adhesion.pk != self.cleaned_data['adhesion'].pk \ if hasattr(self.instance, 'adhesion') \ and self.instance.adhesion.pk != self.cleaned_data['adhesion'].pk \ and not self.instance.is_active(): raise ValidationError('Il n’est pas possible de ré-affecter à un autre adhérent un service inactif (i.e. sans allocations actives).') return self.cleaned_data['adhesion'] Loading @@ -361,7 +362,7 @@ class ServiceAdmin(admin.ModelAdmin): form = ServiceForm def save_model(self, request, srv, form, change): if 'adhesion' in form.changed_data: if srv.pk and 'adhesion' in form.changed_data: with transaction.atomic(): old_srv = Service.objects.get(pk=srv.pk) adhesion = srv.adhesion Loading