1234567891011121314151617181920212223242526272829303132333435363738394041 |
- from flask import request, abort, make_response
- from flask.views import View
- from pycs.database.Project import Project
- from pycs.database.Label import Label
- from pycs.frontend.notifications.NotificationManager import NotificationManager
- class EditLabelName(View):
- """
- edit a labels name
- """
-
- methods = ['POST']
- def dispatch_request(self, project_id: int, label_id: int):
-
- data = request.get_json(force=True)
- if 'name' not in data:
- abort(400)
-
- project = Project.query.get(project_id)
- if project is None:
- abort(404)
-
- label = project.label(label_id)
- if label is None:
- abort(404)
-
- label.set_name(data['name'])
-
- NotificationManager.edited("label", label.id, Label)
-
- return make_response()
|