X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/72afcd696d097e09c792c395b8e2149820fefe2c..2be4bf49bd3bb862ffd7ede2914565f9136e7ba2:/apps/catalogue/views.py diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 1436fc02..ebc35751 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -25,7 +25,7 @@ from apiclient import NotAuthorizedError from catalogue import forms from catalogue import helpers from catalogue.helpers import active_tab -from catalogue.models import Book, Chunk, BookPublishRecord, ChunkPublishRecord +from catalogue.models import Book, Chunk, BookPublishRecord, ChunkPublishRecord, Project from fileupload.views import UploadView # @@ -352,6 +352,7 @@ def chunk_add(request, slug, chunk): }) +@login_required def chunk_edit(request, slug, chunk): try: doc = Chunk.get(slug, chunk) @@ -389,6 +390,7 @@ def chunk_edit(request, slug, chunk): @transaction.commit_on_success +@login_required def chunk_mass_edit(request): if request.method == 'POST': ids = map(int, filter(lambda i: i.strip()!='', request.POST.get('ids').split(','))) @@ -429,6 +431,17 @@ def chunk_mass_edit(request): for b in books_affected: b.touch() # cache + project_id = request.POST.get('project') + if project_id: + try: + project = Project.objects.get(pk=int(project_id)) + except (Project.DoesNotExist, ValueError), e: + project = None + for c in chunks: + book = c.book + book.project = project + book.save() + for c in chunks: c.save() return HttpResponse("", content_type="text/plain")