Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix report deletion through API #492

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions backend/ibutsu_server/controllers/report_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,25 @@ def get_report_list(page=1, page_size=25, project=None, token_info=None, user=No


@validate_uuid
def delete_report(id_):
def delete_report(id_, user=None, token_info=None):
"""Deletes a report

:param id: ID of the report to delete
:type id: str

:rtype: tuple
"""
try:
report = Report.query.get(id_)
session.delete(report)
session.commit()
return "OK", 200
except Exception:
report = Report.query.get(id_)
if not report:
return "Not Found", 404

report_file = ReportFile.query.filter(ReportFile.report_id == report.id).first()
session.delete(report_file)

session.delete(report)
session.commit()
return "OK", 200


@validate_uuid
def view_report(id_, filename, token_info=None, user=None):
Expand Down
Loading