1
Fork 0

Remove contact form

This commit is contained in:
Jake Howard 2016-04-26 19:05:53 +01:00
parent 82266c9406
commit b75d0ccb3c
8 changed files with 1 additions and 124 deletions

View file

@ -1,16 +0,0 @@
from django import forms
from django_dbq.models import Job
class ContactForm(forms.Form):
email = forms.CharField(label="Email Address", widget=forms.EmailInput(attrs={'placeholder': 'Email Address'}))
name = forms.CharField(label="Full Name", widget=forms.TextInput(attrs={'placeholder': 'Full Name'}))
message = forms.CharField(label="Message", widget=forms.Textarea(attrs={'placeholder': 'Enter your message here'}))
def send_email(self):
Job.objects.create(name='send_email', workspace={
'context': self.cleaned_data,
'to_email': 'info@theorangeone.net',
'from_email': self.cleaned_data['email'],
'template': 'email/contact_message.html'
})

View file

@ -1,13 +0,0 @@
from mail_templated import send_mail
def send_email(job):
template = job.workspace['template']
context = job.workspace['context'] or {}
to_email = job.workspace['to_email']
from_email = job.workspace['from_email']
if type(to_email) != list:
to_email = [to_email]
send_mail(template, context, from_email, to_email)

View file

@ -1,33 +0,0 @@
from django.test import TestCase
import os.path
from . import jobs
from collections import namedtuple
PATH = os.path.dirname(os.path.abspath(__file__))
MockJob = namedtuple('MockJob', {'workspace': {}})
class WorkerTestCase(TestCase):
def test_email_error(self):
data = {
'name': 'Person',
'email': '123@123.123',
'message': 'Hi there, things.'
}
workspace = {
'template': 'email/contact_message.html',
'from_email': 'me@123.123',
'to_email': data['email'],
'context': data
}
job = MockJob(workspace)
errors = None
try:
jobs.send_email(job)
except Exception as e:
errors = e
self.assertFalse(errors)

View file

@ -1,8 +1,7 @@
from django.conf.urls import url from django.conf.urls import url
from .views import page_view, AboutView from .views import page_view
urlpatterns = [ urlpatterns = [
url(r'^about/?$', AboutView.as_view(), name='about'),
url(r'^(?P<path>.*)', page_view, name='page'), url(r'^(?P<path>.*)', page_view, name='page'),
] ]

View file

@ -1,10 +1,8 @@
import os.path import os.path
from django.views.generic import FormView
from django.conf import settings from django.conf import settings
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from django.template.loader import get_template from django.template.loader import get_template
from .utils import get_context, parse_content, get_title_from_markdown, swap_page from .utils import get_context, parse_content, get_title_from_markdown, swap_page
from project.common.forms import ContactForm
def page_view(request, path): def page_view(request, path):
@ -33,14 +31,3 @@ def page_view(request, path):
context['html_title'] = context['page_title'] context['html_title'] = context['page_title']
parsed_content = template.render(context, request) parsed_content = template.render(context, request)
return HttpResponse(parsed_content) return HttpResponse(parsed_content)
class AboutView(FormView):
template_name = 'about/index.html'
success_url = '/about/?sent'
form_class = ContactForm
def get_context_data(self, **kwargs):
context = dict(super().get_context_data(**kwargs), **get_context('/about'))
context['sent'] = 'sent' not in self.request.GET
return context

View file

@ -88,12 +88,6 @@ STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static', 'build'), os.path.join(BASE_DIR, 'static', 'build'),
) )
JOBS = {
'send_email': {
'tasks': ['project.common.jobs.send_email'],
}
}
WORDPRESS_URL = "realorangeone.wordpress.com" WORDPRESS_URL = "realorangeone.wordpress.com"
# Generate config data # Generate config data

View file

@ -3,14 +3,9 @@ coverage==4.0.3
colorama==0.3.6 colorama==0.3.6
Django==1.8.7 Django==1.8.7
dj-database-url==0.3.0 dj-database-url==0.3.0
django-db-queue==0.0.2
django-bootstrap-form==3.2
django-flat-theme==1.1.3
djangorestframework==3.3.2
flake8==2.5.0 flake8==2.5.0
iso8601==0.1.11 iso8601==0.1.11
markdown2==2.3.0 markdown2==2.3.0
max-django-mail-templated==1.2
PyYAML==3.11 PyYAML==3.11
requests==2.9.1 requests==2.9.1
requests-mock==0.7.0 requests-mock==0.7.0

View file

@ -1,5 +1,4 @@
{% extends 'content_base.html' %} {% extends 'content_base.html' %}
{% load bootstrap %}
{% block pageTitle %}About all the things{% endblock %} {% block pageTitle %}About all the things{% endblock %}
{% block content %} {% block content %}
@ -39,39 +38,4 @@
</div> </div>
</div> </div>
</div> </div>
<div class="container">
<h2>Contact Me</h2>
<p>Send me a message using the form below, please don't spam! Simply click the button below to see the form.</p>
<div class="row">
<div class="col-xs-12">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel {% if sent %}panel-default{% else %}panel-success{% endif %}">
<div class="panel-heading" role="tab" id="heading1">
<h4 class="panel-title" style="font-size: 21px;">
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse1" aria-expanded="false" aria-controls="collapse1">
View Form {% if sent %}<i class="icon ion-ios-arrow-down"></i>{% else %}<i class="icon ion-android-done"></i>{% endif %}
</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading1">
<div class="panel-body">
<form role="form" method="post">
{% csrf_token %}
{{ form | bootstrap }}
<div class="form-group">
{% if sent %}
<button type="submit" class="btn btn-primary">Send</button>
{% else %}
<button type="button" class="btn btn-success">Already Sent</button>
{% endif %}
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %} {% endblock %}