vkk.workhours.accounting.projects.urls

 1from django.urls import include, path
 2from django.utils.translation import gettext_lazy as _
 3from django.forms import modelform_factory
 4from vkk.workhours.accounting.views import *
 5from vkk.generic.forms import CustomDateInput
 6from vkk.workhours.models import Project
 7
 8model = {'model': Project}
 9fields = {'fields': ['invoice_number', 'name', 'contractor', 'start', 'end']}
10form_class = {'form_class': modelform_factory(
11    **model,
12    fields=['invoice_number', 'name', 'contractor',
13            'department', 'start', 'end'],
14    widgets={'start': CustomDateInput, 'end': CustomDateInput}
15)}
16action_options = {
17    'action_options': {
18        'project:default': _('Details'),
19        'project:export:overview': _('Export'),
20        'delete': _('Delete'),
21    }
22}
23key = {'slug_field': 'invoice_number', 'slug_url_kwarg': 'invoice_number'}
24
25app_name = 'projects'
26urlpatterns = [
27    path(
28        _('create/'),
29        AccountingCreateView.as_view(
30            **model,
31            **form_class,
32        ),
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:invoice_number>/delete/'),
45        AccountingDeleteView.as_view(
46            **model,
47            **key,
48            drop_key='invoice_number',
49        ),
50        name='delete'
51    ),
52    path(
53        _('delete/success/'),
54        AccountingSuccessView.as_view(
55            template_name='vkk/generic/delete_success.html',
56            **model,
57        ),
58        name='delete_success'
59    ),
60    path(
61        '',
62        AccountingFilterView.as_view(
63            **model,
64            **fields,
65            **action_options,
66            keys=key['slug_field'],
67            ordering=['invoice_number'],
68        ),
69        name='default'
70    ),
71    path(_('<int:invoice_number>/project/'),
72         include('vkk.workhours.accounting.projects.project.urls')),
73]