admin.py 974 Bytes
Newer Older
1
"""The admin interfaces registered by the mailinglists package"""
2
from django.contrib import admin
3
from django.utils.translation import ugettext_lazy as _
4

5
from .models import ListAlias, MailingList, VerbatimAddress
6
7
8


class VerbatimAddressInline(admin.TabularInline):
Joren Vrancken's avatar
Joren Vrancken committed
9
10
    """Class to inline show the VerbatimAddress."""

11
12
13
14
    model = VerbatimAddress


class ListAliasInline(admin.TabularInline):
Joren Vrancken's avatar
Joren Vrancken committed
15
16
    """Class to inline show the ListAlias."""

17
18
19
20
    model = ListAlias


@admin.register(MailingList)
21
class MailingListAdmin(admin.ModelAdmin):
Joren Vrancken's avatar
Joren Vrancken committed
22
23
    """Class to show the mailing lists in the admin."""

24
    filter_horizontal = ('members',)
25
    inlines = (VerbatimAddressInline, ListAliasInline)
26
27
28
29
    list_display = ('name', 'alias_names',)
    search_fields = ['name', 'prefix', 'aliasses__alias']

    def alias_names(self, obj):
Joren Vrancken's avatar
Joren Vrancken committed
30
        """Return list of aliases of obj."""
31
32
        return [x.alias for x in obj.aliasses.all()]
    alias_names.short_description = _('List aliasses')