暫無描述

case_comments.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # IRIS Source Code
  2. # DFIR-IRIS Team
  3. # contact@dfir-iris.org
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 3 of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. import marshmallow
  19. from flask import request
  20. from app.schema.marshables import CommentSchema
  21. from app.blueprints.responses import response_error
  22. from app.blueprints.responses import response_success
  23. from app.business.case_comments import case_comments_update
  24. from app.business.errors import BusinessProcessingError
  25. def case_comment_update(comment_id, object_type, caseid):
  26. try:
  27. comment_schema = CommentSchema()
  28. rq_t = request.get_json()
  29. comment_text = rq_t.get('comment_text')
  30. comment = case_comments_update(comment_text, comment_id, object_type, caseid)
  31. return response_success("Comment edited", data=comment_schema.dump(comment))
  32. except BusinessProcessingError as e:
  33. return response_error(e.get_message(), data=e.get_data())
  34. except marshmallow.exceptions.ValidationError as e:
  35. return response_error(msg='Data error', data=e.normalized_messages())