diff --git a/templates/vacations_app/vacation_print_form.html b/templates/vacations_app/vacation_print_form.html index 2db9e6b..9a3e966 100644 --- a/templates/vacations_app/vacation_print_form.html +++ b/templates/vacations_app/vacation_print_form.html @@ -77,7 +77,7 @@
-

Mendoza, {% now 'd \d\e F \d\e Y' %}

+

Mendoza, {{object.created | date:"F j, Y"}}

Por medio de la presente, se deja constancia del acuerdo entre {{object.employee.first_name}} {{object.employee.last_name}}, @@ -90,11 +90,11 @@

Las mismas comienzan el día - {{object.from_date}} + {{object.from_date | date:"F j, Y"}} y finalizan el día - {{object.to_date}}, + {{object.to_date | date:"F j, Y"}}, retomando sus labores habituales el día - {{object.to_date_next_day}}. + {{object.to_date_next_day | date:"F j, Y"}}. Finalizada esta licencia, el saldo de vacaciones correspondiente a dicho periodo es de {{object.year_vacation_left}} días. diff --git a/vacations_app/migrations/0001_initial.py b/vacations_app/migrations/0001_initial.py index 09c9375..980b42e 100644 --- a/vacations_app/migrations/0001_initial.py +++ b/vacations_app/migrations/0001_initial.py @@ -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 @@ -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=[ @@ -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'), + ), ] diff --git a/vacations_app/migrations/0002_group_permissions.py b/vacations_app/migrations/0002_group_permissions.py index 6804738..87429ba 100644 --- a/vacations_app/migrations/0002_group_permissions.py +++ b/vacations_app/migrations/0002_group_permissions.py @@ -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 diff --git a/vacations_app/migrations/0003_auto_20191106_1418.py b/vacations_app/migrations/0003_auto_20191106_1418.py deleted file mode 100644 index 377ce03..0000000 --- a/vacations_app/migrations/0003_auto_20191106_1418.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.24 on 2019-11-06 14:18 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('vacations_app', '0002_group_permissions'), - ] - - operations = [ - 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.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='managed_team', 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'), - ), - ] diff --git a/vacations_app/migrations/0004_auto_20191106_1519.py b/vacations_app/migrations/0004_auto_20191106_1519.py deleted file mode 100644 index 420d6dc..0000000 --- a/vacations_app/migrations/0004_auto_20191106_1519.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.24 on 2019-11-06 15:19 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('vacations_app', '0003_auto_20191106_1418'), - ] - - operations = [ - migrations.AlterField( - model_name='team', - name='engineer_manager', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='managed_teams', to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/vacations_app/migrations/0005_auto_20191108_1302.py b/vacations_app/migrations/0005_auto_20191108_1302.py deleted file mode 100644 index 12dbb08..0000000 --- a/vacations_app/migrations/0005_auto_20191108_1302.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.24 on 2019-11-08 13:02 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('vacations_app', '0004_auto_20191106_1519'), - ] - - operations = [ - migrations.AlterField( - model_name='vacation', - name='days_quantity', - field=models.IntegerField(), - ), - ] diff --git a/vacations_app/migrations/0006_auto_20191108_1453.py b/vacations_app/migrations/0006_auto_20191108_1453.py deleted file mode 100644 index b9b21ec..0000000 --- a/vacations_app/migrations/0006_auto_20191108_1453.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.24 on 2019-11-08 14:53 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('vacations_app', '0005_auto_20191108_1302'), - ] - - operations = [ - migrations.AlterField( - model_name='vacation', - name='from_date', - field=models.DateField(), - ), - ] diff --git a/vacations_app/migrations/0007_assignedvacations.py b/vacations_app/migrations/0007_assignedvacations.py deleted file mode 100644 index fa7c14c..0000000 --- a/vacations_app/migrations/0007_assignedvacations.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.24 on 2019-11-08 15:36 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('vacations_app', '0006_auto_20191108_1453'), - ] - - operations = [ - 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)), - ], - ), - ] diff --git a/vacations_app/models.py b/vacations_app/models.py index afbc712..6dd512a 100644 --- a/vacations_app/models.py +++ b/vacations_app/models.py @@ -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 @@ -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() @@ -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 diff --git a/vacations_app/views.py b/vacations_app/views.py index c6c1809..6f106cd 100644 --- a/vacations_app/views.py +++ b/vacations_app/views.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals from io import BytesIO from datetime import timedelta