Browse Source

First offers and services subscription commit

Fabs 11 years ago
parent
commit
6afa3ed75b

+ 0 - 0
coin/offers/__init__.py


+ 7 - 0
coin/offers/admin.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from coin.offers.models import Offer, Service, OfferSubscription
+
+# Register your models here.
+admin.site.register(Service)
+admin.site.register(Offer)
+admin.site.register(OfferSubscription)

+ 97 - 0
coin/offers/migrations/0001_initial.py

@@ -0,0 +1,97 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Adding model 'Service'
+        db.create_table(u'offers_service', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
+        ))
+        db.send_create_signal(u'offers', ['Service'])
+
+        # Adding model 'Offer'
+        db.create_table(u'offers_offer', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
+            ('biling_priod', self.gf('django.db.models.fields.IntegerField')(default=1)),
+            ('period_fees', self.gf('django.db.models.fields.DecimalField')(max_digits=5, decimal_places=2)),
+            ('initial_fees', self.gf('django.db.models.fields.DecimalField')(max_digits=5, decimal_places=2)),
+            ('service', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['offers.Service'])),
+        ))
+        db.send_create_signal(u'offers', ['Offer'])
+
+        # Adding model 'OfferSubscription'
+        db.create_table(u'offers_offersubscription', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('subscription_date', self.gf('django.db.models.fields.DateField')(default=datetime.date.today)),
+            ('resign_date', self.gf('django.db.models.fields.DateField')(null=True, blank=True)),
+            ('commitment', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),
+            ('member', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['members.Member'])),
+            ('offer', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['offers.Offer'])),
+        ))
+        db.send_create_signal(u'offers', ['OfferSubscription'])
+
+
+    def backwards(self, orm):
+        # Deleting model 'Service'
+        db.delete_table(u'offers_service')
+
+        # Deleting model 'Offer'
+        db.delete_table(u'offers_offer')
+
+        # Deleting model 'OfferSubscription'
+        db.delete_table(u'offers_offersubscription')
+
+
+    models = {
+        u'members.member': {
+            'Meta': {'object_name': 'Member'},
+            'address': ('django.db.models.fields.TextField', [], {}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'country': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '254'}),
+            'entry_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.date.today'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'home_phone_number': ('django.db.models.fields.CharField', [], {'max_length': '25', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'ldap_cn': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
+            'mobile_phone_number': ('django.db.models.fields.CharField', [], {'max_length': '25', 'blank': 'True'}),
+            'organization_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
+            'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+            'resign_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'non_adherent'", 'max_length': '50'}),
+            'type': ('django.db.models.fields.CharField', [], {'default': "'personne_physique'", 'max_length': '20'})
+        },
+        u'offers.offer': {
+            'Meta': {'object_name': 'Offer'},
+            'biling_priod': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'initial_fees': ('django.db.models.fields.DecimalField', [], {'max_digits': '5', 'decimal_places': '2'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'period_fees': ('django.db.models.fields.DecimalField', [], {'max_digits': '5', 'decimal_places': '2'}),
+            'service': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['offers.Service']"})
+        },
+        u'offers.offersubscription': {
+            'Meta': {'object_name': 'OfferSubscription'},
+            'commitment': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'member': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['members.Member']"}),
+            'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['offers.Offer']"}),
+            'resign_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+            'subscription_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.date.today'})
+        },
+        u'offers.service': {
+            'Meta': {'object_name': 'Service'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        }
+    }
+
+    complete_apps = ['offers']

+ 75 - 0
coin/offers/migrations/0002_auto__del_field_offer_biling_priod__add_field_offer_billing_priod.py

@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Deleting field 'Offer.biling_priod'
+        db.delete_column(u'offers_offer', 'biling_priod')
+
+        # Adding field 'Offer.billing_priod'
+        db.add_column(u'offers_offer', 'billing_priod',
+                      self.gf('django.db.models.fields.IntegerField')(default=1),
+                      keep_default=False)
+
+
+    def backwards(self, orm):
+        # Adding field 'Offer.biling_priod'
+        db.add_column(u'offers_offer', 'biling_priod',
+                      self.gf('django.db.models.fields.IntegerField')(default=1),
+                      keep_default=False)
+
+        # Deleting field 'Offer.billing_priod'
+        db.delete_column(u'offers_offer', 'billing_priod')
+
+
+    models = {
+        u'members.member': {
+            'Meta': {'object_name': 'Member'},
+            'address': ('django.db.models.fields.TextField', [], {}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'country': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '254'}),
+            'entry_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.date.today'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'home_phone_number': ('django.db.models.fields.CharField', [], {'max_length': '25', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'ldap_cn': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
+            'mobile_phone_number': ('django.db.models.fields.CharField', [], {'max_length': '25', 'blank': 'True'}),
+            'organization_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
+            'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+            'resign_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'non_adherent'", 'max_length': '50'}),
+            'type': ('django.db.models.fields.CharField', [], {'default': "'personne_physique'", 'max_length': '20'})
+        },
+        u'offers.offer': {
+            'Meta': {'object_name': 'Offer'},
+            'billing_priod': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'initial_fees': ('django.db.models.fields.DecimalField', [], {'max_digits': '5', 'decimal_places': '2'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'period_fees': ('django.db.models.fields.DecimalField', [], {'max_digits': '5', 'decimal_places': '2'}),
+            'service': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['offers.Service']"})
+        },
+        u'offers.offersubscription': {
+            'Meta': {'object_name': 'OfferSubscription'},
+            'commitment': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'member': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['members.Member']"}),
+            'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['offers.Offer']"}),
+            'resign_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+            'subscription_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.date.today'})
+        },
+        u'offers.service': {
+            'Meta': {'object_name': 'Service'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        }
+    }
+
+    complete_apps = ['offers']

+ 75 - 0
coin/offers/migrations/0003_auto__del_field_offer_billing_priod__add_field_offer_billing_period.py

@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Deleting field 'Offer.billing_priod'
+        db.delete_column(u'offers_offer', 'billing_priod')
+
+        # Adding field 'Offer.billing_period'
+        db.add_column(u'offers_offer', 'billing_period',
+                      self.gf('django.db.models.fields.IntegerField')(default=1),
+                      keep_default=False)
+
+
+    def backwards(self, orm):
+        # Adding field 'Offer.billing_priod'
+        db.add_column(u'offers_offer', 'billing_priod',
+                      self.gf('django.db.models.fields.IntegerField')(default=1),
+                      keep_default=False)
+
+        # Deleting field 'Offer.billing_period'
+        db.delete_column(u'offers_offer', 'billing_period')
+
+
+    models = {
+        u'members.member': {
+            'Meta': {'object_name': 'Member'},
+            'address': ('django.db.models.fields.TextField', [], {}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'country': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '254'}),
+            'entry_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.date.today'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'home_phone_number': ('django.db.models.fields.CharField', [], {'max_length': '25', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'ldap_cn': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
+            'mobile_phone_number': ('django.db.models.fields.CharField', [], {'max_length': '25', 'blank': 'True'}),
+            'organization_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
+            'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+            'resign_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'non_adherent'", 'max_length': '50'}),
+            'type': ('django.db.models.fields.CharField', [], {'default': "'personne_physique'", 'max_length': '20'})
+        },
+        u'offers.offer': {
+            'Meta': {'object_name': 'Offer'},
+            'billing_period': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'initial_fees': ('django.db.models.fields.DecimalField', [], {'max_digits': '5', 'decimal_places': '2'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'period_fees': ('django.db.models.fields.DecimalField', [], {'max_digits': '5', 'decimal_places': '2'}),
+            'service': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['offers.Service']"})
+        },
+        u'offers.offersubscription': {
+            'Meta': {'object_name': 'OfferSubscription'},
+            'commitment': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'member': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['members.Member']"}),
+            'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['offers.Offer']"}),
+            'resign_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+            'subscription_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.date.today'})
+        },
+        u'offers.service': {
+            'Meta': {'object_name': 'Service'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        }
+    }
+
+    complete_apps = ['offers']

+ 0 - 0
coin/offers/migrations/__init__.py


+ 45 - 0
coin/offers/models.py

@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+import datetime
+from django.db import models
+
+
+class Service(models.Model):
+    name = models.CharField(max_length=255, blank=False, null=False,
+                            help_text='Nom du service')
+    
+    def __unicode__(self):
+        return self.name
+
+class Offer(models.Model):
+    name = models.CharField(max_length=255, blank=False, null=False,
+                            help_text='Nom de l\'offre')
+    billing_period = models.IntegerField(blank=False, null=False, default=1,
+                                       help_text='Période de facturation en mois')
+    period_fees = models.DecimalField(max_digits=5, decimal_places=2,
+                                      blank=False, null=False,
+                                      help_text='Montant par période de facturation en €')
+    initial_fees = models.DecimalField(max_digits=5, decimal_places=2,
+                                      blank=False, null=False,
+                                      help_text='Frais de mise en service en €')
+    service = models.ForeignKey('Service')
+    
+    def __unicode__(self):
+        return u'%s - %d€ / %im [%s]' % (self.name, self.period_fees, self.billing_period, self.service)
+
+class OfferSubscription(models.Model):
+    subscription_date = models.DateField(
+        null=False,
+        blank=False,
+        default=datetime.date.today,
+        help_text='Date de souscription à l\'offre')
+    resign_date = models.DateField(
+        null=True,
+        blank=True,
+        help_text='Date de résiliation')
+    commitment = models.IntegerField(blank=True, null=True,
+                                     help_text='Période d\'engagement en mois')
+    member = models.ForeignKey('members.Member')
+    offer = models.ForeignKey('Offer')
+
+    def __unicode__(self):
+        return u'%s - %s - %s' % (self.member, self.offer.name, self.subscription_date)

+ 3 - 0
coin/offers/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 3 - 0
coin/offers/views.py

@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.

+ 2 - 1
coin/settings.py

@@ -141,7 +141,8 @@ INSTALLED_APPS = (
     #'django.contrib.admindocs',
     'south',
     'ldapdb',  # LDAP as database backend
-    'coin.members'
+    'coin.members',
+    'coin.offers'
 )
 
 # A sample logging configuration. The only tangible logging