Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interview group forms #1573

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions backend/root/utils/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@
samfundet__recruitment_list = 'samfundet:recruitment-list'
samfundet__recruitment_detail = 'samfundet:recruitment-detail'
samfundet__recruitment_gangs = 'samfundet:recruitment-gangs'
samfundet__recruitment_sharedinterviewgroups_list = 'samfundet:recruitment_sharedinterviewgroups-list'
samfundet__recruitment_sharedinterviewgroups_detail = 'samfundet:recruitment_sharedinterviewgroups-detail'
samfundet__recruitment_for_recruiter_list = 'samfundet:recruitment_for_recruiter-list'
samfundet__recruitment_for_recruiter_detail = 'samfundet:recruitment_for_recruiter-detail'
samfundet__recruitment_stats_list = 'samfundet:recruitment_stats-list'
Expand Down
7 changes: 5 additions & 2 deletions backend/samfundet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,6 @@ class Meta:


class RecruitmentPositionSharedInterviewGroupSerializer(serializers.ModelSerializer):
positions = RecruitmentPositionForApplicantSerializer(many=True, read_only=True)

class Meta:
model = RecruitmentPositionSharedInterviewGroup
fields = [
Expand All @@ -946,6 +944,11 @@ class Meta:
'name_nb',
]

def to_representation(self, instance: RecruitmentPositionSharedInterviewGroup) -> dict:
data = super().to_representation(instance)
data['positions'] = RecruitmentPositionForApplicantSerializer(instance.positions, many=True).data
return data


class RecruitmentApplicationForApplicantSerializer(CustomBaseSerializer):
interview = ApplicantInterviewSerializer(read_only=True)
Expand Down
3 changes: 2 additions & 1 deletion backend/samfundet/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

########## Recruitment ##########
router.register('recruitment', views.RecruitmentView, 'recruitment')
router.register('recruitment-sharedinterviewgroup', views.RecruitmentSharedInterviewPositionsView, 'recruitment_sharedinterviewgroups')
router.register('recruitment-for-recruiter', views.RecruitmentForRecruiterView, 'recruitment_for_recruiter')
router.register('recruitment-stats', views.RecruitmentStatisticsView, 'recruitment_stats')
router.register('recruitment-separateposition', views.RecruitmentSeparatePositionView, 'recruitment_separateposition')
Expand Down Expand Up @@ -90,7 +91,7 @@
),
path(
'recruitment-shared-interview-groups/<int:recruitment_id>/',
views.RecruitmentInterviewGroupView.as_view(),
views.RecruitmentSharedInterviewPositionsRecruitmentView.as_view(),
name='recruitment_shared_interviews',
),
path('recruitment-positions-gang-for-gangs/', views.RecruitmentPositionsPerGangForGangView.as_view(), name='recruitment_positions_gang_for_gangs'),
Expand Down
9 changes: 8 additions & 1 deletion backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,13 @@ class RecruitmentForRecruiterView(ModelViewSet):
queryset = Recruitment.objects.all()


@method_decorator(ensure_csrf_cookie, 'dispatch')
class RecruitmentSharedInterviewPositionsView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly,)
serializer_class = RecruitmentPositionSharedInterviewGroupSerializer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RecruitmentSharedInterviewPositionsSerializer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

queryset = RecruitmentPositionSharedInterviewGroup.objects.all()


@method_decorator(ensure_csrf_cookie, 'dispatch')
class RecruitmentStatisticsView(ModelViewSet):
permission_classes = (DjangoModelPermissions,) # Allow read only to permissions on perms
Expand Down Expand Up @@ -1136,7 +1143,7 @@ def get_queryset(self) -> Response:
return Recruitment.objects.filter(visible_from__lte=timezone.now(), actual_application_deadline__gte=timezone.now())


class RecruitmentInterviewGroupView(APIView):
class RecruitmentSharedInterviewPositionsRecruitmentView(APIView):
permission_classes = [IsAuthenticated]

