def form_valid(self, form): super().form_valid(form=form) return json_update_from_widget_response( form.update_from_widget_response_data() if callable( getattr(form, 'update_from_widget_response_data', None) ) else form.instance)
def abstract_add_doc_from_widget(request, form=q_forms.CSVDocumentWidgetQuickForm, template='creme_core/generics/form/add_innerpopup.html', submit_label=Document.save_label, title=Document.creation_label, ): warnings.warn('documents.views.document.abstract_add_doc_from_widget() is deprecated ; ' 'use the class-based view BaseQuickDocumentCreation instead.', DeprecationWarning ) user = request.user if not user.has_perm_to_create(Document): raise PermissionDenied('You are not allowed to create a document') # TODO: see for permission issues if request.method == 'POST': form_instance = form(user=user, data=request.POST, files=request.FILES or None, ) if form_instance.is_valid(): form_instance.save() return json_update_from_widget_response(form_instance.instance) else: form_instance = form(user=user) return generic.inner_popup( request, template, {'form': form_instance, 'title': title, 'submit_label': submit_label, }, is_valid=form_instance.is_valid(), reload=False, delegate_reload=True, )
def form_valid(self, form): super().form_valid(form=form) return json_update_from_widget_response(form.instance)
def form_valid(self, form): super().form_valid(form=form) return json_update_from_widget_response(self.object)