request model knows its most recent review comment
This commit is contained in:
parent
6facf746e2
commit
73d3851813
@ -194,3 +194,13 @@ class Request(Base):
|
|||||||
@property
|
@property
|
||||||
def is_approved(self):
|
def is_approved(self):
|
||||||
return self.status == RequestStatus.APPROVED
|
return self.status == RequestStatus.APPROVED
|
||||||
|
|
||||||
|
@property
|
||||||
|
def review_comment(self):
|
||||||
|
if (
|
||||||
|
self.status == RequestStatus.CHANGES_REQUESTED
|
||||||
|
or self.status == RequestStatus.CHANGES_REQUESTED_TO_FINVER
|
||||||
|
):
|
||||||
|
review = self.latest_status.review
|
||||||
|
if review:
|
||||||
|
return review.comment
|
||||||
|
@ -92,3 +92,26 @@ def test_reviews():
|
|||||||
RequestStatusEventFactory.create(revision=request.latest_revision),
|
RequestStatusEventFactory.create(revision=request.latest_revision),
|
||||||
]
|
]
|
||||||
assert len(request.reviews) == 2
|
assert len(request.reviews) == 2
|
||||||
|
|
||||||
|
|
||||||
|
def test_review_comment():
|
||||||
|
request = RequestFactory.create()
|
||||||
|
ccpo = UserFactory.from_atat_role("ccpo")
|
||||||
|
request.status_events = [
|
||||||
|
RequestStatusEventFactory.create(
|
||||||
|
revision=request.latest_revision,
|
||||||
|
new_status=RequestStatus.CHANGES_REQUESTED,
|
||||||
|
review=RequestReviewFactory.create(reviewer=ccpo, comment="do better"),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
assert request.review_comment == "do better"
|
||||||
|
|
||||||
|
request.status_events = [
|
||||||
|
RequestStatusEventFactory.create(
|
||||||
|
revision=request.latest_revision,
|
||||||
|
new_status=RequestStatus.APPROVED,
|
||||||
|
review=RequestReviewFactory.create(reviewer=ccpo, comment="much better"),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
assert not request.review_comment
|
||||||
|
Loading…
x
Reference in New Issue
Block a user