Created
February 1, 2016 09:42
-
-
Save LegoStormtroopr/7d273d8bd3297e2ebfb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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