X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..cb3eefff46f3ae0b331f7babbd111a3735e22652:/src/wiki_img/views.py diff --git a/src/wiki_img/views.py b/src/wiki_img/views.py index 2b8dd67e..7fc5c700 100644 --- a/src/wiki_img/views.py +++ b/src/wiki_img/views.py @@ -1,9 +1,12 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# import os import functools import logging logger = logging.getLogger("fnp.wiki_img") -from django.core.urlresolvers import reverse +from django.urls import reverse from wiki.helpers import (JSONResponse, JSONFormInvalid, JSONServerError, ajax_require_permission) @@ -14,7 +17,7 @@ from django.conf import settings from django.utils.formats import localize from django.utils.translation import ugettext as _ -from catalogue.models import Image +from documents.models import Image from wiki import forms from wiki import nice_diff from wiki_img.forms import ImageSaveForm @@ -36,7 +39,7 @@ def editor(request, slug, template_name='wiki_img/document_details.html'): "text_revert": forms.DocumentTextRevertForm(prefix="textrevert"), "pubmark": forms.DocumentPubmarkForm(prefix="pubmark"), }, - 'can_pubmark': request.user.has_perm('catalogue.can_pubmark_image'), + 'can_pubmark': request.user.has_perm('documents.can_pubmark_image'), 'REDMINE_URL': settings.REDMINE_URL, }) @@ -63,7 +66,7 @@ def text(request, image_id): if request.method == 'POST': form = ImageSaveForm(request.POST, user=request.user, prefix="textsave") if form.is_valid(): - if request.user.is_authenticated(): + if request.user.is_authenticated: author = request.user else: author = None @@ -76,7 +79,7 @@ def text(request, image_id): stage = form.cleaned_data['stage_completed'] tags = [stage] if stage else [] publishable = (form.cleaned_data['publishable'] and - request.user.has_perm('catalogue.can_pubmark_image')) + request.user.has_perm('documents.can_pubmark_image')) doc.commit(author=author, text=text, parent=parent, @@ -129,7 +132,7 @@ def history(request, object_id): "author": change.author_str(), "date": localize(change.created_at), "publishable": _("Publishable") + "\n" if change.publishable else "", - "tag": ',\n'.join(unicode(tag) for tag in change.tags.all()), + "tag": ',\n'.join(str(tag) for tag in change.tags.all()), }) return JSONResponse(changes) @@ -148,7 +151,7 @@ def revert(request, object_id): comment = form.cleaned_data['comment'] comment += "\n#revert to %s" % revision - if request.user.is_authenticated(): + if request.user.is_authenticated: author = request.user else: author = None @@ -193,7 +196,7 @@ def diff(request, object_id): @require_POST -@ajax_require_permission('catalogue.can_pubmark_image') +@ajax_require_permission('documents.can_pubmark_image') def pubmark(request, object_id): form = forms.DocumentPubmarkForm(request.POST, prefix="pubmark") if form.is_valid():