Browse Source

Improve admin UI for offers and subscriptions

Baptiste Jonglez 11 years ago
parent
commit
bf2983321c
4 changed files with 17 additions and 5 deletions
  1. 2 1
      coin/offers/admin.py
  2. 4 3
      coin/offers/models.py
  3. 10 0
      coin/vpn/admin.py
  4. 1 1
      coin/vpn/models.py

+ 2 - 1
coin/offers/admin.py

@@ -14,8 +14,9 @@ class IPSubnetInline(admin.TabularInline):
 
 class OfferAdmin(admin.ModelAdmin):
     list_display = ('type', 'name', 'billing_period', 'period_fees',
-                    'initial_fees')
+                    'initial_fees', 'backend')
     list_display_links = ('name',)
+    list_filter = ('type',)
     search_fields = ['name']
 
     def get_readonly_fields(self, request, obj=None):

+ 4 - 3
coin/offers/models.py

@@ -28,7 +28,7 @@ class Offer(models.Model):
     name = models.CharField(max_length=255, blank=False, null=False,
                             verbose_name='Nom de l\'offre')
     type = models.CharField(max_length=50,
-                            verbose_name="Type of offer, for instance technology used (informative only)")
+                            help_text="Type of offer, for instance technology used (informative only)")
     billing_period = models.IntegerField(blank=False, null=False, default=1,
                                          verbose_name='Période de facturation',
                                          help_text='en mois')
@@ -46,8 +46,9 @@ class Offer(models.Model):
     backend = models.CharField(max_length=50, choices=OFFER_BACKEND_CHOICES)
 
     def __unicode__(self):
-        return u'%s - %d€ / %im [%s]' % (self.name, self.period_fees,
-                                          self.billing_period, self.type)
+        return u'%s : %s - %d€ / %im [%s]' % (self.type, self.name,
+                                              self.period_fees,
+                                              self.billing_period, self.backend)
 
     class Meta:
         verbose_name = 'offre'

+ 10 - 0
coin/vpn/admin.py

@@ -4,6 +4,16 @@ from coin.vpn.models import VPNSubscription
 
 # TODO: allow to regenerate IP endpoints (checkbox?)
 class VPNAdmin(admin.ModelAdmin):
+    list_display = ('administrative_subscription', 'activated', 'login',
+                    'ipv4_endpoint', 'ipv6_endpoint', 'comment')
+    list_filter = ('activated',)
+    search_fields = ('login', 'comment',
+                     # TODO: searching on member directly doesn't work
+                     'administrative_subscription__member__first_name',
+                     'administrative_subscription__member__last_name',
+                     'administrative_subscription__member__email')
+
+
     def get_readonly_fields(self, request, obj=None):
         if obj:
             return ['login',]

+ 1 - 1
coin/vpn/models.py

@@ -112,7 +112,7 @@ class VPNSubscription(CoinLdapSyncModel):
                     raise ValidationError("Endpoint {} is not in an attributed range".format(endpoint))
 
     def __unicode__(self):
-        return self.login
+        return 'VPN ' + self.login
 
 
 class LdapVPNConfig(ldapdb.models.Model):