vkk.workhours.accounting.mailing_list.views
This submodule contains class based views.
1""" 2This submodule contains class based views. 3""" 4 5from smtplib import SMTPException 6from django.urls import reverse_lazy, reverse 7from django.http import HttpResponseRedirect 8from django.views.generic import FormView, TemplateView 9from vkk.workhours.accounting.mixins import AccountantRequiredMixin 10from .forms import MailingListForm 11 12class MailingListView(AccountantRequiredMixin, FormView): 13 """ 14 A class based `View` providing the utilities to send out email to a mailing list. 15 """ 16 form_class = MailingListForm 17 success_url = reverse_lazy('vkk:workhours:accounting:mailing_list:success') 18 template_name = 'vkk/workhours/accounting/mailing_list/form.html' 19 20 def form_valid(self, form): 21 try: 22 form.send_mail() 23 except SMTPException: 24 return HttpResponseRedirect( 25 reverse('vkk:workhours:accounting:mailing_list:failed') 26 ) 27 return super().form_valid(form) 28 29class MailingListSuccessView(AccountantRequiredMixin, TemplateView): 30 """ 31 A class based `View` providing the utilities to indicate the successful delivery 32 of email to a mailing list. 33 """ 34 template_name = 'vkk/workhours/accounting/mailing_list/success.html' 35 36class MailingListFailedView(AccountantRequiredMixin, TemplateView): 37 """ 38 A class based `View` providing the utilities to indicate the failure to 39 send out email to a mailing list. 40 """ 41 template_name = 'vkk/workhours/accounting/mailing_list/failed.html'
class
MailingListView(vkk.workhours.accounting.mixins.AccountantRequiredMixin, django.views.generic.edit.FormView):
13class MailingListView(AccountantRequiredMixin, FormView): 14 """ 15 A class based `View` providing the utilities to send out email to a mailing list. 16 """ 17 form_class = MailingListForm 18 success_url = reverse_lazy('vkk:workhours:accounting:mailing_list:success') 19 template_name = 'vkk/workhours/accounting/mailing_list/form.html' 20 21 def form_valid(self, form): 22 try: 23 form.send_mail() 24 except SMTPException: 25 return HttpResponseRedirect( 26 reverse('vkk:workhours:accounting:mailing_list:failed') 27 ) 28 return super().form_valid(form)
A class based View
providing the utilities to send out email to a mailing list.
form_class =
<class 'vkk.workhours.accounting.mailing_list.forms.MailingListForm'>
def
form_valid(self, form):
21 def form_valid(self, form): 22 try: 23 form.send_mail() 24 except SMTPException: 25 return HttpResponseRedirect( 26 reverse('vkk:workhours:accounting:mailing_list:failed') 27 ) 28 return super().form_valid(form)
If the form is valid, redirect to the supplied URL.
Inherited Members
- django.views.generic.base.View
- View
- http_method_names
- view_is_async
- as_view
- setup
- http_method_not_allowed
- options
- django.contrib.auth.mixins.AccessMixin
- login_url
- permission_denied_message
- raise_exception
- redirect_field_name
- get_login_url
- get_permission_denied_message
- get_redirect_field_name
- handle_no_permission
- django.views.generic.base.TemplateResponseMixin
- template_engine
- response_class
- content_type
- render_to_response
- get_template_names
- django.views.generic.edit.FormMixin
- initial
- prefix
- get_initial
- get_prefix
- get_form_class
- get_form
- get_form_kwargs
- get_success_url
- form_invalid
- get_context_data
- django.views.generic.base.ContextMixin
- extra_context
- django.views.generic.edit.ProcessFormView
- get
- post
- put
class
MailingListSuccessView(vkk.workhours.accounting.mixins.AccountantRequiredMixin, django.views.generic.base.TemplateView):
30class MailingListSuccessView(AccountantRequiredMixin, TemplateView): 31 """ 32 A class based `View` providing the utilities to indicate the successful delivery 33 of email to a mailing list. 34 """ 35 template_name = 'vkk/workhours/accounting/mailing_list/success.html'
A class based View
providing the utilities to indicate the successful delivery
of email to a mailing list.
Inherited Members
- django.views.generic.base.View
- View
- http_method_names
- view_is_async
- as_view
- setup
- http_method_not_allowed
- options
- django.contrib.auth.mixins.AccessMixin
- login_url
- permission_denied_message
- raise_exception
- redirect_field_name
- get_login_url
- get_permission_denied_message
- get_redirect_field_name
- handle_no_permission
- django.views.generic.base.TemplateView
- get
- django.views.generic.base.TemplateResponseMixin
- template_engine
- response_class
- content_type
- render_to_response
- get_template_names
- django.views.generic.base.ContextMixin
- extra_context
- get_context_data
class
MailingListFailedView(vkk.workhours.accounting.mixins.AccountantRequiredMixin, django.views.generic.base.TemplateView):
37class MailingListFailedView(AccountantRequiredMixin, TemplateView): 38 """ 39 A class based `View` providing the utilities to indicate the failure to 40 send out email to a mailing list. 41 """ 42 template_name = 'vkk/workhours/accounting/mailing_list/failed.html'
A class based View
providing the utilities to indicate the failure to
send out email to a mailing list.
Inherited Members
- django.views.generic.base.View
- View
- http_method_names
- view_is_async
- as_view
- setup
- http_method_not_allowed
- options
- django.contrib.auth.mixins.AccessMixin
- login_url
- permission_denied_message
- raise_exception
- redirect_field_name
- get_login_url
- get_permission_denied_message
- get_redirect_field_name
- handle_no_permission
- django.views.generic.base.TemplateView
- get
- django.views.generic.base.TemplateResponseMixin
- template_engine
- response_class
- content_type
- render_to_response
- get_template_names
- django.views.generic.base.ContextMixin
- extra_context
- get_context_data