Permalink
Browse files

sanitize

  • Loading branch information...
1 parent 43aaa31 commit 0fdb96104740c629b4c791a97fa79ff4ed7f1b27 Mike Krieger committed Dec 11, 2008
Showing with 7 additions and 2 deletions.
  1. +0 −1 greetings/models.py
  2. +7 −1 greetings/views.py
View
@@ -42,7 +42,6 @@ class Card (models.Model):
to_people = models.ManyToManyField(Person, related_name="to_people", null=True, blank=True)
audio_file = models.FileField(upload_to='audio_uploads/', null=True, blank=True)
image_file = models.FileField(upload_to='image_uploads/', null=True, blank=True)
- template = models.ForeignKey(Template, null=True, blank=True)
template_name = models.CharField(max_length=100, null=True, blank=True)
text_content = models.TextField()
short_hash = models.CharField(max_length=10, null=True, blank=True)
View
@@ -45,6 +45,10 @@ def make_hash_list_from_objects(objects, field):
m.update( eval("entry."+field) )
hash_list.append(m.hexdigest())
return hash_list
+
+def sanitize_phone(raw_phone):
+ if len(raw_phone) == 11:
+ return raw_phone[1:]
def all_cards_for_id(request, person_id, since_id=0):
@@ -168,7 +172,8 @@ def new_user(request):
user.emails.add(new_email)
for phone in phone_list:
- if len(phone) > 0:
+ if len(phone) > 0:
+ phone = sanitize_phone(phone)
if len(Phone.objects.filter(number=phone)) > 0:
json_response['success'] = False
json_response['error'] = "Duplicate phone"
@@ -233,6 +238,7 @@ def make_greeting(request):
new_card.save()
for phone in request.REQUEST["to_people_phones"].split(","):
+ phone = sanitize_phone(phone)
other_person = get_or_create_person_from_phone(phone)
print "other person was found to be", other_person, " based on ", phone.strip()
if other_person:

0 comments on commit 0fdb961

Please sign in to comment.