[events] More rename
This commit is contained in:
parent
4ffa5e0e6e
commit
da94acf18c
|
@ -17,7 +17,7 @@ from . import event_controller, permissions
|
|||
from . import models
|
||||
from ...utils.HTTP import no_content
|
||||
|
||||
schedule_bp = Blueprint("events", __name__, url_prefix="/events")
|
||||
events_bp = Blueprint("events", __name__)
|
||||
|
||||
|
||||
class EventPlugin(Plugin):
|
||||
|
@ -25,19 +25,19 @@ class EventPlugin(Plugin):
|
|||
|
||||
def __init__(self, config):
|
||||
super().__init__(
|
||||
blueprint=schedule_bp,
|
||||
blueprint=events_bp,
|
||||
permissions=permissions.permissions,
|
||||
)
|
||||
|
||||
|
||||
@schedule_bp.route("/templates", methods=["GET"])
|
||||
@events_bp.route("/events/templates", methods=["GET"])
|
||||
@login_required()
|
||||
def get_templates(current_session):
|
||||
return jsonify(event_controller.get_templates())
|
||||
|
||||
|
||||
@schedule_bp.route("/event-types", methods=["GET"])
|
||||
@schedule_bp.route("/event-types/<int:identifier>", methods=["GET"])
|
||||
@events_bp.route("/events/event-types", methods=["GET"])
|
||||
@events_bp.route("/events/event-types/<int:identifier>", methods=["GET"])
|
||||
@login_required()
|
||||
def get_event_types(current_session, identifier=None):
|
||||
"""Get EventType(s)
|
||||
|
@ -59,7 +59,7 @@ def get_event_types(current_session, identifier=None):
|
|||
return jsonify(result)
|
||||
|
||||
|
||||
@schedule_bp.route("/event-types", methods=["POST"])
|
||||
@events_bp.route("/events/event-types", methods=["POST"])
|
||||
@login_required(permission=permissions.EVENT_TYPE)
|
||||
def new_event_type(current_session):
|
||||
"""Create a new EventType
|
||||
|
@ -81,7 +81,7 @@ def new_event_type(current_session):
|
|||
return jsonify(event_type)
|
||||
|
||||
|
||||
@schedule_bp.route("/event-types/<int:identifier>", methods=["PUT", "DELETE"])
|
||||
@events_bp.route("/events/event-types/<int:identifier>", methods=["PUT", "DELETE"])
|
||||
@login_required(permission=permissions.EVENT_TYPE)
|
||||
def modify_event_type(identifier, current_session):
|
||||
"""Rename or delete an event type
|
||||
|
@ -107,7 +107,7 @@ def modify_event_type(identifier, current_session):
|
|||
return "", NO_CONTENT
|
||||
|
||||
|
||||
@schedule_bp.route("/job-types", methods=["GET"])
|
||||
@events_bp.route("/events/job-types", methods=["GET"])
|
||||
@login_required()
|
||||
def get_job_types(current_session):
|
||||
"""Get all JobTypes
|
||||
|
@ -124,7 +124,7 @@ def get_job_types(current_session):
|
|||
return jsonify(types)
|
||||
|
||||
|
||||
@schedule_bp.route("/job-types", methods=["POST"])
|
||||
@events_bp.route("/events/job-types", methods=["POST"])
|
||||
@login_required(permission=permissions.JOB_TYPE)
|
||||
def new_job_type(current_session):
|
||||
"""Create a new JobType
|
||||
|
@ -146,7 +146,7 @@ def new_job_type(current_session):
|
|||
return jsonify(jt)
|
||||
|
||||
|
||||
@schedule_bp.route("/job-types/<int:type_id>", methods=["PUT", "DELETE"])
|
||||
@events_bp.route("/events/job-types/<int:type_id>", methods=["PUT", "DELETE"])
|
||||
@login_required(permission=permissions.JOB_TYPE)
|
||||
def modify_job_type(type_id, current_session):
|
||||
"""Rename or delete a JobType
|
||||
|
@ -172,7 +172,7 @@ def modify_job_type(type_id, current_session):
|
|||
return "", NO_CONTENT
|
||||
|
||||
|
||||
@schedule_bp.route("/<int:event_id>", methods=["GET"])
|
||||
@events_bp.route("/events/<int:event_id>", methods=["GET"])
|
||||
@login_required()
|
||||
def get_event(event_id, current_session):
|
||||
"""Get event by id
|
||||
|
@ -190,7 +190,7 @@ def get_event(event_id, current_session):
|
|||
return jsonify(event)
|
||||
|
||||
|
||||
@schedule_bp.route("/", methods=["GET"])
|
||||
@events_bp.route("/events", methods=["GET"])
|
||||
@login_required()
|
||||
def get_filtered_events(current_session):
|
||||
begin = request.args.get("from")
|
||||
|
@ -204,8 +204,8 @@ def get_filtered_events(current_session):
|
|||
return jsonify(event_controller.get_events(begin, end))
|
||||
|
||||
|
||||
@schedule_bp.route("/<int:year>/<int:month>", methods=["GET"])
|
||||
@schedule_bp.route("/events/<int:year>/<int:month>/<int:day>", methods=["GET"])
|
||||
@events_bp.route("/events/<int:year>/<int:month>", methods=["GET"])
|
||||
@events_bp.route("/events/<int:year>/<int:month>/<int:day>", methods=["GET"])
|
||||
@login_required()
|
||||
def get_events(current_session, year=datetime.now().year, month=datetime.now().month, day=None):
|
||||
"""Get Event objects for specified date (or month or year),
|
||||
|
@ -256,7 +256,7 @@ def _add_job(event, data):
|
|||
event_controller.add_job(event, job_type, required_services, start, end, comment=data.get("comment", None))
|
||||
|
||||
|
||||
@schedule_bp.route("", methods=["POST"])
|
||||
@events_bp.route("/events", methods=["POST"])
|
||||
@login_required(permission=permissions.CREATE)
|
||||
def create_event(current_session):
|
||||
"""Create an new event
|
||||
|
@ -301,7 +301,7 @@ def create_event(current_session):
|
|||
return jsonify(event)
|
||||
|
||||
|
||||
@schedule_bp.route("/events/<int:event_id>", methods=["PUT"])
|
||||
@events_bp.route("/events/<int:event_id>", methods=["PUT"])
|
||||
@login_required(permission=permissions.EDIT)
|
||||
def modify_event(event_id, current_session):
|
||||
"""Modify an event
|
||||
|
@ -332,7 +332,7 @@ def modify_event(event_id, current_session):
|
|||
return jsonify(event)
|
||||
|
||||
|
||||
@schedule_bp.route("/<int:event_id>", methods=["DELETE"])
|
||||
@events_bp.route("/events/<int:event_id>", methods=["DELETE"])
|
||||
@login_required(permission=permissions.DELETE)
|
||||
def delete_event(event_id, current_session):
|
||||
"""Delete an event
|
||||
|
@ -350,7 +350,7 @@ def delete_event(event_id, current_session):
|
|||
return "", NO_CONTENT
|
||||
|
||||
|
||||
@schedule_bp.route("/<int:event_id>/jobs", methods=["POST"])
|
||||
@events_bp.route("/events/<int:event_id>/jobs", methods=["POST"])
|
||||
@login_required(permission=permissions.EDIT)
|
||||
def add_job(event_id, current_session):
|
||||
"""Add an new Job to an Event / EventSlot
|
||||
|
@ -371,7 +371,7 @@ def add_job(event_id, current_session):
|
|||
return jsonify(event)
|
||||
|
||||
|
||||
@schedule_bp.route("/<int:event_id>/jobs/<int:job_id>", methods=["DELETE"])
|
||||
@events_bp.route("/events/<int:event_id>/jobs/<int:job_id>", methods=["DELETE"])
|
||||
@login_required(permission=permissions.DELETE)
|
||||
def delete_job(event_id, job_id, current_session):
|
||||
"""Delete a Job
|
||||
|
@ -391,7 +391,7 @@ def delete_job(event_id, job_id, current_session):
|
|||
return no_content()
|
||||
|
||||
|
||||
@schedule_bp.route("/<int:event_id>/jobs/<int:job_id>", methods=["PUT"])
|
||||
@events_bp.route("/events/<int:event_id>/jobs/<int:job_id>", methods=["PUT"])
|
||||
@login_required()
|
||||
def update_job(event_id, job_id, current_session: Session):
|
||||
"""Edit Job or assign user to the Job
|
||||
|
|
Loading…
Reference in New Issue