admin.py 772 Bytes
Newer Older
okhin's avatar
okhin committed
1
from django.contrib import admin
okhin's avatar
okhin committed
2
from django.utils.translation import ugettext_lazy as _
okhin's avatar
okhin committed
3
4
5

from picampaign.importer.models import Importer

okhin's avatar
okhin committed
6
class ImporterAdmin(admin.ModelAdmin):
okhin's avatar
okhin committed
7
    list_display = ['name', 'kind', 'data_format', 'file', 'url']
okhin's avatar
okhin committed
8
    actions = ['import_action']
okhin's avatar
okhin committed
9

okhin's avatar
okhin committed
10
11
12
13
14
15
16
17
18
19
    def import_action(self, request, queryset):
        """
        We're going to launch the import of data
        """
        for obj in queryset:
            obj.handle()
            self.message_user(request, _("Imported %(last_imported)s of %(last_imported)s contacts") % {
                'last_imported': obj.last_imported,
                'last_count': obj.last_count})
    import_action.short_description = _("Run the selected importers")
okhin's avatar
okhin committed
20

okhin's avatar
okhin committed
21
admin.site.register(Importer, ImporterAdmin)