12345678910111213141516171819202122232425262728293031323334353637383940 |
- # -*- coding: utf-8 -*-
- from __future__ import unicode_literals
- import autocomplete_light
- from django.contrib import admin
- from django.contrib import messages
- from .models import MaillingList
- class MaillingListAdmin(admin.ModelAdmin):
- list_display = ('email', 'verbose_name')
- actions = ['sync_to_server']
- def sync_to_server(self, request, queryset):
- for _list in queryset.all():
- try:
- _list.sync_to_list_server()
- except Exception as e:
- messages.error(
- request,
- 'Impossible de synchroniser la liste {} : "{}"'.format(
- _list, e))
- else:
- messages.success(
- request,
- 'Liste {} synchronisée vers le serveur'.format(
- _list.email))
- sync_to_server.short_description = (
- 'Synchroniser les listes sélectionnées vers le serveur')
- form = autocomplete_light.modelform_factory(
- MaillingList,
- fields='__all__',
- )
- admin.site.register(MaillingList, MaillingListAdmin)
|