This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 65e9ec0c authored by Eduard Frankford's avatar Eduard Frankford
Browse files

review enrolling now works

parent f4275e0f
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
Showing
with 194 additions and 9 deletions
......@@ -104,6 +104,7 @@
"no-new-wrappers": "off",
"object-shorthand": ["off", "always", { "avoidExplicitReturnArrows": true }],
"radix": "off",
"spaced-comment": ["warn", "always"]
"spaced-comment": ["warn", "always"],
"@angular-eslint/no-empty-lifecycle-method": "off"
}
}
......@@ -449,6 +449,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
u.setLastName(oidcUser.getFamilyName());
u.setLogin(email);
u.setActivated(true);
u.setReviewingEnabled(false);
u.setLastModifiedBy("system");
u.setCreatedDate(java.time.Instant.now());
......
......@@ -69,6 +69,10 @@ public class User extends AbstractAuditingEntity implements Serializable {
@Column(nullable = false)
private boolean activated = false;
@NotNull
@Column(nullable = false)
private boolean reviewingEnabled = false;
@Size(min = 2, max = 10)
@Column(name = "lang_key", length = 10)
private String langKey;
......@@ -172,6 +176,14 @@ public class User extends AbstractAuditingEntity implements Serializable {
this.activated = activated;
}
public boolean isReviewingEnabled() {
return reviewingEnabled;
}
public void setReviewingEnabled(boolean reviewingEnabled) {
this.reviewingEnabled = reviewingEnabled;
}
public String getActivationKey() {
return activationKey;
}
......@@ -255,6 +267,7 @@ public class User extends AbstractAuditingEntity implements Serializable {
", email='" + email + '\'' +
", imageUrl='" + imageUrl + '\'' +
", activated='" + activated + '\'' +
", reviewingEnabled='" + reviewingEnabled + '\'' +
", langKey='" + langKey + '\'' +
", activationKey='" + activationKey + '\'' +
"}";
......
......@@ -137,6 +137,7 @@ public class UserService {
newUser.setLangKey(userDTO.getLangKey());
// new user is not active
newUser.setActivated(false);
newUser.setReviewingEnabled(false);
// new user gets registration key
newUser.setActivationKey(RandomUtil.generateActivationKey());
Set<Authority> authorities = new HashSet<>();
......@@ -178,6 +179,7 @@ public class UserService {
user.setResetKey(RandomUtil.generateResetKey());
user.setResetDate(Instant.now());
user.setActivated(true);
user.setReviewingEnabled(true);
if (userDTO.getAuthorities() != null) {
final List<Authority> allAuthorities = authorityRepository.findAll();
......@@ -223,6 +225,7 @@ public class UserService {
}
user.setImageUrl(userDTO.getImageUrl());
user.setActivated(userDTO.isActivated());
user.setReviewingEnabled(userDTO.isReviewingEnabled());
user.setLangKey(userDTO.getLangKey());
final List<Authority> allAuthorities = authorityRepository.findAll();
......
......@@ -48,6 +48,8 @@ public class AdminUserDTO {
private Instant lastLogin;
private boolean reviewingEnabled = false;
private Set<String> authorities;
public AdminUserDTO() {
......@@ -69,6 +71,7 @@ public class AdminUserDTO {
this.lastModifiedDate = user.getLastModifiedDate();
this.lastLogin = user.getLastLogin();
this.authorities = user.getAuthorities().stream().map(Authority::getName).collect(Collectors.toSet());
this.reviewingEnabled = user.isReviewingEnabled();
}
public Long getId() {
......@@ -127,6 +130,14 @@ public class AdminUserDTO {
this.activated = activated;
}
public boolean isReviewingEnabled() {
return reviewingEnabled;
}
public void setReviewingEnabled(boolean reviewingEnabled) {
this.reviewingEnabled = reviewingEnabled;
}
public String getLangKey() {
return langKey;
}
......
......@@ -53,6 +53,7 @@ public class UserMapper {
user.setEmail(userDTO.getEmail());
user.setImageUrl(userDTO.getImageUrl());
user.setActivated(userDTO.isActivated());
user.setReviewingEnabled(userDTO.isReviewingEnabled());
user.setLangKey(userDTO.getLangKey());
Set<Authority> authorities = this.authoritiesFromStrings(userDTO.getAuthorities());
user.setAuthorities(authorities);
......
#H2 Server Properties
#Mon Jan 02 15:29:00 CET 2023
#Mon Feb 20 08:57:05 CET 2023
0=JHipster H2 (Disk)|org.h2.Driver|jdbc\:h2\:file\:./target/h2db/db/gitsearch|gitsearch
webSSL=false
webAllowOthers=true
......
......@@ -128,7 +128,7 @@ spring:
hibernate.query.fail_on_pagination_over_collection_fetch: true
hibernate.query.in_clause_parameter_padding: true
hibernate:
ddl-auto: none
ddl-auto: update
naming:
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
......
......@@ -13,6 +13,7 @@
The initial schema has the '00000000000001' id, so that it is over-written if we re-generate it.
-->
<changeSet id="00000000000001" author="jhipster">
<validCheckSum>8:7e6bd0de3c01ccea4e99bcc5c964ded5</validCheckSum>
<createTable tableName="jhi_user">
<column name="id" type="bigint" autoIncrement="${autoIncrement}" >
<constraints primaryKey="true" nullable="false"/>
......@@ -42,6 +43,9 @@
</column>
<column name="last_modified_by" type="varchar(50)"/>
<column name="last_modified_date" type="timestamp"/>
<column name="reviewing_enabled" type="boolean" valueBoolean="false">
<constraints nullable="false" />
</column>
</createTable>
<createTable tableName="jhi_authority">
......@@ -82,6 +86,7 @@
tableName="jhi_user">
<column name="activated" type="boolean"/>
<column name="created_date" type="timestamp"/>
<column name="reviewing_enabled" type="boolean"/>
</loadData>
<dropDefaultValue tableName="jhi_user" columnName="created_date" columnDataType="datetime"/>
<loadData
......
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<!-- runAlways="true" -> in changeset if data to be populated -->
<changeSet author="eduardfrankford" id="loadData">
<loadData
file="config/liquibase/data/user.csv"
separator=";"
tableName="jhi_user">
<column name="activated" type="boolean" />
<column name="created_date" type="timestamp" />
<column name="reviewing_enabled" type="boolean" />
</loadData>
<dropDefaultValue tableName="jhi_user" columnName="created_date" columnDataType="datetime" />
<loadData
file="config/liquibase/data/authority.csv"
separator=";"
tableName="jhi_authority">
<column name="name" type="string" />
</loadData>
<loadData
file="config/liquibase/data/user_authority.csv"
separator=";"
tableName="jhi_user_authority">
<column name="user_id" type="numeric" />
</loadData>
</changeSet>
</databaseChangeLog>
id;login;password_hash;first_name;last_name;email;image_url;activated;lang_key;created_by;last_modified_by
1;system;$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG;System;System;system@localhost;;true;en;system;system
2;anonymoususer;$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO;Anonymous;User;anonymous@localhost;;true;en;system;system
3;admin;$2a$10$f3bajqkMQSr47/Nzq2sknuO6KTvXG.3BwJk4VryCBb7shnQv7QeG2;Administrator;Administrator;admin@localhost;;true;en;system;system
4;user;$2a$10$WD76nMitzuppCxh5Wl97Hu5unAf2D1ZUedzq75FYf5XpCV8olobba;User;User;user@localhost;;true;en;system;system
id;login;password_hash;first_name;last_name;email;image_url;activated;lang_key;created_by;last_modified_by;reviewing_enabled
1;system;$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG;System;System;system@localhost;;true;en;system;system;true
2;anonymoususer;$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO;Anonymous;User;anonymous@localhost;;true;en;system;system;true
3;admin;$2a$10$f3bajqkMQSr47/Nzq2sknuO6KTvXG.3BwJk4VryCBb7shnQv7QeG2;Administrator;Administrator;admin@localhost;;true;en;system;system;true
4;user;$2a$10$WD76nMitzuppCxh5Wl97Hu5unAf2D1ZUedzq75FYf5XpCV8olobba;User;User;user@localhost;;true;en;system;system;true
......@@ -27,7 +27,7 @@
<include file="config/liquibase/changelog/20210702104135_update_projectID_Likes.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20211407105122_added_Index_exerciseID.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20220221104135_update_SavedSearchLength.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/2023_initdata.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
......
......@@ -12,6 +12,7 @@ import { PasswordResetFinishComponent } from './password-reset/finish/password-r
import { SettingsComponent } from './settings/settings.component';
import { accountState } from './account.route';
import { AchievementsComponent } from './achievements.component';
import { PeerReviewingComponent } from './peer-reviewing/peer-reviewing.component';
@NgModule({
imports: [SharedModule, RouterModule.forChild(accountState), TranslateModule],
......@@ -24,6 +25,7 @@ import { AchievementsComponent } from './achievements.component';
PasswordResetFinishComponent,
SettingsComponent,
AchievementsComponent,
PeerReviewingComponent,
],
})
export class AccountModule {}
......@@ -7,6 +7,7 @@ import { passwordResetInitRoute } from './password-reset/init/password-reset-ini
import { registerRoute } from './register/register.route';
import { settingsRoute } from './settings/settings.route';
import { achievementsRoute } from './achievements.route';
import { peerReviewingRoute } from './peer-reviewing/peer-reviewing.route';
const ACCOUNT_ROUTES = [
activateRoute,
......@@ -16,6 +17,7 @@ const ACCOUNT_ROUTES = [
registerRoute,
settingsRoute,
achievementsRoute,
peerReviewingRoute,
];
export const accountState: Routes = [
......
<!-- Outer container, full page width and height, red border -->
<div class="container-fluid d-flex justify-content-center align-items-center">
<!-- Inner row, half the width and height, centered, blue border -->
<div class="row text-center d-flex align-items-center" style="width: 50vw; height: 50vh">
<div class="ml-auto mr-auto custom-control custom-switch" *ngIf="user">
<input
type="checkbox"
class="custom-control-input"
id="customInput1"
[(ngModel)]="user.reviewingEnabled"
(click)="setReviewerStatusForLogin()"
/>
<label class="custom-control-label" for="customInput1">
<span jhiTranslate="global.menu.account.enable_peer_review">
I want to act as a reviewer for the CodeAbility Sharing Platform
</span>
</label>
</div>
</div>
<!-- Inner row -->
</div>
<!-- Outer container -->
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PeerReviewingComponent } from './peer-reviewing.component';
describe('PeerReviewingComponent', () => {
let component: PeerReviewingComponent;
let fixture: ComponentFixture<PeerReviewingComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [PeerReviewingComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PeerReviewingComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { UserManagementService } from 'app/admin/user-management/service/user-management.service';
import { User } from 'app/admin/user-management/user-management.model';
import { Account } from 'app/core/auth/account.model';
import { AccountService } from 'app/core/auth/account.service';
@Component({
selector: 'jhi-peer-reviewing',
templateUrl: './peer-reviewing.component.html',
styleUrls: ['./peer-reviewing.component.scss'],
})
export class PeerReviewingComponent implements OnInit {
isChecked = false;
currentAccount: Account | null = null;
user: User | null = null;
constructor(private userService: UserManagementService, private accountService: AccountService) {}
ngOnInit(): void {
this.accountService.identity().subscribe(account => (this.currentAccount = account));
this.getUserFromLogin();
}
getUserFromLogin(): void {
if (this.currentAccount != null && this.currentAccount.login != null) {
this.userService.find(this.currentAccount?.login).subscribe(val => (this.user = val));
}
}
setReviewerStatusForLogin(): void {
if (this.user != null && this.currentAccount != null && this.user.login == this.currentAccount.login) {
this.user.reviewingEnabled = !this.user.reviewingEnabled;
this.userService.update(this.user).subscribe();
}
}
}
import { Route } from '@angular/router';
import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { PeerReviewingComponent } from './peer-reviewing.component';
export const peerReviewingRoute: Route = {
path: 'peer-reviewing',
component: PeerReviewingComponent,
data: {
pageTitle: 'Peer Reviewing',
},
canActivate: [UserRouteAccessService],
};
......@@ -25,6 +25,7 @@
<th scope="col" jhiSortBy="login"><span jhiTranslate="userManagement.login">Login</span> <fa-icon icon="sort"></fa-icon></th>
<th scope="col" jhiSortBy="email"><span jhiTranslate="userManagement.email">Email</span> <fa-icon icon="sort"></fa-icon></th>
<th scope="col"></th>
<th scope="col">Reviewer</th>
<th scope="col" jhiSortBy="langKey">
<span jhiTranslate="userManagement.langKey">Lang Key</span> <fa-icon icon="sort"></fa-icon>
</th>
......@@ -70,6 +71,24 @@
Activated
</button>
</td>
<td>
<button
class="btn btn-danger btn-sm"
(click)="setEnableReview(user, true)"
*ngIf="!user.reviewingEnabled"
jhiTranslate="userManagement.deactivated"
>
Deactivated
</button>
<button
class="btn btn-success btn-sm"
(click)="setEnableReview(user, false)"
*ngIf="user.reviewingEnabled"
jhiTranslate="userManagement.activated"
>
Activated
</button>
</td>
<td>{{ user.langKey }}</td>
<td>
<div *ngFor="let authority of user.authorities">
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment