Browse Source

added a BankInfo to isp_database, with account & bank details

Jocelyn Delande 10 years ago
parent
commit
23ba3a72ab

+ 1 - 2
coin/billing/templates/billing/payment_howto.html

@@ -3,8 +3,7 @@
 <p>
 <strong>Virement</strong><br />
 Titulaire du compte : {{ branding.shortname|upper }}<br/>
-RIB : 42559 00012 41020023285 19<br/>
-IBAN : FR76 4255 9000 1241 0200 2328 519<br />
+IBAN : {{ branding.bankinfo.iban}}<br />
 Merci de faire figurer le code suivant sur votre virement : <strong>#{{ invoice.member.id }}</strong>
 <br /><br />
 <strong>Chèque</strong><br />

+ 15 - 2
coin/isp_database/admin.py

@@ -3,7 +3,7 @@ from __future__ import unicode_literals
 
 from django.contrib import admin
 
-from coin.isp_database.models import ISPInfo, RegisteredOffice, OtherWebsite, ChatRoom, CoveredArea
+from coin.isp_database.models import ISPInfo, RegisteredOffice, OtherWebsite, ChatRoom, CoveredArea, BankInfo
 
 
 class SingleInstanceAdminMixin(object):
@@ -38,6 +38,19 @@ class CoveredAreaInline(admin.StackedInline):
     extra = 0
 
 
+class BankInfoInline(admin.StackedInline):
+    model = BankInfo
+    extra = 0
+
+    fieldsets = (('', {
+                'fields': ('iban', 'bic', 'bank_name'),
+                'description': (
+                    'Les coordonnées bancaires ne font pas partie de la'+
+                    ' spécification db.ffdn.org mais sont utilisées par le'+
+                    ' site (facturation notamment).')
+    }),)
+
+
 class ISPInfoAdmin(SingleInstanceAdminMixin, admin.ModelAdmin):
     model = ISPInfo
     fieldsets = (
@@ -53,7 +66,7 @@ class ISPInfoAdmin(SingleInstanceAdminMixin, admin.ModelAdmin):
             'website')}),
     )
 
-    inlines = (RegisteredOfficeInline, OtherWebsiteInline, ChatRoomInline,
+    inlines = (RegisteredOfficeInline, BankInfoInline, OtherWebsiteInline, ChatRoomInline,
                CoveredAreaInline)
     save_on_top = True
 

+ 10 - 0
coin/isp_database/fixtures/illyse.json

@@ -82,5 +82,15 @@
   },
   "model": "isp_database.coveredarea",
   "pk": 2
+},
+{
+  "fields": {
+    "isp": 1,
+    "iban": "FR7642559000124102002328519",
+    "bic": "CCOPFRPPXXX",
+    "bank_name": "Crédit coopératif"
+  },
+  "model": "isp_database.bankinfo",
+  "pk": 1
 }
 ]

+ 29 - 0
coin/isp_database/migrations/0002_bankinfo.py

@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import localflavor.generic.models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('isp_database', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='BankInfo',
+            fields=[
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('iban', localflavor.generic.models.IBANField(max_length=34)),
+                ('bic', localflavor.generic.models.BICField(max_length=11, null=True, verbose_name='BIC', blank=True)),
+                ('bank_name', models.CharField(max_length=100, null=True, verbose_name='\xc9tablissement bancaire', blank=True)),
+                ('isp', models.OneToOneField(to='isp_database.ISPInfo')),
+            ],
+            options={
+                'verbose_name': 'Coordonn\xe9es bancaires',
+            },
+            bases=(models.Model,),
+        ),
+    ]

+ 18 - 0
coin/isp_database/models.py

@@ -5,6 +5,8 @@ from django.db import models
 from django.core.validators import MaxValueValidator
 from django.core.exceptions import ValidationError
 
+from localflavor.generic.models import IBANField, BICField
+
 from coin.members.models import count_active_members
 from coin.offers.models import count_active_subscriptions
 from coin import utils
@@ -181,3 +183,19 @@ class CoveredArea(models.Model):
     def to_dict(self):
         return {"name": self.name,
                 "technologies": [self.technologies]}
+
+
+class BankInfo(models.Model):
+    """Information about bank account and the bank itself
+
+    This is out of the scope of db.ffdn.org spec.
+    """
+    isp = models.OneToOneField(ISPInfo)
+    iban = IBANField('IBAN')
+    bic = BICField('BIC', blank=True, null=True)
+    bank_name = models.CharField('Établissement bancaire',
+                                 max_length=100, blank=True, null=True)
+
+    class Meta:
+        verbose_name = 'Coordonnées bancaires'
+        verbose_name_plural = verbose_name

+ 2 - 0
requirements.txt

@@ -9,6 +9,8 @@ django-activelink==0.4
 html2text
 django-polymorphic==0.6
 django-sendfile==0.3.6
+# Can switch to localflavor release as long as BIC field gets in
+-e git+https://github.com/JocelynDelalande/django-localflavor.git@add-bic-model-and-form-fields#egg=django-localflavor
 -e git+https://code.ffdn.org/zorun/django-postgresql-netfields.git#egg=django-netfields
 -e git+https://github.com/chrisglass/xhtml2pdf@a5d37ffd0ccb0603bdf668198de0f21766816104#egg=xhtml2pdf-master
 -e git+https://github.com/jlaine/django-ldapdb@1c4f9f29e52176f4367a1dffec2ecd2e123e2e7a#egg=django-ldapdb