diff --git a/CHANGELOG.md b/CHANGELOG.md index a2243fc..0d8f6aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] + +## [1.3.17] - 2022-07-14 + +### Changed +- Replace contact page with simple contact email link + + ## [1.3.16] - 2022-07-09 ### Added diff --git a/src/accounts/migrations/0002_alter_address_state.py b/src/accounts/migrations/0002_alter_address_state.py new file mode 100644 index 0000000..b89118b --- /dev/null +++ b/src/accounts/migrations/0002_alter_address_state.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.2 on 2022-07-09 14:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='address', + name='state', + field=models.CharField(blank=True, choices=[('AL', 'Alabama'), ('AK', 'Alaska'), ('AS', 'American Samoa'), ('AZ', 'Arizona'), ('AR', 'Arkansas'), ('AA', 'Armed Forces Americas'), ('AE', 'Armed Forces Europe'), ('AP', 'Armed Forces Pacific'), ('CA', 'California'), ('CO', 'Colorado'), ('CT', 'Connecticut'), ('DE', 'Delaware'), ('DC', 'District of Columbia'), ('FM', 'Federated States of Micronesia'), ('FL', 'Florida'), ('GA', 'Georgia'), ('GU', 'Guam'), ('HI', 'Hawaii'), ('ID', 'Idaho'), ('IL', 'Illinois'), ('IN', 'Indiana'), ('IA', 'Iowa'), ('KS', 'Kansas'), ('KY', 'Kentucky'), ('LA', 'Louisiana'), ('ME', 'Maine'), ('MH', 'Marshall Islands'), ('MD', 'Maryland'), ('MA', 'Massachusetts'), ('MI', 'Michigan'), ('MN', 'Minnesota'), ('MS', 'Mississippi'), ('MO', 'Missouri'), ('MT', 'Montana'), ('NE', 'Nebraska'), ('NV', 'Nevada'), ('NH', 'New Hampshire'), ('NJ', 'New Jersey'), ('NM', 'New Mexico'), ('NY', 'New York'), ('NC', 'North Carolina'), ('ND', 'North Dakota'), ('MP', 'Northern Mariana Islands'), ('OH', 'Ohio'), ('OK', 'Oklahoma'), ('OR', 'Oregon'), ('PW', 'Palau'), ('PA', 'Pennsylvania'), ('PR', 'Puerto Rico'), ('RI', 'Rhode Island'), ('SC', 'South Carolina'), ('SD', 'South Dakota'), ('TN', 'Tennessee'), ('TX', 'Texas'), ('UT', 'Utah'), ('VT', 'Vermont'), ('VI', 'Virgin Islands'), ('VA', 'Virginia'), ('WA', 'Washington'), ('WV', 'West Virginia'), ('WI', 'Wisconsin'), ('WY', 'Wyoming')], max_length=2), + ), + ] diff --git a/src/static/styles/main.css b/src/static/styles/main.css index 2da802d..be9d5f3 100644 --- a/src/static/styles/main.css +++ b/src/static/styles/main.css @@ -215,52 +215,6 @@ input[type=submit]:hover, font-weight: bold; } - -/* Contact form - ========================================================================== */ -.contact-form { - display: grid; - grid-template-columns: repeat(2, 1fr); - gap: 0 2rem; -} - -.contact-form p:nth-child(6) { - grid-column: span 2; -} - -.contact-form #id_captcha { - margin-bottom: 1rem; - display: flex; - justify-content: flex-end; -} - -.contact-form div:last-child { - grid-column: 2; -} - -.contact-form label { - display: block; -} - -:is(.contact-form) input, select, textarea { - width: 100%; -} - -@media screen and (max-width: 600px) { - .contact-form { - grid-template-columns: 1fr; - } - .contact-form p:nth-child(6), - .contact-form div:last-child { - grid-column: 1; - } -} - - - - - - figure { margin: 0; padding: 0; diff --git a/src/storefront/forms.py b/src/storefront/forms.py index bf43d34..5a59231 100644 --- a/src/storefront/forms.py +++ b/src/storefront/forms.py @@ -13,8 +13,6 @@ from captcha.fields import CaptchaField from core.models import Order from core import CoffeeGrind, ShippingContainer -from .tasks import contact_form_email - logger = logging.getLogger(__name__) @@ -137,34 +135,3 @@ class OrderCreateForm(forms.ModelForm): class CouponApplyForm(forms.Form): code = forms.CharField(label='Coupon code') - - -class ContactForm(forms.Form): - GOOGLE = 'Google Search' - SHOP = 'The coffee shop' - WOM = 'Word of mouth' - PRODUCT = 'Coffee Bag' - STORE = 'Store' - OTHER = 'Other' - - REFERAL_CHOICES = [ - (GOOGLE, 'Google Search'), - (SHOP, '"Better Living Through Coffee" coffee shop'), - (WOM, 'Friend/Relative'), - (PRODUCT, 'Our Coffee Bag'), - (STORE, 'PT Food Coop/other store'), - (OTHER, 'Other (please describe below)'), - ] - - full_name = forms.CharField() - email_address = forms.EmailField() - referal = forms.ChoiceField( - label='How did you find our website?', - choices=REFERAL_CHOICES - ) - subject = forms.CharField() - message = forms.CharField(widget=forms.Textarea) - captcha = CaptchaField() - - def send_email(self): - contact_form_email.delay(self.cleaned_data) diff --git a/src/storefront/tasks.py b/src/storefront/tasks.py index ba0cdab..7bda8fa 100644 --- a/src/storefront/tasks.py +++ b/src/storefront/tasks.py @@ -6,26 +6,3 @@ from django.core.mail import EmailMessage, send_mail from templated_email import send_templated_mail logger = get_task_logger(__name__) - - -CONTACT_FORM_TEMPLATE = 'storefront/contact_form' - - -@shared_task(name='contact_form_email') -def contact_form_email(formdata): - with open(f'{settings.BASE_DIR.parent}/.blacklist') as blacklist: - if formdata.get('email_address') not in blacklist.read(): - send_templated_mail( - template_name=CONTACT_FORM_TEMPLATE, - from_email=settings.DEFAULT_FROM_EMAIL, - recipient_list=[settings.DEFAULT_CONTACT_EMAIL], - context=formdata - ) - - logger.info( - f"Contact form email sent from {formdata['email_address']}" - ) - else: - logger.warn( - f"{formdata['email_address']} tried to send an email but was on the blacklist" - ) diff --git a/src/storefront/templates/storefront/checkout_address.html b/src/storefront/templates/storefront/checkout_address.html index a618114..0f3e334 100644 --- a/src/storefront/templates/storefront/checkout_address.html +++ b/src/storefront/templates/storefront/checkout_address.html @@ -17,7 +17,7 @@

