X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5a649a9e943f331ec61d2e86c3840397777ccfb6..58a9ee33481846aca907cae135291852e5e6392a:/apps/catalogue/views.py diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index d2e135c5..1f3130a0 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -24,6 +24,7 @@ from django.views.decorators.http import require_POST from unidecode import unidecode from catalogue import forms +from catalogue.filters import DocumentFilterSet from catalogue.forms import TagMultipleForm, TagSingleForm from catalogue.helpers import active_tab from catalogue.models import Category @@ -94,6 +95,9 @@ def create_missing(request): doc = Document.objects.create(**kwargs) + for tag_form in tag_forms: + tag_form.save(instance=doc) + cover = request.FILES.get('cover') if cover: uppath = 'uploads/%d/' % doc.pk @@ -116,9 +120,7 @@ def create_missing(request): ''' + form.cleaned_data['publisher'] + ''' ''' + form.cleaned_data['description'] + ''' - ''' + form.cleaned_data['language'] + ''' - ''' + form.cleaned_data['rights'] + ''' - ''' + form.cleaned_data['audience'] + ''' + ''' + '\n'.join(tag_form.metadata_rows() for tag_form in tag_forms) + ''' ''' + cover_url + '''
''' + title + '''
@@ -148,8 +150,9 @@ def create_missing(request): form = forms.DocumentCreateForm(initial={'owner_organization': org}) tag_forms = [ - (TagMultipleForm if category.multiple else TagSingleForm)(category=category, prefix=category.dc_tag) - for category in Category.objects.all()] + (TagMultipleForm if category.multiple else TagSingleForm)( + category=category, tutorial_no=i, prefix=category.dc_tag) + for i, category in enumerate(Category.objects.all(), start=2)] return render(request, "catalogue/document_create_missing.html", { "form": form, @@ -508,12 +511,16 @@ def fork(request, pk): def upcoming(request): + f = DocumentFilterSet(request.GET, queryset=Document.objects.filter(deleted=False).filter(publish_log=None)) return render(request, "catalogue/upcoming.html", { - 'objects_list': Document.objects.filter(deleted=False).filter(publish_log=None), + 'filter_set': f, + 'link_url': 'catalogue_preview', }) def finished(request): + f = DocumentFilterSet(request.GET, queryset=Document.objects.filter(deleted=False).exclude(publish_log=None)) return render(request, "catalogue/finished.html", { - 'objects_list': Document.objects.filter(deleted=False).exclude(publish_log=None), + 'filter_set': f, + 'link_url': 'catalogue_html', })