예제 #1
0
 def create(i_interview):
     try:
         interview = Interview(**i_interview)
         session.add(interview)
         session.commit()
         session.refresh(interview)
         return interview
     except exc.IntegrityError as err:
         raise APIException("", "", err.message)
예제 #2
0
 def create(i_recording):
     try:
         recording = Recording(**i_recording)
         session.add(recording)
         session.commit()
         session.refresh(recording)
         return recording
     except exc.IntegrityError as err:
         raise APIException("", "", err.message)
예제 #3
0
 def create(i_question):
     try:
         question = Question(**i_question)
         session.add(question)
         session.commit()
         session.refresh(question)
         return question
     except exc.IntegrityError as err:
         raise APIException("", "", err.message)
예제 #4
0
 def action(recording_id, action):
     try:
         recording = Recording.get(recording_id=recording_id)
         recording.r_sid = ""
         recording.status = RECORDING.STATUS.COMPLETE
         session.commit()
         session.refresh(recording)
         return recording
     except exc.IntegrityError as err:
         raise APIException("", "", err.message)
예제 #5
0
 def fetch_recordings(interview_id):
     try:
         interview = Interview.get(interview_id=interview_id)
         recordings_list = InterviewTask.fetch_recordings(
             interview.call_sid)
         Interview.send_url_sms(interview_id)
         for recording_item in recordings_list:
             recording_item['interview_id'] = interview_id
             Recording.create(recording_item)
         return Recording.list(interview_id)
     except exc.IntegrityError as err:
         raise APIException("", "", err.message)
예제 #6
0
 def init_call(interview_id):
     try:
         interview = Interview.get(interview_id=interview_id)
         call_sid = InterviewTask.init_call(BASE_URL + "/questions/1.xml",
                                            "+16073388347", interview_id)
         interview.call_sid = call_sid
         interview.status = INTERVIEW.STATUS.INIT
         session.commit()
         session.refresh(interview)
         return interview
     except exc.IntegrityError as err:
         raise APIException("", "", err.message)
예제 #7
0
 def get(**kwargs):
     try:
         return session.query(Interview).filter_by(**kwargs).one()
     except orm_exc.NoResultFound:
         raise APIException("", "")