admin.py 759 Bytes
Newer Older
1
from django.contrib import admin
2
from django.utils.translation import ugettext_lazy as _
3
from members.models import Member
4

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


class VerbatimAddressInline(admin.TabularInline):
    model = VerbatimAddress


class ListAliasInline(admin.TabularInline):
    model = ListAlias


@admin.register(MailingList)
17
class MailingListAdmin(admin.ModelAdmin):
18
19
    model = Member
    filter_horizontal = ('members',)
20
    inlines = (VerbatimAddressInline, ListAliasInline)
21
22
23
24
25
26
    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')