Skip to content

Commit

Permalink
feat: add auditor role
Browse files Browse the repository at this point in the history
  • Loading branch information
satikaj committed May 28, 2024
1 parent a319562 commit 51d2d0b
Show file tree
Hide file tree
Showing 31 changed files with 62 additions and 52 deletions.
4 changes: 2 additions & 2 deletions src/app/admin/states/f-units/f-units.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h3>{{ title }}</h3>
[uiParams]="{unitId: row.id}"
></tr>
}
@if (mode === 'admin') {
@if (mode === 'admin' || mode === 'auditor') {
<tr
mat-row
*matRowDef="let row; columns: displayedColumns"
Expand All @@ -126,7 +126,7 @@ <h3>{{ title }}</h3>
<span class="flex items-center">
<mat-paginator class="mat-elevation-z0" [pageSizeOptions]="[10, 25, 100]"></mat-paginator>
<span class="flex-grow"></span>
@if (mode === 'admin') {
@if (mode === 'admin' || mode === 'auditor') {
<button mat-raised-button color="primary" (click)="createUnit()">
<mat-icon class="icon_display">add</mat-icon>
Create Unit
Expand Down
6 changes: 3 additions & 3 deletions src/app/admin/states/f-units/f-units.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class FUnitsComponent implements OnInit, AfterViewInit {
@ViewChild(MatSort, {static: false}) sort: MatSort;
@ViewChild(MatPaginator, {static: false}) paginator: MatPaginator;

@Input({required: true}) mode: 'admin' | 'tutor' | 'student';
@Input({required: true}) mode: 'admin' | 'auditor' | 'tutor' | 'student';

displayedColumns: string[] = [
'unit_code',
Expand All @@ -56,7 +56,7 @@ export class FUnitsComponent implements OnInit, AfterViewInit {
title: string;

shouldShowUnitRoleColumn(): boolean {
return this.mode === 'admin' || this.mode === 'tutor';
return this.mode === 'admin' || this.mode === 'auditor' || this.mode === 'tutor';
}

constructor(
Expand All @@ -79,7 +79,7 @@ export class FUnitsComponent implements OnInit, AfterViewInit {
});
});
}
if (this.mode === 'admin') {
if (this.mode === 'admin' || this.mode === 'auditor') {
this.title = 'Administer units';

this.unitService.query(undefined, {params: {include_in_active: true}}).subscribe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class TeachingPeriodUnitImportDialogComponent implements OnInit {
// Load all teaching staff
this.userService.getTutors().subscribe((staff) => {
this.teachingStaff = staff
.filter((s) => ['Convenor', 'Admin'].includes(s.systemRole))
.filter((s) => ['Convenor', 'Auditor', 'Admin'].includes(s.systemRole))
.sort((a, b) => a.name.localeCompare(b.name));

// Load all units now we have the staff
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/models/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class Unit extends Entity {
}

public get currentUserIsConvenor(): boolean {
return this.myRole === 'Convenor' || this.myRole === 'Admin';
return this.myRole === 'Convenor' || this.myRole === 'Auditor' || this.myRole === 'Admin';
}

public get taskDefinitions(): readonly TaskDefinition[] {
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/models/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class User extends Entity {
email: string;
username: string;
nickname: string;
systemRole: 'Admin' | 'Convenor' | 'Tutor' | 'Student';
systemRole: 'Admin' | 'Auditor' | 'Convenor' | 'Tutor' | 'Student';
receiveTaskNotifications: boolean;
receivePortfolioNotifications: boolean;
receiveFeedbackNotifications: boolean;
Expand All @@ -36,7 +36,7 @@ export class User extends Entity {
}

public get isStaff(): boolean {
return ['Tutor', 'Convenor', 'Admin'].includes(this.systemRole);
return ['Tutor', 'Convenor', 'Auditor', 'Admin'].includes(this.systemRole);
}

public get name(): string {
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/services/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class AuthenticationService {
}
}

private readonly validRoles: string[] = ['anon', 'Student', 'Tutor', 'Convenor', 'Admin'];
private readonly validRoles: string[] = ['anon', 'Student', 'Tutor', 'Convenor', 'Auditor', 'Admin'];

private isValidRoleWhitelist(roleWhitelist: string[]) {
return roleWhitelist.filter((role: string) => this.validRoles.includes(role)).length !== 0;
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ export class UserService extends CachedEntityService<User> {
return this.query(undefined, { endpointFormat: this.tutorEndpointFormat });
}

public adminRoleFor(unitId: number, user: User): UnitRole {
public adminAuditorRoleFor(role: 'Admin' | 'Auditor', unitId: number, user: User): UnitRole {
const result = new UnitRole();
result.role = 'Admin';
result.role = role;
result.user = user;

const unitService = AppInjector.get(UnitService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ <h1>{{ initialFirstName }}</h1>
<mat-label>System Role</mat-label>
<mat-select [(ngModel)]="user.systemRole" name="systemRole" [disabled]="!canEditSystemRole">
<mat-option value="Admin">Administrator</mat-option>
<mat-option value="Auditor">Auditor</mat-option>
<mat-option value="Convenor">Convenor</mat-option>
<mat-option value="Tutor">Tutor</mat-option>
<mat-option value="Student">Student</mat-option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export class EditProfileFormComponent implements OnInit {

public get canSeeSystemRole(): boolean {
return (
this.userService.currentUser.systemRole === 'Admin' || this.userService.currentUser.systemRole === 'Convenor'
this.userService.currentUser.systemRole === 'Admin' ||
this.userService.currentUser.systemRole === 'Auditor' ||
this.userService.currentUser.systemRole === 'Convenor'
);
}

Expand Down
10 changes: 7 additions & 3 deletions src/app/common/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@

<span class="grow"></span>

@if (currentUser.role === 'Admin' || currentUser.role === 'Convenor') {
@if (
currentUser.role === 'Admin' ||
currentUser.role === 'Auditor' ||
currentUser.role === 'Convenor'
) {
<button
#menuState="matMenuTrigger"
mat-icon-button
Expand All @@ -47,7 +51,7 @@
</button>
}
<mat-menu #menu="matMenu">
@if (currentUser.role === 'Admin') {
@if (currentUser.role === 'Admin' || currentUser.role === 'Auditor') {
<button mat-menu-item uiSref="institutionsettings">
<mat-icon matListItemIcon>business</mat-icon>
Institution Settings
Expand All @@ -57,7 +61,7 @@
<mat-icon matListItemIcon>school</mat-icon>
Manage Units
</button>
@if (currentUser.role === 'Admin') {
@if (currentUser.role === 'Admin' || currentUser.role === 'Auditor') {
<button mat-menu-item uiSref="admin/users">
<mat-icon matListItemIcon>people</mat-icon>
Manage Users
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@
}
@if (unitRole && currentView === 'UNIT') {
<!-- <p class="task-dropdown-heading">Tasks</p> -->
@if (unitRole.role !== 'Admin') {
@if (unitRole.role !== 'Admin' && unitRole.role !== 'Auditor') {
<button uiSref="units/tasks/inbox" [uiParams]="{unitId: unitRole.unit.id}" mat-menu-item>
<mat-icon aria-label="Inbox icon" fontIcon="inbox"></mat-icon> <span>Inbox</span>
</button>
}
@if (unitRole.role !== 'Admin') {
@if (unitRole.role !== 'Admin' && unitRole.role !== 'Auditor') {
<button
uiSref="units/tasks/definition"
[uiParams]="{unitId: unitRole.unit.id}"
Expand Down Expand Up @@ -148,7 +148,9 @@
<button uiSref="units/analytics" [uiParams]="{unitId: unitRole.unit.id}" mat-menu-item>
<mat-icon aria-label="Unit Analytics icon" fontIcon="insights"></mat-icon>Analytics
</button>
@if (unitRole.role === 'Convenor' || unitRole.role === 'Admin') {
@if (
unitRole.role === 'Convenor' || unitRole.role === 'Auditor' || unitRole.role === 'Admin'
) {
<button uiSref="units/admin" [uiParams]="{unitId: unitRole.unit.id}" mat-menu-item>
<mat-icon aria-label="Unit Administration" fontIcon="admin_panel_settings"></mat-icon>
Administration
Expand Down
22 changes: 11 additions & 11 deletions src/app/doubtfire.states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const institutionSettingsState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Institution Settings',
roleWhiteList: ['Admin'],
roleWhiteList: ['Admin', 'Auditor'],
},
};

Expand All @@ -42,7 +42,7 @@ const usersState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Administer users',
roleWhiteList: ['Admin'],
roleWhiteList: ['Admin', 'Auditor'],
},
};

Expand All @@ -59,7 +59,7 @@ const HomeState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Home Page',
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'],
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'],
},
};

Expand Down Expand Up @@ -165,7 +165,7 @@ const WelcomeState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Welcome',
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'],
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'],
},
};

Expand All @@ -182,7 +182,7 @@ const SignInState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Sign In',
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'],
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'],
},
};

Expand All @@ -199,7 +199,7 @@ const EditProfileState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Edit Profile',
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'],
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'],
},
};

Expand All @@ -213,7 +213,7 @@ const TeachingPeriodsState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Teaching Periods',
roleWhitelist: ['Convenor', 'Admin'],
roleWhitelist: ['Convenor', 'Admin', 'Auditor'],
},
};

Expand All @@ -227,7 +227,7 @@ const EulaState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Teaching Periods',
roleWhitelist: ['Convenor', 'Admin'],
roleWhitelist: ['Convenor', 'Admin', 'Auditor'],
},
};

Expand All @@ -246,7 +246,7 @@ const ViewAllProjectsState: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Teaching Periods',
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'],
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'],
},
};

Expand All @@ -266,7 +266,7 @@ const AdministerUnits: NgHybridStateDeclaration = {
},
data: {
pageTitle: 'Administer units',
roleWhiteList: ['Admin'],
roleWhiteList: ['Admin', 'Auditor'],
},
};

Expand All @@ -288,7 +288,7 @@ const ViewAllUnits: NgHybridStateDeclaration = {
data: {
pageTitle: 'Teaching Periods',
mode: 'tutor',
roleWhitelist: ['Tutor', 'Convenor', 'Admin'],
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor'],
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/app/home/states/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class HomeComponent implements OnInit, OnDestroy {

this.notEnrolled = this.checkEnrolled();

this.ifAdmin = this.currentUser.role === 'Admin';
this.ifAdmin = this.currentUser.role === 'Admin' || this.currentUser.role === 'Auditor';
this.ifConvenor = this.currentUser.role === 'Convenor';

if (this.ifAdmin) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/projects/states/dashboard/dashboard.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ angular.module('doubtfire.projects.states.dashboard', [
data:
task: "Dashboard"
pageTitle: "_Home_"
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student']
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor', 'Student']
}
)

Expand Down
2 changes: 1 addition & 1 deletion src/app/projects/states/groups/groups.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ angular.module('doubtfire.projects.states.groups', [])
data:
task: "Groups List"
pageTitle: "_Home_"
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student']
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor', 'Student']
}
)

Expand Down
2 changes: 1 addition & 1 deletion src/app/projects/states/index/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ angular.module('doubtfire.projects.states.index', [])
templateUrl: "units/states/index/index.tpl.html" # We can re-use unit's index here
data:
pageTitle: "_Home_"
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin']
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor']
}
)

Expand Down
2 changes: 1 addition & 1 deletion src/app/projects/states/outcomes/outcomes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ angular.module('doubtfire.projects.states.outcomes', [])
data:
task: "Learning Outcomes"
pageTitle: "_Home_"
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student']
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor', 'Student']
}
)

Expand Down
2 changes: 1 addition & 1 deletion src/app/projects/states/portfolio/portfolio.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ angular.module('doubtfire.projects.states.portfolio', [
data:
task: "Portfolio Creation"
pageTitle: "_Home_"
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student']
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor', 'Student']
}
)

Expand Down
2 changes: 1 addition & 1 deletion src/app/projects/states/tutorials/tutorials.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ angular.module('doubtfire.projects.states.tutorials', [])
data:
task: "Tutorial List"
pageTitle: "_Home_"
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student']
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor', 'Student']
}
)

Expand Down
1 change: 1 addition & 0 deletions src/app/sessions/auth/roles/roles.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ angular.module("doubtfire.sessions.auth.roles", [
"Student"
"Tutor"
"Convenor"
"Auditor"
"Admin"
])
2 changes: 1 addition & 1 deletion src/app/units/states/analytics/analytics.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ angular.module('doubtfire.units.states.analytics', [])
data:
task: "Unit Analytics"
pageTitle: "_Home_"
roleWhitelist: ['Tutor', 'Convenor', 'Admin']
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor']
}
)
.controller("UnitAnalyticsStateCtrl", ($scope) ->
Expand Down
2 changes: 1 addition & 1 deletion src/app/units/states/edit/edit.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ angular.module('doubtfire.units.states.edit', [
data:
task: 'Unit Administration'
pageTitle: "_Unit Administration_"
roleWhitelist: ['Convenor', 'Admin']
roleWhitelist: ['Convenor', 'Admin', 'Auditor']
}
)
.controller('EditUnitStateCtrl', ($scope, $state, $stateParams, alertService, analyticsService, newUnitService, newUserService, GlobalStateService) ->
Expand Down
2 changes: 1 addition & 1 deletion src/app/units/states/groups/groups.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ angular.module('doubtfire.units.states.groups', [])
data:
task: "Student Groups"
pageTitle: "_Home_"
roleWhitelist: ['Tutor', 'Convenor', 'Admin']
roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor']
}
)
.controller("UnitGroupsStateCtrl", ($scope) ->
Expand Down
6 changes: 3 additions & 3 deletions src/app/units/states/index/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ angular.module('doubtfire.units.states.index', [])
templateUrl: "units/states/index/index.tpl.html"
data:
pageTitle: "_Home_"
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin']
roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor']
}
)

Expand All @@ -26,8 +26,8 @@ angular.module('doubtfire.units.states.index', [])
# Load assessing unit role
$scope.unitRole = GlobalStateService.loadedUnitRoles.currentValues.find((unitRole) -> unitRole.unit.id == unitId)

if (! $scope.unitRole?) && ( newUserService.currentUser.role == "Admin" )
$scope.unitRole = newUserService.adminRoleFor(unitId, newUserService.currentUser)
if (! $scope.unitRole?) && ( newUserService.currentUser.role == "Admin" || newUserService.currentUser.role == "Auditor" )
$scope.unitRole = newUserService.adminAuditorRoleFor(newUserService.currentUser.role, unitId, newUserService.currentUser)

# Go home if no unit role was found
return $state.go('home') unless $scope.unitRole?
Expand Down
Loading

0 comments on commit 51d2d0b

Please sign in to comment.