def post(self): data = Subject.parser.parse_args() if SubjectModel.find_by_name(data["name"]): return {"messages": err_duplicate.format("subject")}, 400 subject = SubjectModel(**data) try: subject.save_to_db() except: return {"messages": err_500}, 500 return {"messages": noti_201}, 201
def post(self): data = self.parser.parse_args()['subjects'] body = data['body'] date = data['date'] name = data['name'] user_id = get_jwt_identity() user: UserModel = UserModel.find_by_id(user_id) user.subjects_date = date for subject in body: subject_model = SubjectModel(name, subject, user_id) subject_model.save_to_db() if date is None: signuper = SubjectSignuper(body, user.get_cookies()) signuper.execute() return {"message": "Successfully added subjects"}, 201