Exemple #1
0
 def publish(self, request, queryset):
     for material in queryset:
         try:
             draft = AuthoredMaterialDraft.objects.get(material=material)
         except AuthoredMaterialDraft.DoesNotExist:
             continue
         AuthoredMaterial.publish_draft(draft)
Exemple #2
0
 def form_valid(self, form):
     force = self.request.POST.get("force_save")
     if self.request.is_ajax() and not force and self.request.POST.get("checksum") != self.get_object().checksum:
         return JsonResponse(dict(
             status="error",
             message=u"",
             reason="checksum",
         ))
     self.object = form.save()
     if "preview" in self.request.GET:
         return redirect(self.object.get_absolute_url())
     if self.request.is_ajax():
         return JsonResponse(dict(
             status="success",
             message=u"Saved.",
             checksum=self.object.checksum,
         ))
     material = AuthoredMaterial.publish_draft(self.object)
     return redirect(material.get_absolute_url())