1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00

Add alert editing routes

This commit is contained in:
Lorenzo Balugani 2021-05-10 16:34:34 +02:00
parent b5af4283ce
commit da4c5e1334
2 changed files with 7 additions and 0 deletions

View file

@ -67,6 +67,11 @@ app.add_url_rule(
view_func=routes.page_repository_alerts,
methods=["GET", "POST"]
)
app.add_url_rule(
"/api/v1/alert/<int:aid>",
view_func=routes.page_alert,
methods=["GET", "PATCH", "DELETE", "PUT"]
)
app.add_url_rule(
"/api/v1/conditions/<int:cid>",
view_func=routes.page_condition,

View file

@ -113,6 +113,8 @@ def page_alert(aid):
"""
user = find_user(get_jwt_identity())
alert = Alert.query.filter_by(id=aid).first()
if alert.repository_id not in user.owner_of:
return json_error("The user is not authorized."), 403
if not alert:
return json_error("Could not find alert."), 404
if alert.repository not in [a.repository for a in user.authorizations] + user.owner_of: