chore(): minor fixes around codebase
This commit is contained in:
@@ -339,6 +339,7 @@ def experiment_submit_for_review(
|
||||
def experiment_approve(
|
||||
*, experiment: Experiment, approver: User, comment: str = ""
|
||||
) -> Experiment:
|
||||
experiment = Experiment.objects.select_for_update().get(pk=experiment.pk)
|
||||
if experiment.status != ExperimentStatus.IN_REVIEW:
|
||||
raise ValidationError(
|
||||
{"status": "Experiment must be in 'in_review' status to approve."}
|
||||
@@ -386,6 +387,15 @@ def experiment_approve(
|
||||
def experiment_reject(
|
||||
*, experiment: Experiment, user: User, comment: str = ""
|
||||
) -> Experiment:
|
||||
if not can_user_approve_experimenter(user, experiment.owner):
|
||||
raise ValidationError(
|
||||
{
|
||||
"user": (
|
||||
f"User '{user.username}' is not authorized to "
|
||||
f"reject experiments for '{experiment.owner.username}'."
|
||||
)
|
||||
}
|
||||
)
|
||||
experiment = _transition(
|
||||
experiment,
|
||||
ExperimentStatus.REJECTED,
|
||||
@@ -401,6 +411,15 @@ def experiment_reject(
|
||||
def experiment_request_changes(
|
||||
*, experiment: Experiment, user: User, comment: str = ""
|
||||
) -> Experiment:
|
||||
if not can_user_approve_experimenter(user, experiment.owner):
|
||||
raise ValidationError(
|
||||
{
|
||||
"user": (
|
||||
f"User '{user.username}' is not authorized to "
|
||||
f"request changes for '{experiment.owner.username}'."
|
||||
)
|
||||
}
|
||||
)
|
||||
experiment.approvals.all().delete()
|
||||
return _transition(
|
||||
experiment,
|
||||
|
||||
Reference in New Issue
Block a user