Add pdf column and uploader
This commit is contained in:
@@ -36,15 +36,6 @@ class Authorization(object):
|
||||
def is_ccpo(cls, user):
|
||||
return user.atat_role.name == "ccpo"
|
||||
|
||||
@classmethod
|
||||
def check_is_mo_or_cor(cls, user, task_order):
|
||||
if (
|
||||
task_order.contracting_officer_representative != user
|
||||
and task_order.creator != user
|
||||
):
|
||||
message = "build Task Order {}".format(task_order.id)
|
||||
raise UnauthorizedError(user, message)
|
||||
|
||||
@classmethod
|
||||
def check_is_ko(cls, user, task_order):
|
||||
if task_order.contracting_officer != user:
|
||||
|
@@ -51,8 +51,8 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
||||
start_date = Column(Date) # Period of Performance
|
||||
end_date = Column(Date)
|
||||
performance_length = Column(Integer)
|
||||
attachment_id = Column(ForeignKey("attachments.id"))
|
||||
_csp_estimate = relationship("Attachment")
|
||||
csp_attachment_id = Column(ForeignKey("attachments.id"))
|
||||
_csp_estimate = relationship("Attachment", foreign_keys=[csp_attachment_id])
|
||||
clin_01 = Column(Numeric(scale=2))
|
||||
clin_02 = Column(Numeric(scale=2))
|
||||
clin_03 = Column(Numeric(scale=2))
|
||||
@@ -72,6 +72,8 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
||||
so_email = Column(String) # Email
|
||||
so_phone_number = Column(String) # Phone Number
|
||||
so_dod_id = Column(String) # DOD ID
|
||||
pdf_attachment_id = Column(ForeignKey("attachments.id"))
|
||||
_pdf = relationship("Attachment", foreign_keys=[pdf_attachment_id])
|
||||
number = Column(String, unique=True) # Task Order Number
|
||||
loa = Column(String) # Line of Accounting (LOA)
|
||||
custom_clauses = Column(String) # Custom Clauses
|
||||
@@ -93,6 +95,21 @@ class TaskOrder(Base, mixins.TimestampsMixin):
|
||||
elif new_csp_estimate:
|
||||
raise TypeError("Could not set csp_estimate with invalid type")
|
||||
|
||||
@hybrid_property
|
||||
def pdf(self):
|
||||
return self._pdf
|
||||
|
||||
@pdf.setter
|
||||
def pdf(self, new_pdf):
|
||||
if isinstance(new_pdf, Attachment):
|
||||
self._pdf = new_pdf
|
||||
elif isinstance(new_pdf, FileStorage):
|
||||
self._pdf = Attachment.attach(new_pdf, "task_order", self.id)
|
||||
elif not new_pdf and self._pdf:
|
||||
self._pdf = None
|
||||
elif new_pdf:
|
||||
raise TypeError("Could not set pdf with invalid type")
|
||||
|
||||
@property
|
||||
def is_submitted(self):
|
||||
|
||||
|
@@ -261,7 +261,6 @@ def get_started():
|
||||
@task_orders_bp.route("/portfolios/<portfolio_id>/task_orders/new/<int:screen>")
|
||||
def new(screen, task_order_id=None, portfolio_id=None):
|
||||
workflow = ShowTaskOrderWorkflow(g.current_user, screen, task_order_id)
|
||||
Authorization.check_is_mo_or_cor(g.current_user, task_order)
|
||||
return render_template(
|
||||
workflow.template,
|
||||
current=screen,
|
||||
@@ -284,7 +283,6 @@ def update(screen, task_order_id=None, portfolio_id=None):
|
||||
workflow = UpdateTaskOrderWorkflow(
|
||||
g.current_user, form_data, screen, task_order_id, portfolio_id
|
||||
)
|
||||
Authorization.check_is_mo_or_cor(g.current_user, task_order)
|
||||
if workflow.validate():
|
||||
workflow.update()
|
||||
return redirect(
|
||||
|
Reference in New Issue
Block a user