Skip to content

Commit

Permalink
Add a dbapi function to check if an authorization exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dtgay committed Sep 9, 2014
1 parent 7a9f42f commit d385c04
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tahrir_api/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,25 @@ def assertion_exists(self, badge_id, email):

return self.session.query(Assertion).filter_by(
person_id=person.id, badge_id=badge_id).count() != 0

def authorization_exists(self, badge_id, email):
"""
Check if an authorization exists in the database
:type badge_id: str
:param badge_id: ID of the badge
:type email: str
:param email: user's email
"""

person = self.get_person(email)

if not person:
return False

return self.session.query(Authorization).filter_by(
person_id=person.id, badge_id=badge_id).count() != 0

@autocommit
def add_authorization(self, badge_id, person_email):
Expand Down

0 comments on commit d385c04

Please sign in to comment.