Merge pull request #511 from dod-ccpo/csp-integration

Refactor CSP integration
This commit is contained in:
patricksmithdds
2019-01-03 09:59:55 -05:00
committed by GitHub
11 changed files with 381 additions and 285 deletions

View File

@@ -5,8 +5,7 @@ from flask import current_app as app
from atst.models import Base, types, mixins
from atst.database import db
from atst.uploader import UploadError
from atst.domain.exceptions import NotFoundError
from atst.domain.exceptions import NotFoundError, UploadError
class AttachmentError(Exception):
@@ -25,12 +24,12 @@ class Attachment(Base, mixins.TimestampsMixin):
@classmethod
def attach(cls, fyle, resource=None, resource_id=None):
try:
filename, object_name = app.uploader.upload(fyle)
object_name = app.csp.files.upload(fyle)
except UploadError as e:
raise AttachmentError("Could not add attachment. " + str(e))
attachment = Attachment(
filename=filename,
filename=fyle.filename,
object_name=object_name,
resource=resource,
resource_id=resource_id,