def event_edit(params): result = db.get_event_db(session['id'], params["args"].get("event_id", 0)) event = { "notifications": n.flush(), "success": True, "data": { "id": params["id"], "calendar_id": result[0], "calendars": getData("calendar_list"), "name": result[1], "start": str(result[2]), "end": str(result[3]) } } return event
def newuser(request): email = request.get('form_new_email', 0) nickname = request.get('form_new_nick', 0) password = request.get('form_new_pass', 0) repeat_password = request.get('form_new_pass_repeat', 0) user = {} user["data"] = {"email": email, "nickname": nickname} if password == repeat_password: result = back_user.register_user(email, password, nickname) user["success"] = result if not result: n.append(n.notification(3)) else: n.append(n.notification(2)) user["success"] = False user["notifications"] = n.flush() return user
def calendar_edit_form(request): id = request.get('form_calendar_id', 0) name = request.get('form_calendar_name', 0) if request('form_calendar_public', 0) == 'public': public = True else: public = False calendar = { "success": db.edit_calendar_db(session['id'], id, name, public), "data": { "id": id, "name": name, "public": public } } if not calendar["success"]: n.append(n.notification(6)) calendar["notifications"] = n.flush() return calendar
def login(request): username = request.get('username', 0) password = request.get('password', 0) login_db = back_user.login(username, password) if login_db['success']: session['id'] = login_db['user_id'] session['username'] = username session['login'] = True resultat = { "success": login_db['success'], "data": { "username": username } } else: n.append(n.notification(1)) resultat = { "notifications": n.flush(), "success": login_db['success'], "data": { "username": username } } return resultat
def event_edit(request): eventId = request.args.get("event_id", None) if eventId == -1: return -1 event = mf_database.getEvent(eventId) if event == -1: return -1 returnData = { "notifications":notifications.flush(), "success": True, "data": { "id" : eventId, "calendar_id": event["calendarId"], "calendars" : calendar_list(request), "name": event["name"], "start": str(event["start"]), "end": str(event["end"]) } } return returnData
def formatJsonWithNotifications(returnData): returnData["notifications"] = notifications.flush() return json.dumps(returnData)