Fix missing client owner assignment

This commit is contained in:
Kumi 2022-08-12 07:47:14 +00:00
parent 67ad1491e7
commit cb340d2d2f
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -42,5 +42,13 @@ class ClientCreateView(TimeoutMixin, TitleMixin, CreateView):
def get_object(self, queryset=None):
return get_object_or_404(Client, owner=self.request.user, client_id=self.kwargs["pk"])
def form_valid(self, form):
self.object = form.save(commit=False)
self.object.owner = self.request.user
self.object.save()
return super().form_valid(form)
def get_success_url(self):
return reverse_lazy("frontend:client_edit", args=(self.object.client_id,))