Add seen count to totd admin
This commit is contained in:
parent
b3a832a420
commit
b73e3778d7
2 changed files with 8 additions and 3 deletions
|
@ -22,11 +22,13 @@ class TipForm(forms.ModelForm):
|
|||
self.fields['view'].widget = forms.Select(choices=url_choices())
|
||||
|
||||
class TipAdmin(admin.ModelAdmin):
|
||||
#raw_id_fields = ('seen_by',)
|
||||
list_filter =('level', 'view')
|
||||
list_display = ('name', 'level', 'view', 'run_start', 'run_end')
|
||||
list_display = ('name', 'level', 'view', 'run_start', 'run_end', 'seen_count')
|
||||
search_fields = ('name', 'view')
|
||||
form = TipForm
|
||||
|
||||
def seen_count(self, tip):
|
||||
return tip.seen_by.count()
|
||||
seen_count.short_description = 'Seen by'
|
||||
|
||||
admin.site.register(Tip, TipAdmin)
|
||||
|
|
|
@ -19,4 +19,7 @@ class Tip(models.Model):
|
|||
seen_by = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='seen_tips', blank=True)
|
||||
|
||||
def tags(self):
|
||||
return settings.MESSAGE_TAGS[self.level]
|
||||
return settings.MESSAGE_TAGS[self.level]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
Loading…
Reference in a new issue