From e1ec9aa18145bb50f6066275edab7f81eb86fa39 Mon Sep 17 00:00:00 2001 From: maayarosama <66883096+maayarosama@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:04:17 +0200 Subject: [PATCH] Development admin accessibility (#367) * Adding access to admin to request vacations for other users * Adding admin endpoit * fixing vacation card error * Development admin accessibility backend (#368) * Implementation: Implemented an endpoint for admins to post vacations behalf of the user. * Enhancement: rename the route of the admin vacations request * Typo: replaced the pinding by pending. * Using enum in selectionOption and exporting ListUsers in helpers --------- Co-authored-by: Thunder --- client/src/clients/api/vacations.ts | 17 ++ client/src/components/SetUserVacations.vue | 38 ++-- client/src/components/UpdateUser.vue | 31 ++-- client/src/components/cards/vacationCard.vue | 3 +- .../src/components/requests/leaveRequest.vue | 134 ++++++++++++-- client/src/types/index.ts | 7 +- client/src/utils/helpers.ts | 17 ++ server/cshr/routes/vacations.py | 2 + server/cshr/serializers/vacations.py | 5 + server/cshr/services/compensation.py | 2 +- server/cshr/services/hr_letters.py | 2 +- server/cshr/services/official_documents.py | 4 +- server/cshr/services/requests.py | 12 +- server/cshr/utils/redis_functions.py | 2 +- server/cshr/utils/vacation_balance_helper.py | 2 +- server/cshr/views/compensation.py | 2 +- server/cshr/views/vacations.py | 165 ++++++++++++++++-- 17 files changed, 352 insertions(+), 93 deletions(-) diff --git a/client/src/clients/api/vacations.ts b/client/src/clients/api/vacations.ts index f882c78f9..cf423b744 100644 --- a/client/src/clients/api/vacations.ts +++ b/client/src/clients/api/vacations.ts @@ -12,6 +12,7 @@ export class VacationsApi extends ApiClientBase { readonly edit: VacationsEditApi readonly get_admin_balance: VacationsGetAdminBalanceApi readonly post_admin_balance: VacationsPostAdminBalanceApi + readonly admin: VacationsAdmin readonly user: VacationsUserApi constructor(options: Api.ClientOptions) { @@ -25,6 +26,7 @@ export class VacationsApi extends ApiClientBase { this.edit = new VacationsEditApi(options, this.path) this.get_admin_balance = new VacationsGetAdminBalanceApi(options, this.path) this.post_admin_balance = new VacationsPostAdminBalanceApi(options, this.path) + this.admin= new VacationsAdmin(options, this.path) this.user = new VacationsUserApi(options, this.path) } @@ -168,6 +170,21 @@ class VacationsGetAdminBalanceApi extends ApiClientBase { }) } } +class VacationsAdmin extends ApiClientBase { + protected readonly path = '/admin' + + + async create(id: number, input: Api.Inputs.Leave) { + ApiClientBase.assertUser() + const vacation = await this.unwrap( + () => this.$http.post(this.getUrl(`/${id}`), input), + { transform: (d) => d.results } + ) + + return vacation + } +} + class VacationsPostAdminBalanceApi extends ApiClientBase { protected readonly path = '/post-admin-balance' diff --git a/client/src/components/SetUserVacations.vue b/client/src/components/SetUserVacations.vue index 1df4a2d52..c17cd4c0c 100644 --- a/client/src/components/SetUserVacations.vue +++ b/client/src/components/SetUserVacations.vue @@ -80,17 +80,8 @@