You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
981 B
30 lines
981 B
import logging
|
|
|
|
from django.contrib import messages
|
|
from django.contrib.messages.views import SuccessMessageMixin
|
|
from django.db import transaction
|
|
from django.urls import reverse_lazy
|
|
from django.views.generic import FormView
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from .forms import ContactUsForm
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
# Create your views here.
|
|
class ContactUsFormView(SuccessMessageMixin, FormView):
|
|
template_name = None
|
|
form_class = ContactUsForm
|
|
http_method_names = ['post']
|
|
success_message = _('Request has been sent successfully!')
|
|
error_message = _('Some errors occurred during sending the request. Check the input fields or try latter.')
|
|
|
|
def form_valid(self, form):
|
|
return super().form_valid(form)
|
|
|
|
def form_invalid(self, form):
|
|
context = self.get_context_data()
|
|
if len(form.errors) > 0:
|
|
context['form_show_errors'] = True
|
|
return self.render_to_response(context)
|
|
|