Allow having multiple internal comments on a request
This commit is contained in:
parent
7250e1167c
commit
99a745904f
@ -225,8 +225,8 @@ class Requests(object):
|
|||||||
return Requests._add_review(user, request, review_data)
|
return Requests._add_review(user, request, review_data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_internal_comments(cls, user, request, comment_text):
|
def add_internal_comment(cls, user, request, comment_text):
|
||||||
Authorization.check_can_approve_request(user)
|
Authorization.check_can_approve_request(user)
|
||||||
request.internal_comments = RequestInternalComment(text=comment_text, user=user)
|
comment = RequestInternalComment(request=request, text=comment_text, user=user)
|
||||||
request = RequestsQuery.add_and_commit(request)
|
RequestsQuery.add_and_commit(comment)
|
||||||
return request
|
return request
|
||||||
|
@ -45,7 +45,7 @@ class Request(Base, mixins.TimestampsMixin):
|
|||||||
"RequestRevision", back_populates="request", order_by="RequestRevision.sequence"
|
"RequestRevision", back_populates="request", order_by="RequestRevision.sequence"
|
||||||
)
|
)
|
||||||
|
|
||||||
internal_comments = relationship("RequestInternalComment", uselist=False)
|
internal_comments = relationship("RequestInternalComment")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def latest_revision(self):
|
def latest_revision(self):
|
||||||
@ -167,10 +167,6 @@ class Request(Base, mixins.TimestampsMixin):
|
|||||||
def reviews(self):
|
def reviews(self):
|
||||||
return [status.review for status in self.status_events if status.review]
|
return [status.review for status in self.status_events if status.review]
|
||||||
|
|
||||||
@property
|
|
||||||
def internal_comments_text(self):
|
|
||||||
return self.internal_comments.text if self.internal_comments else ""
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_pending_financial_verification(self):
|
def is_pending_financial_verification(self):
|
||||||
return self.status == RequestStatus.PENDING_FINANCIAL_VERIFICATION
|
return self.status == RequestStatus.PENDING_FINANCIAL_VERIFICATION
|
||||||
|
@ -223,10 +223,13 @@ def test_request_changes_to_financial_verification_info():
|
|||||||
assert current_review.fname_mao == review_data["fname_mao"]
|
assert current_review.fname_mao == review_data["fname_mao"]
|
||||||
|
|
||||||
|
|
||||||
def test_update_internal_comments():
|
def test_add_internal_comment():
|
||||||
request = RequestFactory.create()
|
request = RequestFactory.create()
|
||||||
ccpo = UserFactory.from_atat_role("ccpo")
|
ccpo = UserFactory.from_atat_role("ccpo")
|
||||||
|
|
||||||
request = Requests.update_internal_comments(ccpo, request, "this is my comment")
|
assert len(request.internal_comments) == 0
|
||||||
|
|
||||||
assert request.internal_comments.text == "this is my comment"
|
request = Requests.add_internal_comment(ccpo, request, "this is my comment")
|
||||||
|
|
||||||
|
assert len(request.internal_comments) == 1
|
||||||
|
assert request.internal_comments[0].text == "this is my comment"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user