def delete_schedule(id): id = int(id) schedule = current_user.get_schedule(id=id) if schedule is None and id != -1: return "", 403 # Requested id is not in this user's schedule list. if schedule is not None: current_user.remove_schedule(schedule) if id == session["current_schedule"].id or id == -1: mng = app.config["MANAGER"] session["current_schedule"] = schd.Schedule(mng.get_default_project_id()) session["current_schedule_modified"] = True return ( jsonify( { "current_schedule": { "id": session["current_schedule"].id, "project_id": session["current_schedule"].project_id, "label": session["current_schedule"].label, "color_palette": session["current_schedule"].color_palette, }, "unsaved": session["current_schedule_modified"], } ), 200, )
def get_data(): mng = app.config['MANAGER'] label = session['current_schedule'].label if label == schd.DEFAULT_SCHEDULE_NAME: # Translates the default schedule name session['current_schedule'].label = _(label) # Might exist a better way ... return jsonify({ 'project_id': mng.get_project_ids(), 'unsaved': session['current_schedule_modified'], 'schedules': list( map(lambda s: { 'id': s.id, 'label': s.data.label, }, current_user.get_schedule())), 'current_schedule': { 'id': session['current_schedule'].id, 'project_id': session['current_schedule'].project_id, 'label': session['current_schedule'].label, 'color_palette': session['current_schedule'].color_palette, }, }), 200
def update_label(id): label = request.json.get("label") if int(id) == -1: session["current_schedule"].label = label return "OK", 200 schedule = current_user.get_schedule(id=int(id)) if schedule and session["current_schedule"].id == int(id): session["current_schedule"].label = label schedule.update_label(label) return "OK", 200 return "", 403 # Requested id is not in this user's schedule list.
def update_label(id): label = request.json.get('label') if int(id) == -1: session['current_schedule'].label = label return 'OK', 200 schedule = current_user.get_schedule(id=int(id)) if schedule and session['current_schedule'].id == int(id): session['current_schedule'].label = label schedule.update_label(label) return 'OK', 200 return '', 403 # Requested id is not in this user's schedule list.
def autoload_schedule(): if current_user.is_authenticated and session[ "current_schedule"].id is not None: schedule = current_user.get_schedule(id=session["current_schedule"].id) if schedule is None: mng = app.config["MANAGER"] session["current_schedule"] = schd.Schedule( mng.get_default_project_id()) session["current_schedule_modified"] = False return if (schedule.last_modified_by != session["uuid"] and schedule.last_modified_by is not None): session["current_schedule"] = schedule.data schedule.update_last_modified_by(session["uuid"])
def load_schedule(id): if int(id) == -1: return 'OK', 200 schedule = current_user.get_schedule(id=int(id)) if schedule: session['current_schedule'] = schedule.data session['current_schedule_modified'] = False return jsonify({ 'current_schedule': { 'id': schedule.data.id, 'project_id': schedule.data.project_id, 'label': schedule.data.label, 'color_palette': schedule.data.color_palette, }, 'unsaved': session['current_schedule_modified'], }), 200 return '', 403 # Requested id is not in this user's schedule list.
def load_schedule(id): if int(id) == -1: return "OK", 200 schedule = current_user.get_schedule(id=int(id)) if schedule: session["current_schedule"] = schedule.data session["current_schedule_modified"] = False return ( jsonify( { "current_schedule": { "id": schedule.data.id, "project_id": schedule.data.project_id, "label": schedule.data.label, "color_palette": schedule.data.color_palette, }, "unsaved": session["current_schedule_modified"], } ), 200, ) return "", 403 # Requested id is not in this user's schedule list.
def load_schedule(id): mng = app.config["MANAGER"] schedule = current_user.get_schedule(id=int(id)) if schedule: session["current_schedule"] = schedule.data session["current_schedule_modified"] = False return ( jsonify({ "current_schedule": { "id": schedule.data.id, "label": gettext(schedule.data.label), "color_palette": schedule.data.color_palette, }, "project_id": mng.get_project_ids(), "current_project_id": session["current_schedule"].project_id, "n_schedules": len(session["current_schedule"].best_schedules), "events": session["current_schedule"].get_events(json=True), "codes": session["current_schedule"].codes, "schedules": list( map( lambda s: { "id": s.id, "label": gettext(s.data.label) }, current_user.get_schedules(), )), }), 200, ) return "", 403 # Requested id is not in this user's schedule list.
def delete_schedule(id): id = int(id) schedule = current_user.get_schedule(id=id) if schedule is None and id is not -1: return '', 403 # Requested id is not in this user's schedule list. if schedule is not None: current_user.remove_schedule(schedule) if id is session['current_schedule'].id or id is -1: mng = app.config['MANAGER'] session['current_schedule'] = schd.Schedule( mng.get_default_project_id()) session['current_schedule_modified'] = True return jsonify({ 'current_schedule': { 'id': session['current_schedule'].id, 'project_id': session['current_schedule'].project_id, 'label': session['current_schedule'].label, 'color_palette': session['current_schedule'].color_palette, }, 'unsaved': session['current_schedule_modified'], }), 200