def form_valid(self, form): self.object = form.save(commit=False) self.object.created_by = self.request.user if form.cleaned_data["publish"]: self.object.publish_date = timezone.now().date() self.object.save() form.save_m2m() # @@@ Publish forms used to: # for contrib in get_contrib(self.lang): # entry.contributors.add(contrib) if self.object.publish_date is not None: published.send(sender=self, official_resource=self.object) return redirect(self.get_success_url())
def form_valid(self, form): self.object = form.save(commit=False) published_flag = False if form.cleaned_data["publish"] and self.object.publish_date is None: self.object.publish_date = timezone.now().date() published_flag = True self.object.save() form.save_m2m() # @@@ Publish forms used to: # for contrib in get_contrib(self.lang): # entry.contributors.add(contrib) if published_flag: published.send(sender=self, official_resource=self.object) return redirect("oresource_list")