def post(self): if not SigninManager.get_is_signed_in(): raise SigninRequiredError("Signin required.") args = json.loads(request.data.decode("utf-8")) user_id = SigninManager.get_user_id() speakerinfo = SpeakerInfo.query.filter_by(user_id=user_id).first() if speakerinfo is None: speakerinfo = SpeakerInfoRepo.insert(args) else: speakerinfo.introduce = args["introduce"] speakerinfo.history = args["history"] speakerinfo.title = args["title"] speakerinfo.description = args["description"] speakerinfo.keynote_link = args["keynote_link"] try: db.session.merge(speakerinfo) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return speakerinfo
def get(self, pk): # TODO(@harrydrippin) Signin Check library = get_or_404(Library, pk) user_list = list() for user in library.users: if not user.speakerinfo: user_list.append(user) if len(user_list) >= 2: return {"result": 1, "cause": "이미 정원이 꽉 찼습니다."} user_id = SigninManager.get_user_id() user = get_or_404(User, user_id) # TODO(@harrydrippin): Check if ref exist above this situation user.library_id = library._id try: db.session.merge(user) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return {"result": 0}
def insert(cls, args): speakerinfo = SpeakerInfo(**args) try: db.session.add(speakerinfo) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return speakerinfo
def post(self): args = library_reqparser.parse_args() library = Library(**args) try: db.session.add(library) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return library
def post(self): args = user_reqparser.parse_args() user = User(**args) try: db.session.add(user) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e # E-mail Integration gen_uuid = EmailManager.get_unique_uuid() email = VerifyEmail( user_id=user._id, key=gen_uuid ) if EmailManager.send_verify_email(user.email, gen_uuid): email.sended_at = now_at_seoul() else: raise EmailNotSendedError() try: db.session.add(email) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return user
def verify_email(): args = verify_reqparser.parse_args() email = VerifyEmail.query.filter_by(key=args["key"]).first() if email is None: return "적절한 Key가 아닙니다. 운영자에게 문의해주시기 바랍니다." if email.expired: return "이미 만료된 링크입니다." if elapsed_datetime_at_seoul(email.sended_at).days > 0: email.expired = True try: db.session.merge(email) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return "24시간이 초과하여 회원 가입 이력이 삭제되었습니다. 다시 가입해주세요." email.verified_at = now_at_seoul() email.is_verified = True email.expired = True try: db.session.merge(email) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return "인증이 완료되었습니다."
def get(self, pk): if not CredentialManager.get_is_admin(): raise UnauthorizedError("Unauthorized.") speaker = get_or_404(SpeakerInfo, pk) speaker.admin_approved = 1 try: db.session.merge(speaker) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return {"result": 0}
def update(cls, speakerinfo, args): for key, value in args.items(): if value is None: continue setattr(speakerinfo, key, value) try: db.session.merge(speakerinfo) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e print(speakerinfo) return speakerinfo
def get(self, pk): # TODO(@harrydrippin) Signin Check library = get_or_404(Library, pk) user_list = library.users args = matchspeaker_reqparser.parse_args() session_t = list() for user in user_list: # TODO(@harrydrippin): Verify that below if line works if user.speakerinfo: speaker_info = user.speakerinfo session_t.append(speaker_info.session_time) if session_t.count(args["time"] + ":00") != 0: return {"result": 1, "cause": "이미 할당된 세션입니다. 다른 세션을 선택해주세요."} user_id = SigninManager.get_user_id() user = get_or_404(User, user_id) user.library_id = library._id speakerinfo = SpeakerInfo() speakerinfo.user_id = user._id speakerinfo.session_time = args["time"] + ":00" try: db.session.merge(user) db.session.add(speakerinfo) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return {"result": 0}
def put(self, pk): args = user_reqparser.parse_args() user = get_or_404(User, pk) for key, value in args.items(): if value is None: continue setattr(user, key, value) try: db.session.merge(user) db.session.commit() except IntegrityError as e: print(str(e)) db.session.rollback() abort_with_integrityerror(e) except Exception as e: print(str(e)) db.session.rollback() raise e return user