def modifyUSession(): uSession = UserSession.query.get(request.args['sessionID']) newDescription = uSession.description newFeedBack_score = uSession.feedback_score newStart_date = uSession.start_date newEnd_date = uSession.end_date newCourse = Course.query.get(request.args["courseID"]) if not(newDescription == request.args['description']): newDescription = request.args['description'] if not(newFeedBack_score == request.args['feedback']): newFeedBack_score = request.args['feedback'] from datetime import datetime if not(newStart_date == datetime.fromtimestamp(float(request.args['startDate'])/1000)): newStart_date = datetime.fromtimestamp(float(request.args['startDate'])/1000) if not(newEnd_date == datetime.fromtimestamp(float(request.args['endDate'])/1000)): newEnd_date = datetime.fromtimestamp(float(request.args['endDate'])/1000) newSession = UserSession(uSession.user, newCourse, newDescription, newFeedBack_score, newStart_date, newEnd_date) oldId =uSession.id uSession.deleteUntrackedSession() db.session.delete(uSession) db.session.commit() newSession.id = oldId db.session.add(newSession) db.session.commit() return "done"
def modifieUntrackedSession(): uSession = UserSession.query.get(1) oldId = uSession.id newDescription = uSession.description newFeedBack_score = uSession.feedback_score newStart_date = uSession.start_date newEnd_date = uSession.end_date if not(newDescription == "description is aangepast"): newDescription = "description is aangepast" if not(newFeedBack_score == "nieuweFeedback"): newFeedBack_score = "nieuweFeedback" if not(newStart_date == newStart_date): newStart_date = newStart_date if not(newEnd_date == newEnd_date): newEnd_date = newEnd_date newSession = UserSession(uSession.user, uSession.course, newDescription, newFeedBack_score, newStart_date, newEnd_date) db.session.delete(uSession) db.session.commit() newSession.id = oldId db.session.add(newSession) db.session.commit() return "ok"