Commits

Ian George committed e7ae1bd

Added ordinal field to specify tag order

  • Participants
  • Parent commits 11c5916

Comments (0)

Files changed (11)

File tagging/__init__.pyc

Binary file modified.

File tagging/admin.py

 
 class TagAdmin(admin.ModelAdmin):
     form = TagAdminForm
+    list_display = ['namespace', 'name', 'value', 'ordinal']
+    list_filter = ['namespace',]
+    list_editable = ['ordinal',]
 
 admin.site.register(TaggedItem)
 admin.site.register(Tag, TagAdmin)

File tagging/admin.pyc

Binary file modified.

File tagging/fields.pyc

Binary file modified.

File tagging/forms.pyc

Binary file modified.

File tagging/managers.pyc

Binary file modified.

File tagging/models.py

             %%s
         GROUP BY %(tag)s.id, %(tag)s.namespace, %(tag)s.name, %(tag)s.value
         %%s
-        ORDER BY %(tag)s.namespace, %(tag)s.name, %(tag)s.value ASC""" % {
+        ORDER BY %(tag)s.ordinal, %(tag)s.namespace, %(tag)s.name, %(tag)s.value ASC""" % {
             'tag': qn(self.model._meta.db_table),
             'count_sql': counts and (', COUNT(%s)' % model_pk) or '',
             'tagged_item': qn(TaggedItem._meta.db_table),
           AND %(tag)s.id NOT IN (%(tag_id_placeholders)s)
         GROUP BY %(tag)s.id, %(tag)s.namespace, %(tag)s.name, %(tag)s.value
         %(min_count_sql)s
-        ORDER BY %(tag)s.name ASC""" % {
+        ORDER BY %(tag)s.ordinal ASC, %(tag)s.name ASC""" % {
             'tag': qn(self.model._meta.db_table),
             'count_sql': counts and ', COUNT(%s.object_id)' % tagged_item_table or '',
             'tagged_item': tagged_item_table,
     namespace = models.CharField(_('namespace'), max_length=50, null=True, blank=True, db_index=True)
     name      = models.CharField(_('name'), max_length=50, db_index=True)
     value     = models.CharField(_('value'), max_length=50, null=True, blank=True, db_index=True)
+    ordinal   = models.IntegerField(null=True, blank=True, db_index=True)
 
     objects = TagManager()
 
     class Meta:
         unique_together = (('namespace', 'name', 'value'),)
-        ordering = ('namespace', 'name', 'value')
+        ordering = ('ordinal', 'namespace', 'name', 'value')
         verbose_name = _('tag')
         verbose_name_plural = _('tags')
 

File tagging/models.pyc

Binary file modified.

File tagging/settings.pyc

Binary file modified.

File tagging/templatetags/__init__.pyc

Binary file modified.

File tagging/utils.pyc

Binary file modified.