From: Marcin Koziej Date: Thu, 10 May 2012 12:46:13 +0000 (+0200) Subject: makr publoshable / not publishable X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/4a7ad5dc7023218af7197cb563e0f2cfb1511897?ds=inline;hp=cfc1eb85823b39e0f767909ccd3a9709a5fd0ec2 makr publoshable / not publishable --- diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 16d11746..657a1257 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -414,6 +414,21 @@ def chunk_mass_edit(request): for c in chunks: c.user = user + status = request.POST.get('status') + if status: + books_affected = set() + for c in chunks: + if status == 'publish': + c.head.publishable = True + c.head.save() + elif status == 'unpublish': + c.head.publishable = False + c.head.save() + c.touch() # cache + books_affected.add(c.book) + for b in books_affected: + b.touch() # cache + for c in chunks: c.save() return HttpResponse("", content_type="text/plain") diff --git a/redakcja/static/js/catalogue/book_list.js b/redakcja/static/js/catalogue/book_list.js index 96809b65..d7256d3b 100644 --- a/redakcja/static/js/catalogue/book_list.js +++ b/redakcja/static/js/catalogue/book_list.js @@ -19,15 +19,21 @@ var set_field = function(key, ops) { - var kp = key.split('_'); - var field = kp[0]; - var idx = parseInt(kp[1]); - var fds = {} fds.stage = ""; fds.user = ""; fds.status = ""; - fds[field] = $("select[name="+field+"] option[value!=]").eq(idx).val(); + + if (key == "publish" || key == "unpublish") { + fds["status"] = key; + } else { + var kp = key.split('_'); + var field = kp[0]; + var idx = parseInt(kp[1]); + + fds[field] = $("select[name="+field+"] option[value!=]").eq(idx).val(); + } + /* fill in the form */ $("#chunk_mass_edit [name=ids]").val(get_ids()); for (var fn in fds) { $("#chunk_mass_edit [name="+fn+"]").val(fds[fn]); @@ -65,10 +71,12 @@ name: "Set user", items: get_items("user"), }, - "status": { - name: "set status", - items: get_items("status"), + "publish": { + name: "Mark publishable", }, + "unpublish": { + name: "Mark not publishable", + }, }, callback: set_field, });