예제 #1
0
 def create_person(self, data, person_type=None):
     self._check_person_data(data)
     try:
         with self._database_engine.new_session() as session:
             member = PersonDAO(session).get_dao(type=person_type).create(data)
             member_data = member.to_dict()
             return member_data
     except Error as e:
         raise e
예제 #2
0
 def create_person(self, data):
     self._check_profile_data(data)
     try:
         with self._database_engine.new_session() as session:
             # Save person in database
             person = PersonDAO(session).create(data)
             person_data = person.to_dict()
             return person_data
     except Error as e:
         # log error
         raise e
예제 #3
0
 def get_person_by_username(self, username):
     with self._database_engine.new_session() as session:
         user = UserDAO(session).get_by_name(username)
         person = PersonDAO(session).get_by_id_user(user.id)
         person_data = person.to_dict()
     return person_data
예제 #4
0
 def get_person_by_name(self, firstname, lastname):
     with self._database_engine.new_session() as session:
         person = PersonDAO(session).get_by_name(firstname, lastname)
         person_data = person.to_dict()
     return person_data
예제 #5
0
 def get_person(self, person_id):
     with self._database_engine.new_session() as session:
         person = PersonDAO(session).get(person_id)
         person_data = person.to_dict()
     return person_data
예제 #6
0
 def _update_person(self, member_id, member_data, person_type=None):
     with self._database_engine.new_session() as session:
         person = PersonDAO(session).get_dao(type=person_type).get(member_id)
         person = PersonDAO(session).get_dao(type=person_type).update(person, member_data)
         return person.to_dict()
예제 #7
0
 def get_person(self, person_id, person_type=None):
     with self._database_engine.new_session() as session:
         member = PersonDAO(session).get_dao(type=person_type).get(person_id)
         member_data = member.to_dict()
     return member_data