-

We validate addresses with USPS, if you are having issues please contact us at support@ptcoffee.com or use the contact information found on our contact page.

+

We validate addresses with USPS, if you are having issues please contact us at support@ptcoffee.com.

{% endblock %} diff --git a/src/storefront/templates/storefront/contact_form.html b/src/storefront/templates/storefront/contact_form.html deleted file mode 100644 index b180cca..0000000 --- a/src/storefront/templates/storefront/contact_form.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends "base.html" %} - -{% block head_title %}Contact | {% endblock %} - -{% block content %} -
-

Contact us

-
-
-
-

Problem with your online order or have a question?

-

- Please contact us, we’re happy to help you over the phone
- (360) 385-5856 Mon-Fri between 9:00 am and 5:00 pm Pacific Time. -

-

Or send us a message using the form below and we'll email you back as soon as we can.

-
-
-
- {% csrf_token %} - {{ form.non_field_errors }} -

- {{ form.full_name.errors }} - - {{ form.full_name }} -

-

- {{ form.email_address.errors }} - - {{ form.email_address }} -

-

- {{ form.referal.errors }} - - {{ form.referal }} -

-

- {{ form.subject.errors }} - - {{ form.subject }} -

-

- {{ form.message.errors }} - - {{ form.message }} -

-
- {{ form.captcha.errors }} -

- {{ form.captcha }} -

-

-
-
-
-
-{% endblock %} diff --git a/src/storefront/tests/test_views.py b/src/storefront/tests/test_views.py index 1b29480..dbade8b 100644 --- a/src/storefront/tests/test_views.py +++ b/src/storefront/tests/test_views.py @@ -20,7 +20,7 @@ from storefront.views import ( PaymentDoneView, PaymentCanceledView, CustomerDetailView, CustomerUpdateView, OrderDetailView, CustomerAddressCreateView, CustomerAddressUpdateView, - AboutView, FairTradeView, ReviewListView, ContactFormView, + AboutView, FairTradeView, ReviewListView, ) from storefront.cart import Cart @@ -426,21 +426,3 @@ class ReviewListViewTest(TestCase): response = self.client.get(reverse('storefront:reviews')) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'storefront/reviews.html') - - -class ContactFormViewTest(TestCase): - def setUp(self): - self.client = Client() - - def test_view_url_exists_at_desired_location(self): - response = self.client.get('/contact/') - self.assertEqual(response.status_code, 200) - - def test_view_url_accessible_by_name(self): - response = self.client.get(reverse('storefront:contact')) - self.assertEqual(response.status_code, 200) - - def test_view_uses_correct_template(self): - response = self.client.get(reverse('storefront:contact')) - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'storefront/contact_form.html') diff --git a/src/storefront/urls.py b/src/storefront/urls.py index 534df8b..3c13553 100644 --- a/src/storefront/urls.py +++ b/src/storefront/urls.py @@ -5,7 +5,6 @@ urlpatterns = [ path('about/', views.AboutView.as_view(), name='about'), path('fair-trade/', views.FairTradeView.as_view(), name='fair-trade'), path('reviews/', views.ReviewListView.as_view(), name='reviews'), - path('contact/', views.ContactFormView.as_view(), name='contact'), path('', views.ProductListView.as_view(), name='product-list'), path('products//', include([ diff --git a/src/storefront/views.py b/src/storefront/views.py index 82c0e33..541edc7 100644 --- a/src/storefront/views.py +++ b/src/storefront/views.py @@ -36,7 +36,7 @@ from core import OrderStatus, ShippingContainer from .forms import ( AddToCartForm, UpdateCartItemForm, OrderCreateForm, - AddressForm, CouponApplyForm, ContactForm, CheckoutShippingForm, + AddressForm, CouponApplyForm, CheckoutShippingForm, ) from .cart import Cart from .payments import CaptureOrder @@ -491,14 +491,3 @@ class FairTradeView(TemplateView): class ReviewListView(TemplateView): template_name = 'storefront/reviews.html' - - -class ContactFormView(FormView, SuccessMessageMixin): - template_name = 'storefront/contact_form.html' - form_class = ContactForm - success_url = reverse_lazy('storefront:product-list') - success_message = 'Message sent.' - - def form_valid(self, form): - form.send_email() - return super().form_valid(form) diff --git a/src/templates/base.html b/src/templates/base.html index c303547..05f88a8 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -51,7 +51,7 @@
  • Reviews
  • About
  • Cafe
  • -
  • Contact
  • +
  • Contact
  • {% if user.is_authenticated %}