From b75d0ccb3cf8123088db718463b1a3308f1df5eb Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 26 Apr 2016 19:05:53 +0100 Subject: [PATCH] Remove contact form --- project/common/forms.py | 16 ---------------- project/common/jobs.py | 13 ------------- project/common/tests.py | 33 --------------------------------- project/pages/urls.py | 3 +-- project/pages/views.py | 13 ------------- project/settings.py | 6 ------ requirements.txt | 5 ----- templates/about/index.html | 36 ------------------------------------ 8 files changed, 1 insertion(+), 124 deletions(-) delete mode 100644 project/common/forms.py delete mode 100644 project/common/jobs.py delete mode 100644 project/common/tests.py diff --git a/project/common/forms.py b/project/common/forms.py deleted file mode 100644 index 90c0586..0000000 --- a/project/common/forms.py +++ /dev/null @@ -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' - }) diff --git a/project/common/jobs.py b/project/common/jobs.py deleted file mode 100644 index f40f0ae..0000000 --- a/project/common/jobs.py +++ /dev/null @@ -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) diff --git a/project/common/tests.py b/project/common/tests.py deleted file mode 100644 index 0785cfc..0000000 --- a/project/common/tests.py +++ /dev/null @@ -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) diff --git a/project/pages/urls.py b/project/pages/urls.py index 87c68de..b597e68 100644 --- a/project/pages/urls.py +++ b/project/pages/urls.py @@ -1,8 +1,7 @@ from django.conf.urls import url -from .views import page_view, AboutView +from .views import page_view urlpatterns = [ - url(r'^about/?$', AboutView.as_view(), name='about'), url(r'^(?P.*)', page_view, name='page'), ] diff --git a/project/pages/views.py b/project/pages/views.py index 12c3546..f5ce62a 100644 --- a/project/pages/views.py +++ b/project/pages/views.py @@ -1,10 +1,8 @@ import os.path -from django.views.generic import FormView from django.conf import settings from django.http import HttpResponse, Http404 from django.template.loader import get_template from .utils import get_context, parse_content, get_title_from_markdown, swap_page -from project.common.forms import ContactForm def page_view(request, path): @@ -33,14 +31,3 @@ def page_view(request, path): context['html_title'] = context['page_title'] parsed_content = template.render(context, request) 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 diff --git a/project/settings.py b/project/settings.py index 534286d..4a31832 100644 --- a/project/settings.py +++ b/project/settings.py @@ -88,12 +88,6 @@ STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static', 'build'), ) -JOBS = { - 'send_email': { - 'tasks': ['project.common.jobs.send_email'], - } -} - WORDPRESS_URL = "realorangeone.wordpress.com" # Generate config data diff --git a/requirements.txt b/requirements.txt index 487d175..bf93009 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,14 +3,9 @@ coverage==4.0.3 colorama==0.3.6 Django==1.8.7 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 iso8601==0.1.11 markdown2==2.3.0 -max-django-mail-templated==1.2 PyYAML==3.11 requests==2.9.1 requests-mock==0.7.0 diff --git a/templates/about/index.html b/templates/about/index.html index 932882c..dd5ce6a 100644 --- a/templates/about/index.html +++ b/templates/about/index.html @@ -1,5 +1,4 @@ {% extends 'content_base.html' %} -{% load bootstrap %} {% block pageTitle %}About all the things{% endblock %} {% block content %} @@ -39,39 +38,4 @@ - -
-

Contact Me

-

Send me a message using the form below, please don't spam! Simply click the button below to see the form.

-
-
-
-
- -
-
-
- {% csrf_token %} - {{ form | bootstrap }} -
- {% if sent %} - - {% else %} - - {% endif %} -
-
-
-
-
-
-
-
-
{% endblock %}