Skip to content

Commit

Permalink
Merge pull request #150 from CodeHive-Solutions/dev
Browse files Browse the repository at this point in the history
Update Deployment Workflow and Enhance Vacation Request Handling
  • Loading branch information
S-e-b-a-s authored Dec 12, 2024
2 parents 946d841 + 062a55c commit d6b1817
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ jobs:
- name: Deploy to server
run: |
rm -rf /var/www/INSIGHTS/frontend/dist/*
cp -r ./frontend/dist/* /var/www/INSIGHTS/frontend/dist
cp -r ./dist/* /var/www/INSIGHTS/frontend/dist
sudo systemctl restart nginx
8 changes: 6 additions & 2 deletions INSIGHTSAPI/vacation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ class Meta:
@property
def duration(self):
"""Return the duration of the vacation request."""
return get_working_days(self.start_date, self.end_date, self.sat_is_working)
if self.pk:
return get_working_days(self.start_date, self.end_date, self.sat_is_working)
return None

@property
def return_date(self):
"""Return the return date of the vacation request."""
return get_return_date(self.end_date, self.sat_is_working)
if self.pk:
return get_return_date(self.end_date, self.sat_is_working)
return None

def __str__(self):
return f"{self.user} - {self.start_date} - {self.end_date}"
Expand Down
2 changes: 2 additions & 0 deletions INSIGHTSAPI/vacation/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def to_representation(self, instance):
data = super().to_representation(instance)
data["username"] = instance.user.get_full_name()
data["user_id"] = instance.user.id
if "request" in self.context and self.context["request"].user.has_perm("vacation.payroll_approval"):
data["cedula"] = instance.user.cedula
data.pop("manager_approved_at")
data.pop("hr_approved_at")
data.pop("payroll_approved_at")
Expand Down
9 changes: 9 additions & 0 deletions INSIGHTSAPI/vacation/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ def test_vacation_list_manager_multiple_areas(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.data), 2)

def test_vacation_list_payroll(self):
"""Test listing all vacations endpoint for payroll."""
self.user.user_permissions.add(self.permission)
VacationRequest.objects.create(**self.vacation_request_user)
VacationRequest.objects.create(**self.vacation_request_user)
response = self.client.get(reverse("vacation-list"))
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.data), 2)

def test_vacation_list_hr(self):
"""Test listing all vacations endpoint for HR."""
self.user.job_position.name = "GERENTE DE GESTION HUMANA"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/common/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Footer = () => {
>
<Box sx={{ display: 'flex', flexDirection: 'Column', gap: '15px' }}>
<img
loading="lazy"
alt="logo-cyc"
onClick={() =>
window.open('https://cyc-bpo.com/', '_blank')
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/common/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ const Navbar = () => {
className="navbar"
sx={{
backdropFilter: 'blur(10px)',
position: 'sticky',
top: 0,
zIndex: 1001,
}}
>
<Box
Expand All @@ -282,7 +285,7 @@ const Navbar = () => {
alt="logo-cyc-navbar"
style={{ cursor: 'pointer' }}
width={110}
height={55}
height={56}
src={companyLogo}
onClick={() => navigate('/logged/home')}
/>
Expand Down
15 changes: 8 additions & 7 deletions frontend/src/components/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import { Typography, Box, Container, Card } from '@mui/material';
// Media
const benefit = `${getApiUrl().apiUrl}static/images/benefits/benefit-1.webp`;
const cake = `${getApiUrl().apiUrl}static/images/birthdays/cake.webp`;
const AvatarImage = `${getApiUrl().apiUrl}static/birthdays/avatar.webp`;
const AvatarImage = `${getApiUrl().apiUrl}static/images/birthdays/avatar.webp`;
const fultbolVideo = `${getApiUrl().apiUrl}static/videos/futbol.mp4`;
const pointsVideo = `${getApiUrl().apiUrl}static/videos/points.mp4`;

// Libraries
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

const benefits = [{ image: benefit, title: 'befenit' }];

const Home = () => {
const [todayBirthdays, setTodayBirthdays] = useState([]);
const [yesterdayBirthdays, setYesterdayBirthdays] = useState([]);
Expand Down Expand Up @@ -450,10 +448,13 @@ const Home = () => {
>
Beneficios
</Typography>
<CarouselComponent
items={benefits}
height={'960px'}
width={'540px'}
<img
loading="lazy"
style={{ borderRadius: '1rem' }}
width={540}
height={960}
src={benefit}
alt="beneficio"
/>
</Box>
</Box>
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/pages/vacations/Vacations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ export const Vacations = () => {
};

const columns = [
{
field: 'cedula',
headerName: 'Cedula',
width: 110,
type: 'text',
},
{
field: 'start_date',
headerName: 'Fecha inicio',
Expand Down Expand Up @@ -606,7 +612,7 @@ export const Vacations = () => {
};

const handleCloseDialogPayslip = () => {
setOpenDialogPayslip(false);
setOpenDialogPayslip(false);
setOpenObservationsInput(false);
setButtonType('button');
};
Expand Down

0 comments on commit d6b1817

Please sign in to comment.