"""Form used for not editing an Image."""
def __init__(self, *args, **kwargs):
- ret = super(ReadonlyImageForm, self).__init__(*args, **kwargs)
+ super(ReadonlyImageForm, self).__init__(*args, **kwargs)
for field in self.fields.values():
field.widget.attrs.update({"disabled": "disabled"})
- return ret
+
+
+class MarkFinalForm(forms.Form):
+ username = forms.CharField(initial='lipszyc')
+ comment = forms.CharField(initial=u'Ostateczna akceptacja merytoryczna przez kierownika literackiego.')
+ books = forms.CharField(widget=forms.Textarea, help_text=u'linki do książek w redakcji, po jednym na wiersz')
+
+ def clean_books(self):
+ books_value = self.cleaned_data['books']
+ slugs = [line.split('/')[-2] for line in books_value.split('\n') if line.strip()]
+ books = Book.objects.filter(slug__in=slugs)
+ if len(books) != len(slugs):
+ raise forms.ValidationError(
+ 'Incorrect slug(s): %s' % ' '.join(slug for slug in slugs if not Book.objects.filter(slug=slug)))
+ return books
+
+ def clean_username(self):
+ username = self.cleaned_data['username']
+ if not User.objects.filter(username=username):
+ raise forms.ValidationError('Invalid username')
+ return username
+
+ def save(self):
+ for book in self.cleaned_data['books']:
+ for chunk in book.chunk_set.all():
+ src = chunk.head.materialize()
+ chunk.commit(
+ text=src,
+ author=User.objects.get(username=self.cleaned_data['username']),
+ description=self.cleaned_data['comment'],
+ tags=[Chunk.tag_model.objects.get(slug='editor-proofreading')],
+ publishable=True
+ )
--- /dev/null
+{% extends "catalogue/base.html" %}
+
+{% block titleextra %}Oznacz książki{% endblock %}
+
+
+{% block leftcolumn %}
+
+<h1>Oznacz książki</h1>
+
+<form method="post" action="">
+ {% csrf_token %}
+ {{ form.as_p }}
+ <input type="submit" value="Oznacz">
+</form>
+
+{% endblock leftcolumn %}
\ No newline at end of file
--- /dev/null
+{% extends "catalogue/base.html" %}
+
+{% block titleextra %}Oznaczono książki{% endblock %}
+
+
+{% block leftcolumn %}
+
+<h1>Oznaczono książki</h1>
+
+<p>Książki zostały oznaczone.</p>
+
+{% endblock leftcolumn %}
\ No newline at end of file
url(r'^track/(?P<slug>[^/]*)/$', PublishTrackFeed()),
url(r'^active/$', 'active_users_list', name='active_users_list'),
+
+ url(r'^mark-final/$', 'mark_final', name='mark_final'),
+ url(r'^mark-final-completed/$', 'mark_final_completed', name='mark_final_completed'),
)
from django.db import transaction
from django import http
from django.http import Http404, HttpResponse, HttpResponseForbidden
+from django.http.response import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.utils.encoding import iri_to_uri
from django.utils.http import urlquote_plus
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.http import require_POST
+from django_cas.decorators import user_passes_test
from apiclient import NotAuthorizedError
from catalogue import forms
from catalogue import helpers
+from catalogue.forms import MarkFinalForm
from catalogue.helpers import active_tab
from catalogue.models import (Book, Chunk, Image, BookPublishRecord,
ChunkPublishRecord, ImagePublishRecord, Project)
})
+@user_passes_test(lambda u: u.is_superuser)
+def mark_final(request):
+ if request.method == 'POST':
+ form = MarkFinalForm(data=request.POST)
+ if form.is_valid():
+ form.save()
+ return HttpResponseRedirect(reverse('mark_final_completed'))
+ else:
+ form = MarkFinalForm()
+ return render(request, 'catalogue/mark_final.html', {'form': form})
+
+
+def mark_final_completed(request):
+ return render(request, 'catalogue/mark_final_completed.html')