Commit 9771a7c0 authored by Tom van Bussel's avatar Tom van Bussel
Browse files

Merge branch 'fix/pushnotif-admin' into 'master'

Fix push notifications admin search

Closes #540

See merge request thalia/concrexit!619
parents 5f5421ca b12038a3
......@@ -7,22 +7,26 @@ from pushnotifications.models import Message
@admin.register(models.Device)
class DeviceAdmin(admin.ModelAdmin):
list_display = ('user', 'type', 'active', 'date_created')
list_display = ('name', 'type', 'active', 'date_created')
list_filter = ('active', 'type')
actions = ('enable', 'disable')
search_fields = ('name', 'device_id', 'user__username')
ordering = ('user__first_name', )
search_fields = ('registration_id', 'user__username',
'user__first_name', 'user__last_name')
def enable(self, request, queryset):
queryset.update(active=True)
enable.short_description = _('Enable selected devices')
def disable(self, request, queryset):
queryset.update(active=False)
disable.short_description = _('Disable selected devices')
def name(self, obj):
return '{} ({})'.format(obj.user.get_full_name(), obj.user.username)
name.short_description = _('Name')
name.admin_order_field = 'user__first_name'
@admin.register(models.Message)
class MessageAdmin(admin.ModelAdmin):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment