730 |
730 |
731 template_dict = {'text' : text, 'form' : form} |
731 template_dict = {'text' : text, 'form' : form} |
732 |
732 |
733 return render_to_response('site/text_edit.html', template_dict , context_instance=RequestContext(request)) |
733 return render_to_response('site/text_edit.html', template_dict , context_instance=RequestContext(request)) |
734 |
734 |
735 # TODO: modif de la base => if POST |
|
736 @has_perm_on_text('can_edit_text') |
735 @has_perm_on_text('can_edit_text') |
737 def text_revert(request, key, text_version_key): |
736 def text_revert(request, key, text_version_key): |
|
737 if request.method != 'POST': |
|
738 raise UnauthorizedException('Unauthorized') |
|
739 |
738 text = get_text_by_keys_or_404(key) |
740 text = get_text_by_keys_or_404(key) |
739 |
741 |
740 text_version = text.revert_to_version(text_version_key) |
742 text_version = text.revert_to_version(text_version_key) |
741 display_message(request, _(u'A new version (copied from version %(version_title)s) has been created') % {'version_title':text_version.title}) |
743 display_message(request, _(u'A new version (copied from version %(version_title)s) has been created') % {'version_title':text_version.title}) |
742 |
744 |
743 return HttpResponseRedirect(reverse('text-history', args=[text.key])) |
745 return HttpResponse('') # no redirect because this is called by js |
744 |
746 |
745 @has_perm_on_text('can_view_text') |
747 @has_perm_on_text('can_view_text') |
746 def text_attach(request, key, attach_key): |
748 def text_attach(request, key, attach_key): |
747 attach = Attachment.objects.get(key=attach_key, text_version__text__key=key) |
749 attach = Attachment.objects.get(key=attach_key, text_version__text__key=key) |
748 content = file(attach.data.path).read() |
750 content = file(attach.data.path).read() |