Commits

Josh VanderLinden  committed bef52fa

Made it possible to mass-set the status for articles in the Django admin.
Updated the label for article statuses to describe which statuses are live and
which are not. Fixed a problem with attachment ordering.

  • Participants
  • Parent commits 8a503dd

Comments (0)

Files changed (2)

File articles/admin.py

         queryset.update(is_active=False)
     mark_inactive.short_description = _('Mark select articles as inactive')
 
-    actions = (mark_active, mark_inactive)
+    def get_actions(self, request):
+        actions = super(ArticleAdmin, self).get_actions(request)
+
+        def dynamic(name, status):
+            def status_func(self, request, queryset):
+                queryset.update(status=status)
+
+            status_func.__name__ = name
+            status_func.short_description = _('Set status of selected to "%s"' % status)
+            return status_func
+
+        for status in ArticleStatus.objects.all():
+            name = 'mark_status_%i' % status.id
+            actions[name] = (dynamic(name, status), name, _('Set status of selected to "%s"' % status))
+
+        return actions
+
+    actions = [mark_active, mark_inactive]
 
     def save_model(self, request, obj, form, change):
         """Set the article's author based on the logged in user and make sure at least one site is selected"""

File articles/models.py

         verbose_name_plural = _('Article statuses')
 
     def __unicode__(self):
-        return self.name
+        if self.is_live:
+            return u'%s (live)' % self.name
+        else:
+            return self.name
 
 class ArticleManager(models.Manager):
     def active(self):
     caption = models.CharField(max_length=255, blank=True)
 
     class Meta:
-        ordering = ('-article', 'pk')
+        ordering = ('-article', 'id')
 
     def __unicode__(self):
         return u'%s: %s' % (self.article, self.caption)