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