admin.py 706 Bytes
Newer Older
1
from django.contrib import admin
2
from django.utils.translation import ugettext_lazy as _
3

4
from .models import ListAlias, MailingList, VerbatimAddress
5
6
7
8
9
10
11
12
13
14
15


class VerbatimAddressInline(admin.TabularInline):
    model = VerbatimAddress


class ListAliasInline(admin.TabularInline):
    model = ListAlias


@admin.register(MailingList)
16
class MailingListAdmin(admin.ModelAdmin):
17
    filter_horizontal = ('members',)
18
    inlines = (VerbatimAddressInline, ListAliasInline)
19
20
21
22
23
24
    list_display = ('name', 'alias_names',)
    search_fields = ['name', 'prefix', 'aliasses__alias']

    def alias_names(self, obj):
        return [x.alias for x in obj.aliasses.all()]
    alias_names.short_description = _('List aliasses')