diff --git a/frontend/public/locales/en/common.json b/frontend/public/locales/en/common.json index d577a248de0da775fe2d24f0f0ca8782075b01a4..4fb32e744a529a077c9227174132b218c53944d4 100644 --- a/frontend/public/locales/en/common.json +++ b/frontend/public/locales/en/common.json @@ -82,6 +82,7 @@ "name": "Name", "role": "Guest role", "period": "Period", + "host": "Host", "ou": "Organisation", "department": "Department", "choice": "Choices", diff --git a/frontend/public/locales/nb/common.json b/frontend/public/locales/nb/common.json index c1c20c7e7076f72f2ab58eea16c2654d72e06835..93451ae367074958355c3380a4b1e3a4676a947c 100644 --- a/frontend/public/locales/nb/common.json +++ b/frontend/public/locales/nb/common.json @@ -82,6 +82,7 @@ "name": "Navn", "role": "Gjesterolle", "period": "Periode", + "host": "Vert", "ou": "Organisasjon", "department": "Avdeling", "choice": "Valg", diff --git a/frontend/public/locales/nn/common.json b/frontend/public/locales/nn/common.json index 23cc41728257e834c6df137b0c34f9e940c9f40c..c649f55ba90abcebbb7572a7aa17be9dcb319498 100644 --- a/frontend/public/locales/nn/common.json +++ b/frontend/public/locales/nn/common.json @@ -82,6 +82,7 @@ "name": "Namn", "role": "Gjesterolle", "period": "Periode", + "host": "Vert", "ou": "Organisasjonsenhet", "department": "Enhet", "choice": "Val", diff --git a/frontend/src/components/roleLine/index.tsx b/frontend/src/components/roleLine/index.tsx index f57d3e68eb32a164a24ddccd4e85fe06ed563df1..9bd73c40ae44edf9a2c66d538c12e254d020ec4c 100644 --- a/frontend/src/components/roleLine/index.tsx +++ b/frontend/src/components/roleLine/index.tsx @@ -22,6 +22,7 @@ const RoleLine = ({ role, pid }: RoleLineProps) => { {role.start_date ? format(role.start_date, 'yyyy-MM-dd') : null} -{' '} {format(role.end_date, 'yyyy-MM-dd')} </TableCell> + <TableCell align="left">{role.sponsor_name}</TableCell> <TableCell> <Button variant="contained" diff --git a/frontend/src/interfaces/index.ts b/frontend/src/interfaces/index.ts index fe1309b2c195f83a21dbdee9dbc209db49237616..4e5766da531443af5d573dd075a1fa7f768b168f 100644 --- a/frontend/src/interfaces/index.ts +++ b/frontend/src/interfaces/index.ts @@ -55,6 +55,7 @@ export type Role = { max_days: number contact_person_unit: string | null comments: string | null + sponsor_name: string } export type FetchedRole = { @@ -68,6 +69,7 @@ export type FetchedRole = { max_days: number contact_person_unit: string | null comments: string | null + sponsor_name: string } export type ConsentType = { diff --git a/frontend/src/routes/sponsor/guest/guestInfo/index.tsx b/frontend/src/routes/sponsor/guest/guestInfo/index.tsx index c691d1145ed4ce6d481d84e314b9927538fa1f97..ba55ea72c5f1d5baaae79fbcf7c316c182b84b9e 100644 --- a/frontend/src/routes/sponsor/guest/guestInfo/index.tsx +++ b/frontend/src/routes/sponsor/guest/guestInfo/index.tsx @@ -362,6 +362,7 @@ export default function GuestInfo({ <TableHeadCell align="left">{t('common:role')}</TableHeadCell> <TableHeadCell align="left">{t('common:ou')}</TableHeadCell> <TableHeadCell align="left">{t('common:period')}</TableHeadCell> + <TableHeadCell align="left">{t('common:host')}</TableHeadCell> <TableHeadCell align="left" /> </TableRow> {guest.roles.map((role) => ( diff --git a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx index c63c674bc69e229d9097ba21fa0e9e78c1b69fcd..a9ac03667481cad35d2b2537424adedd7338626d 100644 --- a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx +++ b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx @@ -115,6 +115,7 @@ export default function GuestRoleInfo({ max_days: 365, contact_person_unit: null, comments: null, + sponsor_name: '', }) // Prepare min and max date values const today = new Date() @@ -268,6 +269,13 @@ export default function GuestRoleInfo({ <TableCell align="left">{getRoleOuName(role)}</TableCell> <TableCell align="left" /> </TableRow> + <TableRow> + <TableCell align="left" sx={{ fontWeight: 'bold' }}> + {t('common:host')} + </TableCell> + <TableCell align="left">{role.sponsor_name}</TableCell> + <TableCell align="left" /> + </TableRow> {displayContactAtUnit && ( <TableRow> <TableCell align="left" sx={{ fontWeight: 'bold' }}> diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index d89b241898eac2e8c4bac4a11d4a9f73a6c1b251..430805b265353b97b2bc34898ec8ee7e04d84a4e 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -150,6 +150,7 @@ export function parseRole(role: FetchedRole): Role { max_days: role.max_days, contact_person_unit: role.contact_person_unit, comments: role.comments, + sponsor_name: role.sponsor_name, } } diff --git a/gregui/api/serializers/role.py b/gregui/api/serializers/role.py index 40b2e8093b8b106c123d3c24404f8d1c76f5121f..4353e4b560d19ad66abd88f7965a451fd910c4ef 100644 --- a/gregui/api/serializers/role.py +++ b/gregui/api/serializers/role.py @@ -103,6 +103,7 @@ class ExtendedRoleSerializer(serializers.ModelSerializer): ou_nb = SerializerMethodField(source="orgunit") ou_en = SerializerMethodField(source="orgunit") max_days = SerializerMethodField(source="type") + sponsor_name = SerializerMethodField(source="sponsor") def get_name_nb(self, obj): return obj.type.name_nb @@ -119,6 +120,9 @@ class ExtendedRoleSerializer(serializers.ModelSerializer): def get_max_days(self, obj): return obj.type.max_days + def get_sponsor_name(self, obj): + return f"{obj.sponsor.first_name} {obj.sponsor.last_name}" + class Meta: model = Role fields = [ @@ -132,7 +136,6 @@ class ExtendedRoleSerializer(serializers.ModelSerializer): "max_days", "contact_person_unit", "comments", + "sponsor_name", ] - read_only_fields = [ - "contact_person_unit", - ] + read_only_fields = ["contact_person_unit", "sponsor_name"] diff --git a/gregui/tests/api/serializers/test_guest.py b/gregui/tests/api/serializers/test_guest.py index 456f7034749421b12efc07b4fc660d9621f0b5d7..ed47312828a4531379132cb38e66dfdc771e93c3 100644 --- a/gregui/tests/api/serializers/test_guest.py +++ b/gregui/tests/api/serializers/test_guest.py @@ -34,6 +34,7 @@ def test_serialize_guest(invited_person): "max_days": 365, "contact_person_unit": "", "comments": "", + "sponsor_name": "Sponsor Bar", }, ], "verified": False,