Created
May 16, 2012 20:46
Revisions
-
readevalprint revised this gist
May 16, 2012 . 1 changed file with 12 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,15 @@ EMAIL_TYPE_CHOICES = ( ('work', 'Work'), ('home', 'Person'), ('other', 'Other'), ) class EmailAddress(models.Model): email = models.EmailField(db_index=True, max_length=254, unique=True) # Allows us to remove the choices and be backwards compatible type = models.CharField(max_length=10, choices=EMAIL_TYPE_CHOICES) userprofile = models.ForeignKey(UserProfile) @classmethod def search(cls, query): @@ -13,5 +19,5 @@ def search(cls, query): return s def __unicode__(self): """Return the email or blank""" return getattr(self, 'email', '') -
davidw93 created this gist
May 16, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ class EmailAddress(models.Model): email = models.EmailField(db_index=True, max_length=254, unique=True) user = models.ForeignKey('UserProfile', null=False) class Meta: db_table = 'emails' @classmethod def search(cls, query): if query: q = dict('user', query) s = S(cls).query(or_=q) return s def __unicode__(self): """Return the Email Address or return blank""" return getattr(self, 'email', u'')