Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
more robust handling of "name" messages
Browse files Browse the repository at this point in the history
  • Loading branch information
monty5811 committed Oct 19, 2016
1 parent b4948a9 commit 4215abc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apostello/reply.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ def reply_to_name(self):
try:
# update person's name:
self.contact.first_name = self.sms_body.split()[1].strip()
self.contact.last_name = " ".join(self.sms_body.split()[2:]).strip(
)
if not self.contact.last_name:
last_name = " ".join(self.sms_body.split()[2:]).strip()
if not last_name:
raise ValidationError('No last name')
last_name = last_name.split('\n')[0]
last_name = last_name[0:40] # truncate last name
self.contact.last_name = last_name
self.contact.save()
# update old messages with this person's name
async('apostello.tasks.update_msgs_name', self.contact.pk)
Expand Down

0 comments on commit 4215abc

Please sign in to comment.