Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'gbirke-bk_695' into devel

  • Loading branch information...
commit bb19f862fb8b54ea97cbb216c040b0bb6e83c013 2 parents c882610 + 4dd9e11
Aleksandar Erkalović aerkalov authored
Showing with 71 additions and 2 deletions.
  1. +58 −0 lib/booki/channels/editor.py
  2. +13 −2 lib/booki/site_static/js/editor.js
58 lib/booki/channels/editor.py
View
@@ -3057,6 +3057,64 @@ def remote_book_status_create(request, message, bookid, version):
"statuses": allStatuses
}
+def remote_book_status_rename(request, message, bookid, version):
+ """
+ Rename book status.
+
+ Sends notification to chat.
+
+ Input:
+ - status_id
+
+ Output:
+ - status
+ - result
+ - statuses
+
+ @type request: C{django.http.HttpRequest}
+ @param request: Client Request object
+ @type message: C{dict}
+ @param message: Message object
+ @type bookid: C{string}
+ @param bookid: Unique Book id
+ @type version: C{string}
+ @param version: Book version
+ @rtype: C{dict}
+ @return: Returns list of all statuses
+ """
+
+ book = models.Book.objects.get(id=bookid)
+
+ bookSecurity = security.getUserSecurityForBook(request.user, book)
+
+ if not bookSecurity.isAdmin():
+ return {"status": False}
+
+ from django.utils.html import strip_tags
+
+ result = True
+
+ try:
+ up = models.BookStatus.objects.get(book = book, id = message["status_id"])
+ up.name = strip_tags(message["status_name"].strip())
+ up.save()
+ except models.BookStatus.DoesNotExist:
+ transaction.rollback()
+ else:
+ transaction.commit()
+
+ allStatuses = [(status.id, status.name) for status in models.BookStatus.objects.filter(book=book).order_by("-weight")]
+
+ sputnik.addMessageToChannel(request,
+ "/booki/book/%s/%s/" % (bookid, version),
+ {"command": "chapter_status_changed",
+ "statuses": allStatuses},
+ myself = False
+ )
+
+ return {"status": True,
+ "result": result,
+ "statuses": allStatuses}
def remote_book_status_remove(request, message, bookid, version):
"""
15 lib/booki/site_static/js/editor.js
View
@@ -1860,8 +1860,19 @@ $(function() {
var i = $(this).attr("name");
var nm = getStatusDescription(i);
var ns = prompt($.booki._('new_status_name', "New status name"), nm);
- if(ns) {
- dial.find("#liststatus_"+i+" .statuslabel").html(escapeJS(ns));
+ if(ns && ns != nm) {
+ $.booki.sendToCurrentBook({'command': 'book_status_rename',
+ 'status_id': i, "status_name": ns},
+ function(data) {
+ if(data.result == false) {
+ alert($.booki._('cant_rename_status', "There was an error renaming the status."));
+ } else {
+ // send event
+ statuses = data.statuses;
+ dial.find("#liststatus_"+i+" .statuslabel").html(escapeJS(ns));
+ }
+ });
+
}
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.