Skip to content
Browse files

Enforced unique constraint on Invoice

  • Loading branch information...
1 parent b9bd930 commit 1362b55d06249793ee8e2e62b017d37f1b0211d4 @anttihirvonen committed
View
49 dotmembership/apps/billing/migrations/0002_auto__add_unique_invoice_member_for_year.py
@@ -0,0 +1,49 @@
+# -*- 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 unique constraint on 'Invoice', fields ['member', 'for_year']
+ db.create_unique('billing_invoice', ['member_id', 'for_year'])
+
+
+ def backwards(self, orm):
+ # Removing unique constraint on 'Invoice', fields ['member', 'for_year']
+ db.delete_unique('billing_invoice', ['member_id', 'for_year'])
+
+
+ models = {
+ 'billing.invoice': {
+ 'Meta': {'unique_together': "(('member', 'for_year'),)", 'object_name': 'Invoice'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '7', 'decimal_places': '2'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'due_date': ('django.db.models.fields.DateField', [], {'blank': 'True'}),
+ 'for_year': ('django.db.models.fields.IntegerField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'member': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'invoices'", 'to': "orm['members.Member']"}),
+ 'payment_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'payment_method': ('django.db.models.fields.CharField', [], {'max_length': '15', 'null': 'True', 'blank': 'True'}),
+ 'reference_number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'created'", 'max_length': '15'})
+ },
+ 'members.member': {
+ 'Meta': {'object_name': 'Member'},
+ 'class_year': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+ 'home_town': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'joined': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+ 'major': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+ 'membership_type': ('django.db.models.fields.CharField', [], {'default': "'normal'", 'max_length': '15'}),
+ 'school': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['billing']
View
3 dotmembership/apps/billing/models.py
@@ -71,6 +71,9 @@ def save(self, *args, **kwargs):
def __unicode__(self):
return u"{0}, {1}".format(self.member, self.for_year)
+ class Meta:
+ unique_together = ("member", "for_year")
+
reversion.register(Invoice)

0 comments on commit 1362b55

Please sign in to comment.
Something went wrong with that request. Please try again.