def create_schedule_item(project_key, json): json.pop("key", None) json["starttime"] = datetime.strptime(json["starttime"], "%m/%d/%Y %H:%M") json["endtime"] = datetime.strptime(json["endtime"], "%m/%d/%Y %H:%M") schedule = Schedule(**json) schedule.addIndex("project_bin", project_key) schedule.save() return schedule
def get_schedules(project_key): schedules_queries = Schedule.indexLookup("project_bin", project_key) schedules = [] for schedule in schedules_queries.run(): schedules.append(schedule_to_json(schedule)) schedules.sort(key=lambda x: x["starttime"]) return schedules
def delete_schedule(schedule_key): Schedule.get(schedule_key).delete()