Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions backend/controllers/committeeController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { NextFunction, Request, Response } from 'express'
import { CustomError, UnauthorizedUserError } from 'ntnui-tools/customError'
import { CommitteeModel } from '../models/Committee'
import { ELECTION_COMMITTEE_ID, MAIN_BOARD_ID } from '../utils/constants'
import {
ELECTION_COMMITTEE_ID,
MAIN_BOARD_ID,
LAW_COMMITTEE_ID,
} from '../utils/constants'
import { RequestWithNtnuiNo } from '../utils/request'
import { getUserRoleInCommitteeByUserId } from '../utils/userCommittee'

Expand Down Expand Up @@ -32,9 +36,11 @@ async function acceptAdmissions(
// If user is organizer, allow toggle of all except main board
(userCommittee.committee === MAIN_BOARD_ID &&
committee._id !== MAIN_BOARD_ID) ||
// If user part of election committee, allow toggle of own and main board
// If user part of election committee, allow toggle of own, main board and the law committee
(userCommittee.committee === ELECTION_COMMITTEE_ID &&
committee._id === MAIN_BOARD_ID) ||
(committee._id === userCommittee.committee ||
committee._id === MAIN_BOARD_ID ||
committee._id === LAW_COMMITTEE_ID)) ||
// If user is board member of the committee and is not in the main board
(userCommittee.committee === committee._id &&
committee._id !== MAIN_BOARD_ID)
Expand Down
12 changes: 12 additions & 0 deletions backend/fixtures/development/committees.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,17 @@
"deputy_board_member"
],
"accepts_admissions": false
},
{
"_id": 11,
"name": "Lovutvalget",
"slug": "lovutvalget",
"access_roles": [
"deputy_leader",
"cashier",
"board_member",
"deputy_board_member"
],
"accepts_admissions": true
}
]
7 changes: 7 additions & 0 deletions backend/fixtures/production/committees.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,12 @@
"slug": "baneutvalget",
"access_roles": ["deputy_leader"],
"accepts_admissions": true
},
{
"_id": 72,
"name": "Lovutvalget",
"slug": "lovutvalget",
"access_roles": ["deputy_leader"],
"accepts_admissions": true
}
]
4 changes: 3 additions & 1 deletion backend/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable no-console */
const MAIN_BOARD_ID = Number(process.env.MAIN_BOARD_ID) || 52
const ELECTION_COMMITTEE_ID = Number(process.env.ELECTION_COMMITTEE_ID) || 71
const LAW_COMMITTEE_ID = Number(process.env.LAW_COMMITTEE_ID) || 72

console.log(`🔗 MAIN_BOARD_ID set to ${MAIN_BOARD_ID}`)
console.log(`🔗 ELECTION_COMMITTEE_ID set to ${ELECTION_COMMITTEE_ID}`)
console.log(`🔗 LAW_COMMITTEE_ID set to ${LAW_COMMITTEE_ID}`)

export { MAIN_BOARD_ID, ELECTION_COMMITTEE_ID }
export { MAIN_BOARD_ID, ELECTION_COMMITTEE_ID, LAW_COMMITTEE_ID }
6 changes: 4 additions & 2 deletions frontend/src/pages/AdmissionStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@
committee.slug !== 'valgkomiteen' && committee.slug !== 'hovedstyret'
)
})
// Election committee can see main board
// Election committee can see main board and the law committee
} else if (locationState.isElectionCommittee) {
allCommittees = await getAllCommittees()
allCommittees = allCommittees.filter((committee: ICommittee) => {
return committee.slug === 'hovedstyret'
return (
committee.slug === 'hovedstyret' || committee.slug === 'lovutvalget'
)
})
// Include the users other committees
const committeesRes = await getUserCommittees()
Expand Down Expand Up @@ -180,7 +182,7 @@
}
}
getCommittees()
}, [])

Check warning on line 185 in frontend/src/pages/AdmissionStatus.tsx

View workflow job for this annotation

GitHub Actions / main (ubuntu-latest, 16.14.0)

React Hook useEffect has missing dependencies: 'location.state' and 'navigate'. Either include them or remove the dependency array

useEffect(() => {
async function getAdmissionPeriodData() {
Expand Down
Loading