Commits

Alex Robbins  committed abdb0e7

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

  • Participants
  • Parent commits 73251a3

Comments (0)

Files changed (2)

File 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);

File 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):
     """