Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/improve captcha on contact form #6859

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pootle/apps/contact/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_control
from django.views.generic import TemplateView

from contact_form.views import ContactFormView as OriginalContactFormView

from pootle.core.views.mixins import AjaxResponseMixin
from pootle.i18n.gettext import ugettext_lazy as _
from pootle_misc.util import ajax_required
from pootle_store.models import Unit

from .forms import ContactForm, ReportForm
Expand All @@ -27,6 +30,11 @@ class ContactFormView(AjaxResponseMixin, OriginalContactFormView):
form_class = ContactForm
template_name = 'contact_form/xhr_contact_form.html'

@cache_control(max_age=0)
@method_decorator(ajax_required)
def get(self, *args, **kwargs):
return super(ContactFormView, self).get(*args, **kwargs)

def get_context_data(self, **kwargs):
ctx = super(ContactFormView, self).get_context_data(**kwargs)
# Provide the form action URL to use in the template that renders the
Expand Down