Browse Source

Merge branch 'subscriptions-id' of opi/coin into master

jocelyn 8 years ago
parent
commit
c7a20f297d

+ 1 - 0
README.md

@@ -277,6 +277,7 @@ List of available settings in your `settings_local.py` file.
 - `EXTRA_TEMPLATE_DIRS`: See *Customizing templates*
 - `LDAP_ACTIVATE`: See *LDAP*
 - `MEMBER_MEMBERSHIP_INFO_URL`: Link to a page with information on how to become a member or pay the membership fee
+- `SUBSCRIPTION_REFERENCE`: Pattern used to display a unique reference for any subscription. Helpful for bank wire transfer identification
 
 More information
 ================

+ 3 - 3
coin/offers/admin.py

@@ -13,7 +13,7 @@ import autocomplete_light
 
 
 class OfferAdmin(admin.ModelAdmin):
-    list_display = ('get_configuration_type_display', 'name', 'billing_period', 'period_fees',
+    list_display = ('get_configuration_type_display', 'name', 'reference', 'billing_period', 'period_fees',
                     'initial_fees')
     list_display_links = ('name',)
     list_filter = ('configuration_type',)
@@ -28,8 +28,8 @@ class OfferAdmin(admin.ModelAdmin):
 
 
 class OfferSubscriptionAdmin(admin.ModelAdmin):
-    list_display = ('member', 'offer', 'subscription_date', 'commitment',
-                    'resign_date')
+    list_display = ('get_subscription_reference', 'member', 'offer',
+                    'subscription_date', 'commitment', 'resign_date')
     list_display_links = ('member','offer')
     list_filter = ( OfferSubscriptionTerminationFilter,
                     OfferSubscriptionCommitmentFilter,

+ 20 - 0
coin/offers/migrations/0006_offer_reference.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('offers', '0005_auto_20150210_0923'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='offer',
+            name='reference',
+            field=models.CharField(help_text='Identifiant a utiliser par exemple comme identifiant de virement', max_length=255, blank=True, verbose_name="référence de l'offre"),
+            preserve_default=True,
+        ),
+    ]

+ 8 - 0
coin/offers/models.py

@@ -3,6 +3,7 @@ from __future__ import unicode_literals
 
 import datetime
 
+from django.conf import settings
 from django.db import models
 from django.db.models import Q
 from django.core.validators import MinValueValidator
@@ -19,6 +20,9 @@ class Offer(models.Model):
 
     name = models.CharField(max_length=255, blank=False, null=False,
                             verbose_name="nom de l'offre")
+    reference = models.CharField(max_length=255, blank=True,
+                                    verbose_name="référence de l'offre",
+                                    help_text="Identifiant a utiliser par exemple comme identifiant de virement")
     configuration_type = models.CharField(max_length=50,
                             blank=True,
                             verbose_name='type de configuration',
@@ -103,6 +107,10 @@ class OfferSubscription(models.Model):
     member = models.ForeignKey('members.Member', verbose_name='membre')
     offer = models.ForeignKey('Offer', verbose_name='offre')
 
+    def get_subscription_reference(self):
+        return settings.SUBSCRIPTION_REFERENCE.format(subscription=self)
+    get_subscription_reference.short_description = 'Référence'
+
     def __unicode__(self):
         return '%s - %s - %s' % (self.member, self.offer.name,
                                        self.subscription_date)

+ 4 - 0
coin/settings.py

@@ -237,6 +237,10 @@ MEMBER_DEFAULT_COTISATION = 20
 # membership fee
 MEMBER_MEMBERSHIP_INFO_URL = ''
 
+# Pattern used to display a unique reference for any subscription
+# Helpful for bank wire transfer identification
+SUBSCRIPTION_REFERENCE = 'REF-{subscription.offer.reference}-{subscription.pk}'
+
 # Reset session if cookie older than 2h.
 SESSION_COOKIE_AGE = 7200
 

+ 6 - 0
coin/static/css/local.css

@@ -389,3 +389,9 @@ tr.inactive {
 .message.success:before {
     content: "✔ ";
 }
+
+.nowrap {
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+}