예제 #1
0
    def delete(self, schedule_id, session=None):
        """ Delete a schedule """
        for i in range(len(manager.config.get('schedules', []))):
            if id(manager.config['schedules'][i]) == schedule_id:
                del manager.config['schedules'][i]
                manager.save_config()
                manager.config_changed()
                return {}, 200

        return {'error': 'Schedule not found'}, 404
예제 #2
0
    def delete(self, schedule_id, session=None):
        """ Delete a schedule """
        for i in range(len(manager.config.get("schedules", []))):
            if id(manager.config["schedules"][i]) == schedule_id:
                del manager.config["schedules"][i]
                manager.save_config()
                manager.config_changed()
                return {}, 200

        return {"error": "Schedule not found"}, 404
예제 #3
0
    def delete(self, schedule_id, session=None):
        """ Delete a schedule """
        for i in range(len(manager.config.get('schedules', []))):
            if id(manager.config['schedules'][i]) == schedule_id:
                del manager.config['schedules'][i]
                manager.save_config()
                manager.config_changed()
                return {}, 200

        return {'error': 'Schedule not found'}, 404
예제 #4
0
    def _update_schedule(self, existing, update, merge=False):
        if "id" in update:
            del update["id"]

        if not merge:
            existing.clear()

        existing.update(update)
        manager.save_config()
        manager.config_changed()
        return existing
예제 #5
0
    def _update_schedule(self, existing, update, merge=False):
        if 'id' in update:
            del update['id']

        if not merge:
            existing.clear()

        existing.update(update)
        manager.save_config()
        manager.config_changed()
        return existing
예제 #6
0
    def post(self, session=None):
        """ Add new schedule """
        data = request.json

        if "schedules" not in manager.config or not manager.config["schedules"]:
            # Schedules not defined or are disabled, enable as one is being created
            manager.config["schedules"] = []

        manager.config["schedules"].append(data["schedule"])
        new_schedule = _schedule_by_id(id(data["schedule"]))

        if not new_schedule:
            return {"error": "schedule went missing after add"}, 500

        manager.save_config()
        manager.config_changed()
        return {"schedule": new_schedule}, 201
예제 #7
0
    def post(self, session=None):
        """ Add new schedule """
        data = request.json

        if 'schedules' not in manager.config or not manager.config['schedules']:
            # Schedules not defined or are disabled, enable as one is being created
            manager.config['schedules'] = []

        manager.config['schedules'].append(data)
        new_schedule = _schedule_by_id(id(data))

        if not new_schedule:
            return {'error': 'schedule went missing after add'}, 500

        manager.save_config()
        manager.config_changed()
        return {'schedule': new_schedule}, 201