def revisionform_view(self, request, version, template_name, extra_context=None):
try:
with transaction.atomic():
# Revert the revision.
version.revision.revert(delete=True)
# Run the normal change_view view.
with self._create_revision(request):
response = self.change_view(request, version.object_id, request.path, extra_context)
# Decide on whether the keep the changes.
if request.method == "POST" and response.status_code == 302:
self.revision_context_manager.set_comment(_("Reverted to previous version, saved on %(datetime)s") % {"datetime": localize(version.revision.date_created)})
else:
response.template_name = template_name
response.render()
raise RollBackRevisionView
except RollBackRevisionView:
pass
return response
评论列表
文章目录