diff --git a/templates/vacations_app/admin_vacation_request.html b/templates/vacations_app/admin_vacation_request.html index ac452ab..d1821b4 100644 --- a/templates/vacations_app/admin_vacation_request.html +++ b/templates/vacations_app/admin_vacation_request.html @@ -6,7 +6,7 @@

Admin Vacation Request

-
+ {% csrf_token %} {% for hidden_field in form.hidden_fields %} diff --git a/templates/vacations_app/assignedvacations_confirm_delete.html b/templates/vacations_app/assignedvacations_confirm_delete.html new file mode 100644 index 0000000..7fbc107 --- /dev/null +++ b/templates/vacations_app/assignedvacations_confirm_delete.html @@ -0,0 +1,20 @@ +{% extends 'vacations_app/base.html' %} +{% load bootstrap4 %} +{% load widget_tweaks %} + +{% block content %} +

Employee Assigned Vacation

+
+
+ {% csrf_token %} +

Are you sure you want to delete "{{ object }}"?

+ + + +
+
+{% endblock content %} +{% block scripts %} + {{ block.super }} + {{form.media }} +{% endblock scripts %} diff --git a/templates/vacations_app/assignedvacations_form.html b/templates/vacations_app/assignedvacations_form.html new file mode 100644 index 0000000..0c89646 --- /dev/null +++ b/templates/vacations_app/assignedvacations_form.html @@ -0,0 +1,55 @@ +{% extends 'vacations_app/base.html' %} +{% load bootstrap4 %} +{% load widget_tweaks %} + +{% block content %} +

Employee Assigned Vacation

+
+
+
+ {% csrf_token %} + + {% for hidden_field in form.hidden_fields %} + {{ hidden_field }} + {% endfor %} + + {% if form.non_field_errors %} + + {% endif %} + + {% for field in form.visible_fields %} +
+ {{ field.label_tag }} + {% if form.is_bound %} + {% if field.errors %} + {% render_field field class="form-control is-invalid" %} + {% for error in field.errors %} +
+ {{ error }} +
+ {% endfor %} + {% else %} + {% render_field field class="form-control is-valid" %} + {% endif %} + {% else %} + {% render_field field class="form-control" %} + {% endif %} + + {% if field.help_text %} + {{ field.help_text }} + {% endif %} +
+ {% endfor %} + +
+
+
+{% endblock content %} +{% block scripts %} + {{ block.super }} + {{form.media }} +{% endblock scripts %} diff --git a/templates/vacations_app/assignedvacations_list.html b/templates/vacations_app/assignedvacations_list.html new file mode 100644 index 0000000..1ab1344 --- /dev/null +++ b/templates/vacations_app/assignedvacations_list.html @@ -0,0 +1,37 @@ +{% extends 'vacations_app/base.html' %} +{% load static %} +{% block head %} + {{block.super}} + +{% endblock head %} +{% block content %} + +{% if user.is_authenticated %} +

Employees Assigned Vacations

+ + + + + + + + + + {% for assigned_vacation in object_list %} + + + + + + + + + {% endfor %} +
EmployeeWorked YearTotal DaysActions
{{ assigned_vacation.employee.first_name }} {{ assigned_vacation.employee.last_name }} {{ assigned_vacation.worked_year }}{{ assigned_vacation.total_days }} + Update + Delete +
+ Create Assigned Vacations + {% else %} +{% endif %} +{% endblock content %} diff --git a/templates/vacations_app/index.html b/templates/vacations_app/index.html index afb53b0..d2453c1 100644 --- a/templates/vacations_app/index.html +++ b/templates/vacations_app/index.html @@ -43,6 +43,7 @@

Employee

Admin Request vacation View vacations requests View Holidays + View Employees Assigned Vacations {% endif %} {% endif %} {% endblock content %} diff --git a/vacations_app/urls.py b/vacations_app/urls.py index b7674f8..52769e9 100644 --- a/vacations_app/urls.py +++ b/vacations_app/urls.py @@ -15,6 +15,10 @@ """ from django.conf.urls import url from .views import ( + AssignedVacationCreateView, + AssignedVacationDeleteView, + AssignedVacationsList, + AssignedVacationUpdateView, HolidayCreateView, HolidayUpdateView, HolidayDeleteView, @@ -34,6 +38,10 @@ url(r'^vacation/admin-request$', AdminVacationRequest.as_view(), name='vacation-admin-request'), url(r'^vacations$', VacationList.as_view(), name='vacations-list'), url(r'^vacations/team$', TeamVacationsList.as_view(), name='vacations-team'), + url(r'^assigned_vacations$', AssignedVacationsList.as_view(), name='assigned-vacations-list'), + url(r'^assigned_vacations/create$', AssignedVacationCreateView.as_view(), name='assigned-vacations-create'), + url(r'^assigned_vacations/update/(?P[0-9]+)/$', AssignedVacationUpdateView.as_view(), name='assigned-vacations-update'), + url(r'^assigned_vacations/delete/(?P[0-9]+)/$', AssignedVacationDeleteView.as_view(), name='assigned-vacations-delete'), url(r'^holidays$', HolidayList.as_view(), name='holidays-list'), url(r'^holidays/create$', HolidayCreateView.as_view(), name='holidays-create'), url(r'^holidays/update/(?P[0-9]+)/$', HolidayUpdateView.as_view(), name='holidays-update'), diff --git a/vacations_app/views.py b/vacations_app/views.py index 625cef2..c6c1809 100644 --- a/vacations_app/views.py +++ b/vacations_app/views.py @@ -23,6 +23,7 @@ CAN_VIEW_TEAM_MEMBERS_VACATIONS, ) from vacations_app.models import ( + AssignedVacations, Holiday, Vacation, validate_from_date, @@ -184,3 +185,28 @@ def get_form(self): widget=DatePickerInput(), ) return form + + +class AssignedVacationsList(PermissionRequiredMixin, ListView): + permission_required = CAN_VIEW_OTHER_VACATIONS + model = AssignedVacations + + +class AssignedVacationCreateView(PermissionRequiredMixin, CreateView): + permission_required = CAN_VIEW_OTHER_VACATIONS + model = AssignedVacations + fields = '__all__' + success_url = reverse_lazy('assigned-vacations-list') + + +class AssignedVacationUpdateView(PermissionRequiredMixin, UpdateView): + permission_required = CAN_VIEW_OTHER_VACATIONS + model = AssignedVacations + fields = '__all__' + success_url = reverse_lazy('assigned-vacations-list') + + +class AssignedVacationDeleteView(PermissionRequiredMixin, DeleteView): + permission_required = CAN_VIEW_OTHER_VACATIONS + model = AssignedVacations + success_url = reverse_lazy('assigned-vacations-list')