Skip to content

Commit

Permalink
CSCEXAM-1404 User agreement prompt for all user roles
Browse files Browse the repository at this point in the history
  • Loading branch information
lupari committed Feb 4, 2025
1 parent 57b7ae0 commit 9484dbf
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 17 deletions.
18 changes: 9 additions & 9 deletions app/controllers/admin/SettingsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ public Result provideMaturityInstructions(String ref, String lang) {

@Restrict({ @Group("ADMIN") })
public Result updateUserAgreement(Http.Request request) {
DynamicForm df = formFactory.form().bindFromRequest(request);
String eula = df.get("value");
JsonNode body = request.body().asJson();
String eula = body.get("value").asText();
GeneralSettings gs = getOrCreateSettings("eula", eula, null);

// Since the EULA has changed, force users to accept it again.
String updStatement = "update app_user set user_agreement_accepted = :hasNot";
Update<User> update = DB.createUpdate(User.class, updStatement);
update.set("hasNot", false);
update.execute();

if (!body.get("majorUpdate").asBoolean()) {
// Since the EULA has changed, force users to accept it again.
String updStatement = "update app_user set user_agreement_accepted = :hasNot";
Update<User> update = DB.createUpdate(User.class, updStatement);
update.set("hasNot", false);
update.execute();
}
return ok(Json.toJson(gs));
}

Expand Down
2 changes: 1 addition & 1 deletion conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ PUT /app/maintenance/:id
DELETE /app/maintenance/:id controllers.facility.MaintenancePeriodController.removeMaintenancePeriod(id: Long)

#######################################################
GET /attributes controllers.user.SessionController.getAttributes(request: Request)
GET /app/attributes controllers.user.SessionController.getAttributes(request: Request)

# static assets
GET /*path controllers.assets.FrontendController.assetOrDefault(path)
8 changes: 7 additions & 1 deletion ui/src/app/administrative/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@
</div>
</div>
<div class="row mt-2">
<div class="col-12">
<div class="col-1">
<button (click)="updateAgreement()" class="btn btn-success">
{{ 'i18n_button_save' | translate }}
</button>
</div>
<div class="col form-check mt-2">
<label class="form-check-label ms-2" for="exclude-update">{{
'i18n_minor_agreement_update' | translate
}}</label>
<input id="exclude-update" class="form-check-input" type="checkbox" [(ngModel)]="majorAgreementUpdate" />
</div>
</div>

<div class="row mt-2 align-items-end">
Expand Down
6 changes: 5 additions & 1 deletion ui/src/app/administrative/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { SettingsService } from './settings.service';
export class SettingsComponent implements OnInit {
config!: AppConfig;
attributes: string[] = [];
majorAgreementUpdate = false;

constructor(
private Settings: SettingsService,
Expand All @@ -45,7 +46,10 @@ export class SettingsComponent implements OnInit {
}

updateAgreement = () =>
this.Settings.updateAgreement$(this.config).subscribe({ next: this.onSuccess, error: this.onError });
this.Settings.updateAgreement$(this.config, this.majorAgreementUpdate).subscribe({
next: this.onSuccess,
error: this.onError,
});

updateDeadline = () =>
this.Settings.updateDeadline$(this.config).subscribe({ next: this.onSuccess, error: this.onError });
Expand Down
5 changes: 3 additions & 2 deletions ui/src/app/administrative/settings/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import { AppConfig } from 'src/app/administrative/administrative.model';
export class SettingsService {
constructor(private http: HttpClient) {}

updateAgreement$ = (config: AppConfig) => this.http.put('/app/settings/agreement', { value: config.eula });
updateAgreement$ = (config: AppConfig, bypassAgreementUpdate = false) =>
this.http.put('/app/settings/agreement', { value: config.eula, majorUpdate: bypassAgreementUpdate });

updateDeadline$ = (config: AppConfig) => this.http.put('/app/settings/deadline', { value: config.reviewDeadline });

updateReservationWindow$ = (config: AppConfig) =>
this.http.put('/app/settings/reservationWindow', { value: config.reservationWindowSize });

listAttributes$ = () => this.http.get<string[]>('/attributes');
listAttributes$ = () => this.http.get<string[]>('/app/attributes');

getConfig$ = () => this.http.get<AppConfig>('/app/config');
}
3 changes: 2 additions & 1 deletion ui/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1238,5 +1238,6 @@
"i18n_language_inspection_reports_title": "Language inspection reports",
"i18n_login_title": "Login",
"i18n_logout_title": "Logged out",
"i18n_assessment_questions_title": "Assessment questions"
"i18n_assessment_questions_title": "Assessment questions",
"i18n_minor_agreement_update": "Muutos jota ei tarvitse tiedottaa käyttäjille"
}
3 changes: 2 additions & 1 deletion ui/src/assets/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1238,5 +1238,6 @@
"i18n_language_inspection_reports_title": "Kielentarkastuksen raportit",
"i18n_login_title": "Kirjautuminen",
"i18n_logout_title": "Kirjattu ulos",
"i18n_assessment_questions_title": "Arvioinnin kysymykset"
"i18n_assessment_questions_title": "Arvioinnin kysymykset",
"i18n_minor_agreement_update": "Muutos jota ei tarvitse tiedottaa käyttäjille"
}
3 changes: 2 additions & 1 deletion ui/src/assets/i18n/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -1238,5 +1238,6 @@
"i18n_language_inspection_reports_title": "Språkgranskningsrapporter SV",
"i18n_login_title": "Logga in SV",
"i18n_logout_title": "Logga ut SV",
"i18n_assessment_questions_title": "Bedömningsfrågor SV"
"i18n_assessment_questions_title": "Bedömningsfrågor SV",
"i18n_minor_agreement_update": "Muutos jota ei tarvitse tiedottaa käyttäjille SV"
}

0 comments on commit 9484dbf

Please sign in to comment.