mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-29 07:54:19 +00:00
Add alert editing routes
This commit is contained in:
parent
b5af4283ce
commit
da4c5e1334
2 changed files with 7 additions and 0 deletions
|
@ -67,6 +67,11 @@ app.add_url_rule(
|
||||||
view_func=routes.page_repository_alerts,
|
view_func=routes.page_repository_alerts,
|
||||||
methods=["GET", "POST"]
|
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(
|
app.add_url_rule(
|
||||||
"/api/v1/conditions/<int:cid>",
|
"/api/v1/conditions/<int:cid>",
|
||||||
view_func=routes.page_condition,
|
view_func=routes.page_condition,
|
||||||
|
|
|
@ -113,6 +113,8 @@ def page_alert(aid):
|
||||||
"""
|
"""
|
||||||
user = find_user(get_jwt_identity())
|
user = find_user(get_jwt_identity())
|
||||||
alert = Alert.query.filter_by(id=aid).first()
|
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:
|
if not alert:
|
||||||
return json_error("Could not find alert."), 404
|
return json_error("Could not find alert."), 404
|
||||||
if alert.repository not in [a.repository for a in user.authorizations] + user.owner_of:
|
if alert.repository not in [a.repository for a in user.authorizations] + user.owner_of:
|
||||||
|
|
Loading…
Reference in a new issue