1234567891011121314151617181920212223242526272829303132333435 |
- from flask import request, abort, make_response
- from flask.views import View
- from pycs.database.Label import Label
- from pycs.frontend.notifications.NotificationManager import NotificationManager
- class EditLabelParent(View):
- """
- edit a labels name
- """
- # pylint: disable=arguments-differ
- methods = ['POST']
- def dispatch_request(self, project_id: int, label_id: int):
- # extract request data
- data = request.get_json(force=True)
- if 'parent' not in data:
- abort(400)
- # find label
- label = Label.query.filter_by(id=label_id, project_id=project_id).one_or_none()
- if label is None:
- abort(404)
- # change parent
- label.set_parent(data['parent'])
- # send notification
- NotificationManager.edited("label", label.id, Label)
- # return success response
- return make_response()
|