Skip to content

Commit 4b029ab

Browse files
author
Joni Salmi
committed
Implemented code review request disabling per exercise
1 parent 28070f7 commit 4b029ab

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

tmc-plugin/src/fi/helsinki/cs/tmc/actions/RequestReviewAction.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@ protected CourseDb getCourseDb() {
7070

7171
@Override
7272
public boolean enable(Project... projects) {
73-
if (projects.length > 1) {
73+
if (projects.length != 1) {
7474
return false; // One at a time please
75-
} else {
76-
return super.enable(projects);
7775
}
76+
77+
TmcProjectInfo projectInfo = projectMediator.wrapProject(projects[0]);
78+
Exercise exercise = projectMediator.tryGetExerciseForProject(projectInfo, courseDb);
79+
80+
if (exercise != null && !exercise.isCodeReviewRequestsEnabled()) {
81+
return false;
82+
}
83+
84+
return super.enable(projects);
7885
}
7986

8087
@Override

tmc-plugin/src/fi/helsinki/cs/tmc/data/Exercise.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public class Exercise implements Serializable {
5757
@SerializedName("valgrind_strategy")
5858
private ValgrindStrategy valgrindStrategy = ValgrindStrategy.FAIL;
5959

60+
@SerializedName("code_review_requests_enabled")
61+
private boolean codeReviewRequestsEnabled;
62+
6063
public enum ValgrindStrategy {
6164
@SerializedName("")
6265
NONE,
@@ -262,6 +265,14 @@ public ValgrindStrategy getValgrindStrategy() {
262265
return valgrindStrategy;
263266
}
264267

268+
public boolean isCodeReviewRequestsEnabled() {
269+
return codeReviewRequestsEnabled;
270+
}
271+
272+
public void setCodeReviewRequestsEnabled(boolean codeReviewRequestsEnabled) {
273+
this.codeReviewRequestsEnabled = codeReviewRequestsEnabled;
274+
}
275+
265276
@Override
266277
public String toString() {
267278
return name;

0 commit comments

Comments
 (0)