Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def view_historic_reversion(request, iid, vid):
item = get_object_or_404(MDR._concept, pk=iid).item
if not user_can_view(request.user, item):
if request.user.is_anonymous():
return redirect(reverse('friendly_login') + '?next=%s' % request.path)
else:
raise PermissionDenied
old_item = default_revision_manager.get_for_object_reference(
item.__class__,
item.pk,
).filter(id=int(vid)).first()
if old_item is None:
raise Http404
else:
old_item = old_item.object_version.object
old_item._meta = item._meta
old_item.id = item.id
default_template = "%s/concepts/%s.html" % (item.__class__._meta.app_label, item.__class__._meta.model_name)
template = select_template([default_template, item.template])
context = RequestContext(
request,
{
'item': old_item,
'original_item':item,
}
)
return HttpResponse(template.render(context))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment