admin nice as the milky way
This commit is contained in:
parent
e0a9f9df41
commit
b2000edb89
|
@ -15,9 +15,18 @@ admin.site.register(Feed, FeedAdmin)
|
|||
|
||||
|
||||
class ItemAdmin(admin.ModelAdmin):
|
||||
list_display = ['mark', 'title_with_link', 'expire_date', 'published_date', 'source']
|
||||
list_per_page = 20
|
||||
actions_on_top = True
|
||||
actions_on_bottom = True
|
||||
save_on_top = True
|
||||
readonly_fields = ['link', 'source']
|
||||
list_display = ['mark', 'title', 'direct_link' ,'expire_date_nice',
|
||||
'published_date', 'source']
|
||||
list_display_links = ['title']
|
||||
list_filter = ['mark', 'source', 'expire_date']
|
||||
list_editable = ['mark']
|
||||
ordering = ['-expire_date']
|
||||
date_hierarchy = 'expire_date'
|
||||
actions = ['mark_item', 'unmark_item']
|
||||
|
||||
def mark_item(modeladmin, request, queryset):
|
||||
|
|
|
@ -69,9 +69,19 @@ class Item(models.Model):
|
|||
source = models.ForeignKey(Feed)
|
||||
add_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def title_with_link(self):
|
||||
return '<a href="%s">%s</a>' % (self.link, self.title)
|
||||
title_with_link.short_description = "title"
|
||||
title_with_link.allow_tags = True
|
||||
title_with_link.admin_order_field = 'title'
|
||||
def direct_link(self):
|
||||
return '<a href="%s">direct<br />link</a>' % self.link
|
||||
direct_link.short_description = ''
|
||||
direct_link.allow_tags = True
|
||||
direct_link.admin_order_field = 'title'
|
||||
|
||||
def expire_date_nice(self):
|
||||
if self.expire_date == UNKNOWN_DATE:
|
||||
return 'unknown'
|
||||
else:
|
||||
return self.expire_date
|
||||
expire_date_nice.short_description = 'expire date'
|
||||
expire_date_nice.allow_tags = True
|
||||
expire_date_nice.admin_order_field = 'expire_date'
|
||||
|
||||
|
||||
|
|
Reference in New Issue