fix(disputed): add admin role + contact info in discussion modal
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
- request-discussion endpoint: add 'admin' to allowed roles - Return rejector_email and rejector_role in the response - Modal success state shows contact card with username, role, email link so the approving lead can immediately reach out to the rejecting lead
This commit is contained in:
@@ -754,7 +754,7 @@ def sync_tempo(
|
||||
def request_discussion(
|
||||
test_id: uuid.UUID,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(require_any_role("red_lead", "blue_lead")),
|
||||
current_user: User = Depends(require_any_role("red_lead", "blue_lead", "admin")),
|
||||
):
|
||||
"""Called when the approving lead confirms their vote in a disputed test.
|
||||
|
||||
@@ -774,12 +774,12 @@ def request_discussion(
|
||||
role = current_user.role
|
||||
|
||||
# Identify who the "other lead" is (the one who rejected)
|
||||
if role == "red_lead" and test.red_validation_status == "approved":
|
||||
if (role in ("red_lead", "admin")) and test.red_validation_status == "approved":
|
||||
# Red approved, Blue rejected → notify Blue Lead who rejected
|
||||
rejector_id = test.blue_validated_by
|
||||
rejector_label = "Blue Lead"
|
||||
requester_label = "Red Lead"
|
||||
elif role == "blue_lead" and test.blue_validation_status == "approved":
|
||||
elif (role in ("blue_lead", "admin")) and test.blue_validation_status == "approved":
|
||||
# Blue approved, Red rejected → notify Red Lead who rejected
|
||||
rejector_id = test.red_validated_by
|
||||
rejector_label = "Red Lead"
|
||||
@@ -787,15 +787,16 @@ def request_discussion(
|
||||
else:
|
||||
from app.domain.errors import BusinessRuleViolation
|
||||
raise BusinessRuleViolation(
|
||||
"You are not the approving lead in this conflict or the state is inconsistent"
|
||||
"The conflict state is inconsistent — no approving lead found"
|
||||
)
|
||||
|
||||
# Look up the rejecting lead's username for the message
|
||||
# Look up the rejecting lead's full info for the response
|
||||
rejector = (
|
||||
db.query(UserModel).filter(UserModel.id == rejector_id).first()
|
||||
if rejector_id else None
|
||||
)
|
||||
rejector_name = rejector.username if rejector else rejector_label
|
||||
rejector_email = getattr(rejector, "email", None) if rejector else None
|
||||
|
||||
# Notify the rejecting lead
|
||||
if rejector_id:
|
||||
@@ -833,6 +834,8 @@ def request_discussion(
|
||||
"status": "notification_sent",
|
||||
"message": f"Discussion request sent to {rejector_name}",
|
||||
"rejector_username": rejector_name,
|
||||
"rejector_email": rejector_email,
|
||||
"rejector_role": rejector_label,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user