Skip to content

Commit

Permalink
Täsä the data
Browse files Browse the repository at this point in the history
  • Loading branch information
Veikkosuhonen committed Jan 22, 2024
1 parent 976163e commit cb49f73
Show file tree
Hide file tree
Showing 8 changed files with 1,741 additions and 1,707 deletions.
9 changes: 5 additions & 4 deletions src/auth/IAMConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { normalizeOrganisationCode } from './common'
import { FACULTY_MAP, data } from './data'
import { FACULTIES } from '../organisation/faculties'
import { FACULTY_MAP } from '../organisation/types'

const ANY = 'ANY'

Expand Down Expand Up @@ -498,7 +499,7 @@ const iamToFaculty = (iam) => {

for (const f of faculties) {
if (facultyIamsMap[f].includes(iam)) {
const faculty = data.find(({ code }) => code === FACULTY_MAP[f])
const faculty = FACULTIES.find(({ code }) => code === FACULTY_MAP[f])
return faculty
}
}
Expand Down Expand Up @@ -527,9 +528,9 @@ const RELEVANT_ORGANISATION_CODES = [
]

const relevantOrganisations = RELEVANT_ORGANISATION_CODES.concat(
data.map((faculty) => faculty.code),
FACULTIES.map((faculty) => faculty.code),
).concat(
data.flatMap((faculty) =>
FACULTIES.flatMap((faculty) =>
faculty.programmes.map((programme) =>
normalizeOrganisationCode(programme.key),
),
Expand Down
8 changes: 4 additions & 4 deletions src/auth/IAMRights.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
isKatselmusViewer,
dekaaniIamToFaculty
} from './IAMConfig'
import { data } from './data'
import { FACULTIES } from '../organisation/faculties'
import { mapToDegreeCode } from './common'

/**
Expand All @@ -28,7 +28,7 @@ import { mapToDegreeCode } from './common'
*/
const getAllProgrammeAccess = (accessLevel, where) => {
const access = {}
data.forEach((faculty) => {
FACULTIES.forEach((faculty) => {
faculty.programmes.forEach((program) => {
if (where?.(program) === false) return
access[program.key] = { ...accessLevel }
Expand Down Expand Up @@ -195,7 +195,7 @@ const getFacultyReadingRights = (hyGroups) => {
.filter(Boolean)
const access = {}
facultyCodes.forEach((fc) => {
const faculty = data.find((faculty) => faculty.code === fc)
const faculty = FACULTIES.find((faculty) => faculty.code === fc)
const programmeCodes = faculty.programmes.map((p) => p.key)
programmeCodes.forEach((code) => {
access[code] = { read: true, write: false, admin: false }
Expand All @@ -214,7 +214,7 @@ const getFacultyAdminRights = (hyGroups) => {

const access = {}
facultyCodes.forEach((fc) => {
const faculty = data.find((faculty) => faculty.code === fc)
const faculty = FACULTIES.find((faculty) => faculty.code === fc)
const programmeCodes = faculty.programmes.map((p) => p.key)
programmeCodes.forEach((code) => {
access[code] = { read: true, write: true, admin: true }
Expand Down
Loading

0 comments on commit cb49f73

Please sign in to comment.