def get(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@import "src/constants";

@import "src/mixins";

.button {
margin-top: 2rem;
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type ReactElement, useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { CrudButtons, Link, type Tab, TabView } from '~/Components';
import { Button, CrudButtons, Link, type Tab, TabView } from '~/Components';
import { Table } from '~/Components/Table';
import { deleteRecruitmentSeparatePosition, getRecruitment, getRecruitmentGangs } from '~/api';
import type { RecruitmentDto, RecruitmentGangDto, RecruitmentSeparatePositionDto } from '~/dto';
Expand All @@ -11,7 +11,9 @@ import { reverse } from '~/named-urls';
import { ROUTES } from '~/routes';
import { dbT, lowerCapitalize } from '~/utils';
import { AdminPageLayout } from '../AdminPageLayout/AdminPageLayout';
import { AppletContainer, RecruitmentInterviewGroupsList } from './components';
import { AppletContainer, RecruitmentSharedInterviewPositionsList } from './components';

import styles from './RecruitmentGangOverviewPage.module.scss';

export function RecruitmentGangOverviewPage() {
const { recruitmentId } = useParams();
Expand Down Expand Up @@ -124,7 +126,26 @@ export function RecruitmentGangOverviewPage() {
label: t(KEY.recruitment_gangs_with_separate_positions),
value: <Table columns={tableSeparatePositionColumns} data={tableSeparatePositionData ?? []} />,
},
{ key: 3, label: t(KEY.recruitment_interview_groups), value: <RecruitmentInterviewGroupsList /> },
{
key: 3,
label: t(KEY.recruitment_interview_group_create_header),
value: (
<>
<Button
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Knappen burde være over listen. Den blir litt gjemt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

className={styles.button}
theme="success"
rounded={true}
link={reverse({
pattern: ROUTES.frontend.admin_recruitment_sharedinterviewgroup_create,
urlParams: { recruitmentId: recruitmentId },
})}
>
{lowerCapitalize(`${t(KEY.common_create)} ${t(KEY.recruitment_interview_group)}`)}
</Button>{' '}
<RecruitmentSharedInterviewPositionsList />
</>
),
},
];
}, [gangs, recruitment, t, recruitmentId, navigate, deleteSeparatePositionHandler]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { toast } from 'react-toastify';
import { getRecruitmentSharedInterviewGroups, getRecruitmentStats } from '~/api';
import type { RecruitmentSharedInterviewGroupDto, RecruitmentStatsDto } from '~/dto';
import { getRecruitmentSharedInterviewPositionss, getRecruitmentStats } from '~/api';
import type { RecruitmentSharedInterviewPositionsDto, RecruitmentStatsDto } from '~/dto';
import { KEY } from '~/i18n/constants';
import styles from './RecruitmentInterviewGroupsList.module.scss';
import { RecruitmentInterviewGroupComponent } from './components/RecruitmentInterviewGroupComponent/RecruitmentInterviewGroupComponent';
import styles from './RecruitmentSharedInterviewPositionsList.module.scss';
import { RecruitmentSharedInterviewPositionsComponent } from './components/RecruitmentSharedInterviewPositionsComponent/RecruitmentSharedInterviewPositionsComponent';

export function RecruitmentInterviewGroupsList() {
export function RecruitmentSharedInterviewPositionsList() {
const { recruitmentId } = useParams();
const [interviewGroups, setInterviewGroups] = useState<RecruitmentSharedInterviewGroupDto[]>();
const [interviewGroups, setInterviewGroups] = useState<RecruitmentSharedInterviewPositionsDto[]>();
const { t } = useTranslation();

useEffect(() => {
if (recruitmentId) {
getRecruitmentSharedInterviewGroups(recruitmentId)
getRecruitmentSharedInterviewPositionss(recruitmentId)
.then((response) => {
setInterviewGroups(response.data);
})
Expand All @@ -28,8 +28,8 @@ export function RecruitmentInterviewGroupsList() {

return (
<div className={styles.container}>
{interviewGroups?.map((interviewGroup: RecruitmentSharedInterviewGroupDto) => {
return <RecruitmentInterviewGroupComponent interviewGroup={interviewGroup} key={interviewGroup.id} />;
{interviewGroups?.map((interviewGroup: RecruitmentSharedInterviewPositionsDto) => {
return <RecruitmentSharedInterviewPositionsComponent interviewGroup={interviewGroup} key={interviewGroup.id} />;
})}
</div>
);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@
width: 100%;
flex: 1;
}

.footer {
justify-content: end;
display: flex;
padding: 0.5em;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { useTranslation } from 'react-i18next';
import { Button, ExpandableHeader, Table } from '~/Components';
import type { RecruitmentSharedInterviewPositionsDto, RecruitmentStatsDto } from '~/dto';
import { KEY } from '~/i18n/constants';
import { reverse } from '~/named-urls';
import { ROUTES } from '~/routes';
import { dbT } from '~/utils';
import styles from './RecruitmentSharedInterviewPositionsComponent.module.scss';

type RecruitmentSharedInterviewPositionsComponentProps = {
interviewGroup: RecruitmentSharedInterviewPositionsDto;
};

export function RecruitmentSharedInterviewPositionsComponent({
interviewGroup,
}: RecruitmentSharedInterviewPositionsComponentProps) {
const interviewGroupHeader = dbT(interviewGroup, 'name') ?? 'N/A';
const { t } = useTranslation();

return (
<ExpandableHeader
showByDefault={true}
key={interviewGroup.id}
label={interviewGroupHeader}
className={styles.dropDownHeader}
>
<Table
className={styles.table}
data={interviewGroup.positions.map((position) => {
return { cells: [dbT(position, 'name'), dbT(position.gang, 'name')] };
})}
/>
<div className={styles.footer}>
<Button
display="basic"
theme="blue"
rounded={true}
link={reverse({
pattern: ROUTES.frontend.admin_recruitment_sharedinterviewgroup_edit,
urlParams: { recruitmentId: interviewGroup.recruitment, sharedInterviewGroupId: interviewGroup.id },
})}
>
{t(KEY.common_edit)}
</Button>
</div>
</ExpandableHeader>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { RecruitmentSharedInterviewPositionsComponent } from './RecruitmentSharedInterviewPositionsComponent';
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { AppletCard } from './AppletCard/AppletCard';
export { AppletContainer } from './AppletContainer/AppletContainer';
export { RecruitmentInterviewGroupsList } from './RecruitmentInterviewGroupsList/RecruitmentInterviewGroupsList';
export { RecruitmentSharedInterviewPositionsList } from './RecruitmentInterviewGroupsList/RecruitmentSharedInterviewPositionsList';
Loading
Loading