Browse Source

UI tweaks for mail-list management

1. Hide noisy redundant titles on top of each inline (admin-wide change)
2. Hide confusing « add » and « edit » buttons in mail-list subscribers add
  form
3. Allow to add several subscriptions at once
4. Use different labels depending on which side we are using admin
  inlines (list or member ?)
5. Member view: display currently subscriptions before add form
Jocelyn Delalande 6 years ago
parent
commit
ee3f6cf142
4 changed files with 39 additions and 8 deletions
  1. 18 0
      coin/static/css/admin-local.css
  2. 1 0
      coin/templates/admin/base_site.html
  3. 18 6
      maillists/admin.py
  4. 2 2
      maillists/models.py

+ 18 - 0
coin/static/css/admin-local.css

@@ -0,0 +1,18 @@
+/* Remove the titles from inlines elements
+
+Generaly, this is redundant, with fields content */
+
+form .inline-group .inline-related td.original p, /* TabularInline */
+form .inline-group .inline-related h3 {           /* TabularStacked */
+    display: none;
+}
+.inline-group .tabular tr.has_original td {
+    padding-top: 5px;
+}
+
+/* Remove « Add » and « Edit » icons near member search in mailling list members management
+*/
+.inline-related.dynamic-maillinglistsubscription_set .related-widget-wrapper-link.change-related ,
+.inline-related.dynamic-maillinglistsubscription_set .related-widget-wrapper-link.add-related {
+    display: none;
+}

+ 1 - 0
coin/templates/admin/base_site.html

@@ -5,6 +5,7 @@
 
 
 {% block extrahead %}
 {% block extrahead %}
     <link rel="stylesheet" type="text/css" href="{% static 'hijack/hijack-styles.css' %}" />
     <link rel="stylesheet" type="text/css" href="{% static 'hijack/hijack-styles.css' %}" />
+    <link rel="stylesheet" type="text/css" href="{% static 'css/admin-local.css' %}" />
     <script src="{% static "js/vendor/jquery.js" %}" type="text/javascript"></script>
     <script src="{% static "js/vendor/jquery.js" %}" type="text/javascript"></script>
     <link rel="stylesheet" href="{% static "css/font-awesome.min.css"%}" />
     <link rel="stylesheet" href="{% static "css/font-awesome.min.css"%}" />
     {% include 'autocomplete_light/static.html' %}
     {% include 'autocomplete_light/static.html' %}

+ 18 - 6
maillists/admin.py

@@ -14,11 +14,10 @@ import coin.members.admin
 
 
 class AddMaillingListSubscriptionInline(admin.StackedInline):
 class AddMaillingListSubscriptionInline(admin.StackedInline):
     model = MaillingListSubscription
     model = MaillingListSubscription
-    extra = 1
-    max_num = 1
+    extra = 0
     fields = ('member', 'maillinglist')
     fields = ('member', 'maillinglist')
-    verbose_name_plural = "Ajouter un abonnement à la liste mail"
-    verbose_name = "Ajouter un abonnement"
+    verbose_name_plural = "Ajouter un abonnement à une liste mail"
+    verbose_name = "abonnement"
 
 
     form = autocomplete_light.modelform_factory(MaillingListSubscription, fields='__all__')
     form = autocomplete_light.modelform_factory(MaillingListSubscription, fields='__all__')
 
 
@@ -30,6 +29,11 @@ class AddMaillingListSubscriptionInline(admin.StackedInline):
         return False
         return False
 
 
 
 
+class AddSubscriberInline(AddMaillingListSubscriptionInline):
+    verbose_name_plural = "Ajouter des abonné·e·s"
+    verbose_name = "abonné·e"
+
+
 class MaillingListSubscriptionInline(admin.TabularInline):
 class MaillingListSubscriptionInline(admin.TabularInline):
     model = MaillingListSubscription
     model = MaillingListSubscription
 
 
@@ -39,6 +43,11 @@ class MaillingListSubscriptionInline(admin.TabularInline):
         return False
         return False
 
 
 
 
+class SubscribersInline(MaillingListSubscriptionInline):
+    verbose_name_plural = "Abonné·e·s"
+    verbose_name = "abonné·e"
+
+
 class MaillingListAdmin(admin.ModelAdmin):
 class MaillingListAdmin(admin.ModelAdmin):
     list_display = ('email', 'verbose_name')
     list_display = ('email', 'verbose_name')
     actions = ['sync_to_server']
     actions = ['sync_to_server']
@@ -60,7 +69,7 @@ class MaillingListAdmin(admin.ModelAdmin):
     sync_to_server.short_description = (
     sync_to_server.short_description = (
         'Synchroniser les listes sélectionnées vers le serveur')
         'Synchroniser les listes sélectionnées vers le serveur')
 
 
-    inlines = [AddMaillingListSubscriptionInline, MaillingListSubscriptionInline,]
+    inlines = [AddSubscriberInline, SubscribersInline]
 
 
     def change_view(self, request, object_id, *args, **kwargs):
     def change_view(self, request, object_id, *args, **kwargs):
         try:
         try:
@@ -83,7 +92,10 @@ admin.site.register(MaillingList, MaillingListAdmin)
 
 
 
 
 class MemberAdmin(coin.members.admin.MemberAdmin):
 class MemberAdmin(coin.members.admin.MemberAdmin):
-    inlines = coin.members.admin.MemberAdmin.inlines + [AddMaillingListSubscriptionInline, MaillingListSubscriptionInline]
+    inlines = coin.members.admin.MemberAdmin.inlines + [
+        MaillingListSubscriptionInline,
+        AddMaillingListSubscriptionInline,
+    ]
 
 
     def change_view(self, request, *args, **kwargs):
     def change_view(self, request, *args, **kwargs):
         try:
         try:

+ 2 - 2
maillists/models.py

@@ -21,7 +21,7 @@ class MaillingListSubscription(models.Model):
 
 
     class Meta:
     class Meta:
         verbose_name = 'abonnement à une liste mail'
         verbose_name = 'abonnement à une liste mail'
-        verbose_name_plural = 'abonnements à des listes mail'
+        verbose_name_plural = 'abonnements aux listes mail'
         unique_together = ('member', 'maillinglist')
         unique_together = ('member', 'maillinglist')
 
 
     def __str__(self):
     def __str__(self):
@@ -32,7 +32,7 @@ class MaillingList(models.Model):
         'identifiant technique', max_length=50,
         'identifiant technique', max_length=50,
         help_text=(
         help_text=(
             "c'est l'identifiant qui servira à "
             "c'est l'identifiant qui servira à "
-            "communiquer avec le système de mailling-list"
+            "communiquer avec le serveur de liste mail "
             "(typiquement, la partie avant le \"@\" dans l'adress )"
             "(typiquement, la partie avant le \"@\" dans l'adress )"
         )
         )
     )
     )