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

Add ability to enable/disable contact form #3686

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions esp/esp/tagdict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,13 @@
'category': 'theme',
'is_setting': False,
},
'contact_form_enabled': {
'is_boolean': True,
'help_text': 'Should the contact form at /contact/contact be enabled?',
'default': False,
'category': 'manage',
'is_setting': True,
},
}

# Any tag used with Tag.getProgramTag()
Expand Down
3 changes: 2 additions & 1 deletion esp/esp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@

# Specific .html pages that have defaults
urlpatterns += [
url(r'^faq', TemplateView.as_view(template_name='faq.html'), name='FAQ'),
url(r'^(faq|faq\.html)$', main.FAQView.as_view(), name='FAQ'),
url(r'^(contact|contact\.html)$', main.ContactUsView.as_view(), name='Contact Us'),
]

urlpatterns += [
Expand Down
20 changes: 13 additions & 7 deletions esp/esp/utils/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
from esp.middleware import ESPError
from esp.themes.controllers import ThemeController
from esp.program.models import Program
from esp.web.views.navBar import makeNavBar
from esp.tagdict.models import Tag
from django.conf import settings
import django.shortcuts

Expand All @@ -59,14 +61,9 @@ def get_from_id(id, module, strtype = 'object', error = True):
return None
return foundobj

def render_to_response(template, request, context, content_type=None, use_request_context=True):
from esp.web.views.navBar import makeNavBar
from esp.tagdict.models import Tag

if isinstance(template, (basestring,)):
template = [ template ]
def esp_context_stuff():
context = {}

section = request.path.split('/')[1]
tc = ThemeController()
context['theme'] = tc.get_template_settings()
context['current_theme_version'] = Tag.getTag("current_theme_version")
Expand All @@ -76,6 +73,15 @@ def render_to_response(template, request, context, content_type=None, use_reques
context['settings'] = settings

context['current_programs'] = Program.current_programs()
return context

def render_to_response(template, request, context, content_type=None, use_request_context=True):
if isinstance(template, (basestring,)):
template = [ template ]

section = request.path.split('/')[1]

context.update(esp_context_stuff())

# create nav bar list
if not 'navbar_list' in context:
Expand Down
26 changes: 15 additions & 11 deletions esp/esp/web/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,31 @@
Phone: 617-379-0178
Email: [email protected]
"""
from esp.qsd.views import qsd
from django.core.exceptions import PermissionDenied
from django.contrib.sites.models import Site
from esp.users.models import ESPUser, Permission
from django.http import Http404, HttpResponseRedirect, HttpResponse
from django.utils.datastructures import MultiValueDict
from django.template import loader
from django.views.generic.base import TemplateView
from esp.middleware.threadlocalrequest import AutoRequestContext as Context

from Cookie import SimpleCookie

import datetime
import re
import json

from esp.dbmail.models import MessageRequest
from esp.web.models import NavBarCategory
from esp.utils.web import render_to_response
from esp.utils.web import render_to_response, esp_context_stuff
from esp.web.views.navBar import makeNavBar
from esp.web.views.archives import archive_handlers
from esp.middleware import ESPError
from esp.web.forms.contact_form import ContactForm
from esp.tagdict.models import Tag
from esp.utils.no_autocookie import disable_csrf_cookie_update
from esp.utils.query_utils import nest_Q

from django.views.decorators.cache import cache_control
from django.core.mail import mail_admins
from django.conf import settings

from django.views.decorators.csrf import csrf_exempt

from pprint import pprint

try:
from cStringIO import StringIO
except ImportError:
Expand Down Expand Up @@ -134,11 +125,24 @@ def archives(request, selection, category = None, options = None):

return render_to_response('users/construction', request, {})

class DefaultQSDView(TemplateView):
def get_context_data(self, **kwargs):
return esp_context_stuff()

class FAQView(DefaultQSDView):
template_name = "faq.html"

class ContactUsView(DefaultQSDView):
template_name = "contact_qsd.html"

def contact(request, section='esp'):
"""
This view should take an email and post to those people.
"""
from esp.dbmail.models import send_mail
# if not set up, immediately redirect
if not Tag.getBooleanTag('contact_form_enabled'):
return HttpResponseRedirect("/contact.html")

if 'success' in request.GET:
return render_to_response('contact_success.html', request, {})
Expand Down
19 changes: 19 additions & 0 deletions esp/templates/contact_qsd.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "main.html" %}

{% block title %}Contact Us{% endblock %}
{% block content_title %}Contact Us{% endblock %}

{% block content %}

{% load render_qsd %}
{% load getTag %}

{% inline_qsd_block "contact" %}

<p>
Before contacting us with a question or concern, please check our <b><a href="/faq.html">FAQ page</a></b>.
If your question is still not answered, please contact us {% if "contact_form_enabled"|getBooleanTag %}via <b><a href="/contact/contact">our contact form</a></b>{% else %} via email at <b><a href="mailto:{{ settings.DEFAULT_EMAIL_ADDRESSES.default }}">{{ settings.DEFAULT_EMAIL_ADDRESSES.default }}</a></b>{% endif %}.
</p>

{% end_inline_qsd_block %}
{% endblock %}
Loading