def form_valid(self, form): existing_contacts = zcontacts.list_contacts(self.request.user) if not existing_contacts: new_contact = zcontacts.contact_create_from_profile( self.request.user, form.instance) if not zmaster.contact_create_update(new_contact): messages.error(self.request, self.error_message) return HttpResponseRedirect(self.request.path_info) existing_registrant = zcontacts.get_registrant(self.request.user) if not existing_registrant: new_registrant = zcontacts.registrant_create_from_profile( self.request.user, form.instance) if not zmaster.contact_create_update(new_registrant): messages.error(self.request, self.error_message) return HttpResponseRedirect(self.request.path_info) else: zcontacts.registrant_update_from_profile(existing_registrant, form.instance) if not zmaster.contact_create_update(existing_registrant): messages.error(self.request, self.error_message) return HttpResponseRedirect(self.request.path_info) if existing_registrant and existing_contacts: messages.success( self.request, 'Your profile information was successfully updated') else: messages.success( self.request, 'Profile information successfully updated, you can register new domains now' ) return super().form_valid(form)
def form_valid(self, form): self.object = form.save(commit=False) self.object.owner = self.request.user if not zmaster.contact_create_update(self.object): messages.error(self.request, self.error_message) return HttpResponseRedirect(self.request.path_info) self.object.save() messages.success(self.request, self.success_message) return super().form_valid(form)
def form_valid(self, form): if not zmaster.contact_create_update(form.instance): messages.error(self.request, self.error_message) return HttpResponseRedirect(self.request.path_info) messages.success(self.request, self.success_message) return super().form_valid(form)