Skip to content

Commit

Permalink
Add created to Vacation model, fix PDF dates
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabertranou-eb committed Nov 11, 2019
1 parent 9fb821c commit 6ae19fb
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 135 deletions.
8 changes: 4 additions & 4 deletions templates/vacations_app/vacation_print_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</tr>
</table>
<div class="content">
<p class="date">Mendoza, <b><u>{% now 'd \d\e F \d\e Y' %}</u></b></p>
<p class="date">Mendoza, <b><u>{{object.created | date:"F j, Y"}}</u></b></p>
<p class="paragraph">
Por medio de la presente, se deja constancia del acuerdo entre
<b><u>{{object.employee.first_name}} {{object.employee.last_name}}</u></b>,
Expand All @@ -90,11 +90,11 @@

<p class="paragraph">
Las mismas comienzan el día
<b><u>{{object.from_date}}</u></b>
<b><u>{{object.from_date | date:"F j, Y"}}</u></b>
y finalizan el día
<b><u>{{object.to_date}}</u></b>,
<b><u>{{object.to_date | date:"F j, Y"}}</u></b>,
retomando sus labores habituales el día
<b><u>{{object.to_date_next_day}}</u></b>.
<b><u>{{object.to_date_next_day | date:"F j, Y"}}</u></b>.
Finalizada esta licencia,
el saldo de vacaciones correspondiente a dicho periodo es de
<b><u>{{object.year_vacation_left}}</u></b> días.
Expand Down
35 changes: 31 additions & 4 deletions vacations_app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-11-05 19:35
# Generated by Django 1.11.24 on 2019-11-11 15:03
from __future__ import unicode_literals

from django.conf import settings
Expand Down Expand Up @@ -33,12 +33,20 @@ class Migration(migrations.Migration):
('job_start_date', models.DateField(null=True)),
('initial_annual_vacations_days', models.IntegerField(default=14)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='AssignedVacations',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('worked_year', models.IntegerField()),
('total_days', models.IntegerField()),
('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Holiday',
fields=[
Expand All @@ -47,15 +55,34 @@ class Migration(migrations.Migration):
('date', models.DateField(unique=True)),
],
),
migrations.CreateModel(
name='Team',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30)),
('engineer_manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='managed_teams', to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Vacation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('from_date', models.DateField(validators=[vacations_app.models.validate_from_date])),
('days_quantity', models.IntegerField(choices=[(7, 7), (14, 14), (21, 21), (28, 28)])),
('created', models.DateTimeField(auto_now_add=True)),
('from_date', models.DateField()),
('days_quantity', models.IntegerField()),
('to_date', models.DateField()),
('applicable_worked_year', models.IntegerField(validators=[vacations_app.models.validate_year])),
('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='employee',
name='team',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='members', to='vacations_app.Team'),
),
migrations.AddField(
model_name='employee',
name='user_permissions',
field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions'),
),
]
2 changes: 1 addition & 1 deletion vacations_app/migrations/0002_group_permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-11-05 18:41
# Generated by Django 1.11.24 on 2019-11-11 15:03
from __future__ import unicode_literals

from django.db import migrations
Expand Down
30 changes: 0 additions & 30 deletions vacations_app/migrations/0003_auto_20191106_1418.py

This file was deleted.

22 changes: 0 additions & 22 deletions vacations_app/migrations/0004_auto_20191106_1519.py

This file was deleted.

20 changes: 0 additions & 20 deletions vacations_app/migrations/0005_auto_20191108_1302.py

This file was deleted.

20 changes: 0 additions & 20 deletions vacations_app/migrations/0006_auto_20191108_1453.py

This file was deleted.

26 changes: 0 additions & 26 deletions vacations_app/migrations/0007_assignedvacations.py

This file was deleted.

8 changes: 2 additions & 6 deletions vacations_app/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from datetime import date, timedelta
from django.db import models
from django.contrib.auth.models import PermissionsMixin
Expand Down Expand Up @@ -90,7 +87,7 @@ def get_short_name(self):


class Vacation(models.Model):

created = models.DateTimeField(auto_now_add=True)
from_date = models.DateField()
days_quantity = models.IntegerField()
to_date = models.DateField()
Expand All @@ -109,8 +106,7 @@ def year_vacation_left(self):
)
total = 0
for vacation in vacations:
vacation_diff = vacation.to_date - vacation.from_date
total += vacation_diff.days
total += vacation.days_quantity
return self.employee.initial_annual_vacations_days - total


Expand Down
2 changes: 0 additions & 2 deletions vacations_app/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from io import BytesIO
from datetime import timedelta

Expand Down

0 comments on commit 6ae19fb

Please sign in to comment.