diff --git a/portail_citoyen_announces/admin.py b/portail_citoyen_announces/admin.py index d08799d..58f5f94 100644 --- a/portail_citoyen_announces/admin.py +++ b/portail_citoyen_announces/admin.py @@ -74,7 +74,7 @@ class CategoryAdmin(admin.ModelAdmin): class SubscriptionAdmin(admin.ModelAdmin): list_filter = [ 'category' ] - list_display = [ 'category', 'transport', 'identifier', 'user', 'created' ] + list_display = [ 'category', 'transport', 'real_identifier', 'user_display_name', 'created' ] admin.site.register(models.Announce, AnnounceAdmin) diff --git a/portail_citoyen_announces/locale/fr/LC_MESSAGES/django.po b/portail_citoyen_announces/locale/fr/LC_MESSAGES/django.po index 7c9271c..82c633e 100644 --- a/portail_citoyen_announces/locale/fr/LC_MESSAGES/django.po +++ b/portail_citoyen_announces/locale/fr/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: portail-citoyen-announces 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-06-24 11:20+0200\n" -"PO-Revision-Date: 2013-06-24 11:20+0200\n" +"POT-Creation-Date: 2013-07-30 15:50+0200\n" +"PO-Revision-Date: 2013-07-30 15:51+0200\n" "Last-Translator: Benjamin Dauvergne \n" "Language: fr\n" "MIME-Version: 1.0\n" @@ -16,15 +16,15 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: admin.py:22 +#: admin.py:23 msgid "Send by {0}" msgstr "Envoyé via {0}" -#: admin.py:59 +#: admin.py:60 msgid "extract" msgstr "extrait" -#: admin.py:63 models.py:75 +#: admin.py:64 models.py:75 msgid "sent" msgstr "envoyé via" @@ -48,7 +48,7 @@ msgstr "" msgid "name" msgstr "nom" -#: models.py:18 models.py:83 +#: models.py:18 models.py:83 models.py:100 msgid "identifier" msgstr "identifiant" @@ -57,6 +57,8 @@ msgid "" "the identifier is used to find templates for sending announces; it can only " "contain lowercase letter, digits or underscores" msgstr "" +"cet identifiant est utilisé pour trouvé les modèles pour créer les messages d'annonces; " +"il ne peut contenirs que des minuscules, des chiffres et des caractères souligné." #: models.py:30 models.py:51 models.py:82 msgid "category" @@ -110,7 +112,7 @@ msgstr "date d'envoi" msgid "result" msgstr "résultat" -#: models.py:80 +#: models.py:80 models.py:106 msgid "user" msgstr "utilisateur" @@ -118,7 +120,11 @@ msgstr "utilisateur" msgid "ex.: email, mobile phone number, jabber id" msgstr "ex.: courriel, numéro de téléphone mobile, identifiant jabber" -#: models.py:98 +#: models.py:104 +msgid "anonymous" +msgstr "anonyme" + +#: models.py:109 msgid "subscription" msgstr "abonnement" @@ -126,11 +132,11 @@ msgstr "abonnement" msgid "Homepage" msgstr "Page d'accueil" -#: transports.py:93 +#: transports.py:96 msgid "SMS" msgstr "" -#: transports.py:176 +#: transports.py:184 msgid "Email" msgstr "Courriel" @@ -147,6 +153,3 @@ msgstr "Catégorie" #: templates/portail_citoyen_announces/subscription_edit.html:31 msgid "Modify" msgstr "Modifier" - -#~ msgid "sms" -#~ msgstr "SMS" diff --git a/portail_citoyen_announces/models.py b/portail_citoyen_announces/models.py index 320ed12..952c21e 100644 --- a/portail_citoyen_announces/models.py +++ b/portail_citoyen_announces/models.py @@ -94,6 +94,17 @@ class Subscription(TimeStampedModel): transport=self.transport, identifier=self.identifier) + def real_identifier(self): + transport = transports.get_transport(self.transport) + return transport.get_identifier_from_subscription(self) + real_identifier.short_description = _('identifier') + + def user_display_name(self): + if not self.user: + return _('anonymous') + return self.user.get_full_name() or self.user.username + user_display_name.short_description = _('user') + class Meta: verbose_name = _('subscription') ordering = ('-created',) diff --git a/portail_citoyen_announces/transports.py b/portail_citoyen_announces/transports.py index 2acfcd4..e98cc3e 100644 --- a/portail_citoyen_announces/transports.py +++ b/portail_citoyen_announces/transports.py @@ -24,9 +24,9 @@ logger = logging.getLogger() def get_transport_choices(include=[], exclude=[]): for transport in get_transports(): - if include and transport.identifer not in include: + if include and transport.identifier not in include: continue - if exclude and transport.identifer in exclude: + if exclude and transport.identifier in exclude: continue for identifier, display_name in transport.get_choices(): yield (identifier, display_name) @@ -80,6 +80,9 @@ class HomepageTransport(object): def get_choices(self): return (('homepage', _('Homepage')),) + def get_identifier_from_subscription(self, subscription): + return u'homepage' + class SMSTransport(object): body_template_list = [ @@ -155,6 +158,11 @@ class SMSTransport(object): transport=self.identifier, result=msg) + def get_identifier_from_subscription(self, subscription): + if subscription.user: + return subscription.user.mobile + return subscription.identifier + class EmailTransport(object): identifier = 'email' @@ -224,3 +232,8 @@ class EmailTransport(object): announce=announce, transport=self.identifier, result=msg) + + def get_identifier_from_subscription(self, subscription): + if subscription.user: + return subscription.user.email + return subscription.identifier