vkk.workhours.accounting.departments.views
1from django.template import loader 2from django.http import HttpResponse 3from django.views.generic import FormView 4from vkk.workhours.accounting.mixins import AccountantRequiredMixin 5from .forms import EvaluationForm 6 7 8class EvaluationView(AccountantRequiredMixin, FormView): 9 template_name = 'vkk/workhours/accounting/department/evaluation.html' 10 form_class = EvaluationForm 11 12 def get_context_data(self, **kwargs): 13 context = super().get_context_data(**kwargs) 14 context["projects"] = {} 15 return context 16 17 def form_valid(self, form): 18 response = HttpResponse( 19 content_type='text/csv', 20 headers={ 21 'Content-Disposition': 'attachment; filename="12345.csv"'}, 22 ) 23 response.write( 24 loader \ 25 .get_template('vkk/workhours/accounting/department/evaluation.csv') \ 26 .render( 27 context=self.get_context_data(), 28 request=self.request 29 ) 30 ) 31 return response
class
EvaluationView(vkk.workhours.accounting.mixins.AccountantRequiredMixin, django.views.generic.edit.FormView):
9class EvaluationView(AccountantRequiredMixin, FormView): 10 template_name = 'vkk/workhours/accounting/department/evaluation.html' 11 form_class = EvaluationForm 12 13 def get_context_data(self, **kwargs): 14 context = super().get_context_data(**kwargs) 15 context["projects"] = {} 16 return context 17 18 def form_valid(self, form): 19 response = HttpResponse( 20 content_type='text/csv', 21 headers={ 22 'Content-Disposition': 'attachment; filename="12345.csv"'}, 23 ) 24 response.write( 25 loader \ 26 .get_template('vkk/workhours/accounting/department/evaluation.csv') \ 27 .render( 28 context=self.get_context_data(), 29 request=self.request 30 ) 31 ) 32 return response
Verify that the current user has accountant rights.
def
get_context_data(self, **kwargs):
13 def get_context_data(self, **kwargs): 14 context = super().get_context_data(**kwargs) 15 context["projects"] = {} 16 return context
Insert the form into the context dict.
def
form_valid(self, form):
18 def form_valid(self, form): 19 response = HttpResponse( 20 content_type='text/csv', 21 headers={ 22 'Content-Disposition': 'attachment; filename="12345.csv"'}, 23 ) 24 response.write( 25 loader \ 26 .get_template('vkk/workhours/accounting/department/evaluation.csv') \ 27 .render( 28 context=self.get_context_data(), 29 request=self.request 30 ) 31 ) 32 return response
If the form is valid, redirect to the supplied URL.
Inherited Members
- django.views.generic.base.View
- View
- view_is_async
- as_view
- setup
- http_method_not_allowed
- options
- django.contrib.auth.mixins.AccessMixin
- get_login_url
- get_permission_denied_message
- get_redirect_field_name
- handle_no_permission
- django.views.generic.base.TemplateResponseMixin
- render_to_response
- get_template_names
- django.views.generic.edit.FormMixin
- get_initial
- get_prefix
- get_form_class
- get_form
- get_form_kwargs
- get_success_url
- form_invalid
- django.views.generic.edit.ProcessFormView
- get
- post
- put