1from django.urls import path
2from django.utils.translation import gettext_lazy as _
3from django.forms import modelform_factory
4from ..views import *
5from .views import AccountingPeriodDetailView, AccountingPeriodDetailDepartmentView
6from vkk.workhours.models import Period
7from vkk.generic.forms import CustomDateInput, CustomDateTimeInput
8
9model = {'model': Period}
10fields = {'fields': ['start', 'end', 'dead_line', 'dead_line_final']}
11form_class = {'form_class': modelform_factory(**model, **fields,
12 widgets={
13 'start': CustomDateInput,
14 'end': CustomDateInput,
15 'dead_line': CustomDateTimeInput,
16 'dead_line_final': CustomDateTimeInput
17 })
18 }
19action_options = {
20 'action_options': {
21 'details': _('Details'),
22 'update': _('Update'),
23 'delete': _('Delete'),
24 }
25}
26
27app_name = 'periods'
28urlpatterns = [
29 path(
30 _('<int:pk>/details/'),
31 AccountingPeriodDetailView.as_view(),
32 name='details'
33 ),
34 path(
35 _('<int:pk>/details/projects_open_by_department/<int:department_pk>'),
36 AccountingPeriodDetailDepartmentView.as_view(),
37 name='projects_open'
38 ),
39 path(
40 _('create/'),
41 AccountingCreateView.as_view(**model, **form_class),
42 name='create'
43 ),
44 path(
45 _('create/success/'),
46 AccountingSuccessView.as_view(
47 template_name='vkk/generic/create_success.html',
48 **model
49 ),
50 name='create_success'
51 ),
52 path(
53 _('<int:pk>/update/'),
54 AccountingUpdateView.as_view(**model, **form_class),
55 name='update'
56 ),
57 path(
58 _('update/success/'),
59 AccountingSuccessView.as_view(
60 template_name='vkk/generic/update_success.html',
61 **model
62 ),
63 name='update_success'
64 ),
65 path(
66 _('<int:pk>/delete/'),
67 AccountingDeleteView.as_view(**model),
68 name='delete'
69 ),
70 path(
71 _('delete/success/'),
72 AccountingSuccessView.as_view(
73 template_name='vkk/generic/delete_success.html',
74 **model
75 ),
76 name='delete_success'
77 ),
78 path(
79 '',
80 AccountingListView.as_view(
81 **model,
82 **fields,
83 ordering=['-start'],
84 **action_options
85 ),
86 name='default'
87 ),
88]