def register(): user_type = request.json['role'] session = DBSession() if user_type == 'donator': donator = Donator(name=request.json['name'], gender=request.json['gender'], profession=request.json['profession'], phone=request.json['phone'], wallet_address=request.json['wallet_address'], address=request.json['address']) session.add(donator) session.commit() elif user_type == 'recipient': recipient = Recipient(name=request.json['name'], gender=request.json['gender'], profession=request.json['profession'], phone=request.json['phone'], wallet_address=request.json['wallet_address'], address=request.json['address']) session.add(recipient) session.commit() else: session.close() return 'Error user_type', 400 session.close() return "Register Success", 201
def create(): session = DBSession() try: name = request.json['name'] money = request.json['money'] title = request.json['title'] content = request.json['content'] wallet_address = request.json['wallet_address'] project = Project(name=name, money=money, title=title, content=content, wallet_address=wallet_address, current_money=0, status='Create') session.add(project) session.commit() session.close() return "Create Project Success", 201 except: session.close() return "Create Project Failed", 400