Skip to content

Commit

Permalink
Allow add_person to set the nickname.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Jun 20, 2013
1 parent 70ad1cc commit 0a6daea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tahrir_api/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def delete_person(self, person_email):
return person_email
return False

def add_person(self, email):
def add_person(self, email, nickname=None):
"""
Add a new Person to the database
Expand All @@ -186,7 +186,13 @@ def add_person(self, email):

session = scoped_session(self.session_maker)
if not self.person_exists(email=email):
new_person = Person(email=email)

# If no nickname is specified, just use the first bit of their
# email as a convenient default.
if not nickname:
nickname = email.split('@')[0]

new_person = Person(email=email, nickname=nickname)
session.add(new_person)
session.commit()
return email
Expand Down

0 comments on commit 0a6daea

Please sign in to comment.