summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-05-08 15:09:50 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-05-08 15:09:50 -0400
commitcb206c7b9d9cd4768fb7eeea49e1026abeb107c9 (patch)
tree921049d7381b809c41fda285a518b34cffb72606
parentc63adbab25a6972e540652c5ed68b359e81c209d (diff)
downloadaskbot-cb206c7b9d9cd4768fb7eeea49e1026abeb107c9.tar.gz
askbot-cb206c7b9d9cd4768fb7eeea49e1026abeb107c9.tar.bz2
askbot-cb206c7b9d9cd4768fb7eeea49e1026abeb107c9.zip
intermediate commit, removed two migrations and fixed bugs
-rw-r--r--askbot/models/user.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/askbot/models/user.py b/askbot/models/user.py
index 2e4bbda5..70aee263 100644
--- a/askbot/models/user.py
+++ b/askbot/models/user.py
@@ -363,9 +363,13 @@ class GroupProfile(models.Model):
is_open = models.BooleanField(default = False)
#preapproved email addresses and domain names to auto-join groups
#trick - the field is padded with space and all tokens are space separated
- preapproved_emails = models.TextField(null = True, blank = True)
+ preapproved_emails = models.TextField(
+ null = True, blank = True, default = ''
+ )
#only domains - without the '@' or anything before them
- preapproved_email_domains = models.TextField(null = True, blank = True)
+ preapproved_email_domains = models.TextField(
+ null = True, blank = True, default = ''
+ )
class Meta:
app_label = 'askbot'
@@ -382,13 +386,17 @@ class GroupProfile(models.Model):
return True
#relying on a specific method of storage
- email_match_re = re.compile(r'\s%s\s' % user.email)
- if email_match_re.search(self.preapproved_emails):
- return True
+ if self.preapproved_emails:
+ email_match_re = re.compile(r'\s%s\s' % user.email)
+ if email_match_re.search(self.preapproved_emails):
+ return True
+
+ if self.preapproved_email_domains:
+ email_domain = user.email.split('@')[1]
+ domain_match_re = re.compile(r'\s%s\s' % email_domain)
+ return domain_match_re.search(self.preapproved_email_domains)
- email_domain = user.email.split('@')[1]
- domain_match_re = re.compile(r'\s%s\s' % email_domain)
- return domain_match_re.search(self.preapproved_email_domains)
+ return False
def clean(self):
"""called in `save()`