Anonymous avatar Anonymous committed abdb0e7

Adding a better unicode representation for Bookmark objects. Fixed a bug where new title wasn't saved correctly.

Comments (0)

Files changed (2)

admin_tools/media/admin_tools/js/menu.js

  */
 var process_bookmarks = function(url, title, prompt_msg) {
     var $ = jQuery;
+    var new_title;
     $('#bookmark-button').live('click', function(e) {
         var submit_url = $("#bookmark-form").attr('action');
         e.preventDefault();
                 $("#bookmark-form").replaceWith(data.replace('**title**', title));
             }, 'html');
         } else {
-            title = prompt(prompt_msg, title);
-            if (!title) {
+            new_title = prompt(prompt_msg, title);
+            if (!new_title) {
                 return;
             }
             $(this).addClass('bookmarked');
                 $('#navigation-menu li.bookmark').removeClass('disabled');
             }
             $('#navigation-menu li.bookmark ul').append(
-                '<li><a href="' + url + '">' + title + '</a></li>'
+                '<li><a href="' + url + '">' + new_title + '</a></li>'
             );
+            $('#bookmark-form input[name=title]').attr('value', new_title);
             // Save bookmark and switch form
             $.post(submit_url, $("#bookmark-form").serialize(), function(data) {
                 $("#bookmark-form").replaceWith(data);

admin_tools/menu/models.py

     url = models.CharField(max_length=255)
     title = models.CharField(max_length=255)
 
+    def __unicode__(self):
+        return "%s - %s" % (self.title, self.url)
+
+    class Meta:
+        ordering = ('id',)
+
 
 class Menu(object):
     """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.