Commits

Guilherme Gondim committed d690bbd

add unique constraint for Contact's email field

  • Participants
  • Parent commits 6bb1d7a

Comments (0)

Files changed (2)

informativo/migrations/0002_auto__add_unique_contact_email.py

+# -*- 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 'Contact', fields ['email']
+        db.create_unique('informativo_contact', ['email'])
+
+
+    def backwards(self, orm):
+        # Removing unique constraint on 'Contact', fields ['email']
+        db.delete_unique('informativo_contact', ['email'])
+
+
+    models = {
+        'informativo.contact': {
+            'Meta': {'ordering': "('-id',)", 'object_name': 'Contact'},
+            'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'mailing_lists': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subscribers'", 'symmetrical': 'False', 'to': "orm['informativo.MailingList']"})
+        },
+        'informativo.contactmailingstatus': {
+            'Meta': {'ordering': "('-id',)", 'object_name': 'ContactMailingStatus'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['informativo.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'newsletter': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['informativo.Newsletter']"}),
+            'status': ('django.db.models.fields.CharField', [], {'max_length': '16'})
+        },
+        'informativo.mailinglist': {
+            'Meta': {'ordering': "('-id',)", 'object_name': 'MailingList'},
+            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '64'})
+        },
+        'informativo.newsletter': {
+            'Meta': {'ordering': "('-id',)", 'object_name': 'Newsletter'},
+            'html_content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'mailing_list': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['informativo.MailingList']"}),
+            'sending_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'waiting'", 'max_length': '16'}),
+            'text_content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        }
+    }
+
+    complete_apps = ['informativo']

informativo/models.py

 
 
 class Contact(models.Model):
-    email = models.EmailField(_('e-mail'))
+    email = models.EmailField(_('e-mail'), unique=True)
     first_name = models.CharField(_('first name'), max_length=64, blank=True)
     last_name = models.CharField(_('last name'), max_length=64, blank=True)
     mailing_lists = models.ManyToManyField(