generated from westfarn/web_django_template
Add customer accounts, shipment tracking, and purchase reviews.
CI / test (pull_request) Successful in 35s
CI / test (pull_request) Successful in 35s
Shoppers can register, save shipping details, and view order history while cards stay on Stripe. EasyPost tracker updates (including numbers from Pirate Ship) and 1–5 star reviews are limited to buyers. The contact form now only asks for email and a message.
This commit is contained in:
@@ -11,88 +11,9 @@ class ContactForm(forms.Form):
|
||||
("other", "Something else"),
|
||||
]
|
||||
|
||||
first_name = forms.CharField(
|
||||
max_length=100,
|
||||
widget=forms.TextInput(attrs={"class": "form-input", "id": "contact-first-name"}),
|
||||
)
|
||||
last_name = forms.CharField(
|
||||
max_length=100,
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={"class": "form-input", "id": "contact-last-name"}),
|
||||
)
|
||||
email = forms.EmailField(
|
||||
widget=forms.EmailInput(attrs={"class": "form-input", "id": "contact-email"}),
|
||||
)
|
||||
phone = forms.CharField(
|
||||
max_length=32,
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={"class": "form-input", "id": "contact-phone"}),
|
||||
)
|
||||
address_line1 = forms.CharField(
|
||||
max_length=200,
|
||||
required=False,
|
||||
label="Street address",
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-input",
|
||||
"id": "contact-address-line1",
|
||||
"autocomplete": "off",
|
||||
"data-ac": "line1",
|
||||
}
|
||||
),
|
||||
)
|
||||
address_line2 = forms.CharField(
|
||||
max_length=200,
|
||||
required=False,
|
||||
label="Apt / suite",
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-input",
|
||||
"id": "contact-address-line2",
|
||||
"autocomplete": "address-line2",
|
||||
"data-ac": "line2",
|
||||
}
|
||||
),
|
||||
)
|
||||
address_city = forms.CharField(
|
||||
max_length=100,
|
||||
required=False,
|
||||
label="City",
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-input",
|
||||
"id": "contact-address-city",
|
||||
"autocomplete": "address-level2",
|
||||
"data-ac": "city",
|
||||
}
|
||||
),
|
||||
)
|
||||
address_state = forms.CharField(
|
||||
max_length=32,
|
||||
required=False,
|
||||
label="State",
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-input",
|
||||
"id": "contact-address-state",
|
||||
"autocomplete": "address-level1",
|
||||
"data-ac": "state",
|
||||
}
|
||||
),
|
||||
)
|
||||
address_zip = forms.CharField(
|
||||
max_length=20,
|
||||
required=False,
|
||||
label="ZIP",
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-input",
|
||||
"id": "contact-address-zip",
|
||||
"autocomplete": "postal-code",
|
||||
"data-ac": "zip",
|
||||
}
|
||||
),
|
||||
)
|
||||
interest = forms.ChoiceField(
|
||||
choices=INTEREST_CHOICES,
|
||||
widget=forms.Select(attrs={"class": "form-input", "id": "contact-interest"}),
|
||||
|
||||
@@ -17,6 +17,9 @@ class UnderConstructionMiddleware:
|
||||
"/admin/",
|
||||
"/accounts/login",
|
||||
"/accounts/logout",
|
||||
"/account/login",
|
||||
"/account/logout",
|
||||
"/account/register",
|
||||
"/under-construction",
|
||||
"/portal/messaging/webhooks/",
|
||||
"/unsubscribe/",
|
||||
|
||||
@@ -26,8 +26,6 @@ def notify_admins_of_contact_form(lead: Lead) -> bool:
|
||||
return False
|
||||
|
||||
contact = lead.contact
|
||||
name = contact.full_name or "(no name)"
|
||||
phone = contact.phone or "(none)"
|
||||
email = contact.email or "(none)"
|
||||
message = (lead.message or "").strip() or "(no message)"
|
||||
|
||||
@@ -35,27 +33,8 @@ def notify_admins_of_contact_form(lead: Lead) -> bool:
|
||||
portal_path = reverse("leads:detail", kwargs={"pk": lead.pk})
|
||||
portal_url = f"{site}{portal_path}" if site else portal_path
|
||||
|
||||
postal = contact.postal_address or {}
|
||||
address_bits = [
|
||||
postal.get("line1") or "",
|
||||
postal.get("line2") or "",
|
||||
", ".join(
|
||||
part
|
||||
for part in [
|
||||
postal.get("city") or "",
|
||||
postal.get("state") or "",
|
||||
postal.get("zip") or "",
|
||||
]
|
||||
if part
|
||||
),
|
||||
]
|
||||
address = "\n".join(bit for bit in address_bits if bit) or "(none)"
|
||||
|
||||
ctx = email_brand_context(
|
||||
name=name,
|
||||
email=email,
|
||||
phone=phone,
|
||||
address=address,
|
||||
message=message,
|
||||
portal_url=portal_url,
|
||||
)
|
||||
@@ -63,7 +42,7 @@ def notify_admins_of_contact_form(lead: Lead) -> bool:
|
||||
html_content = get_template("emails/contact_email.html").render(ctx)
|
||||
|
||||
mail = EmailMultiAlternatives(
|
||||
subject=f"New contact form inquiry from {name}",
|
||||
subject=f"New contact form inquiry from {email}",
|
||||
body=text_content,
|
||||
from_email=settings.DEFAULT_FROM_EMAIL,
|
||||
to=[to_email],
|
||||
|
||||
@@ -6,20 +6,11 @@
|
||||
<p style="margin:0 0 16px;color:#212121;">Hello,</p>
|
||||
<p style="margin:0 0 24px;color:#212121;">A new contact request was submitted on the site.</p>
|
||||
|
||||
<p class="field-label" style="color:#6b7280;font-size:12px;text-transform:uppercase;letter-spacing:0.6px;margin:0 0 4px;">Name</p>
|
||||
<p class="field-value" style="color:#212121;font-size:15px;margin:0 0 16px;"><strong>{{ name }}</strong></p>
|
||||
|
||||
<p class="field-label" style="color:#6b7280;font-size:12px;text-transform:uppercase;letter-spacing:0.6px;margin:0 0 4px;">Email</p>
|
||||
<p class="field-value" style="color:#212121;font-size:15px;margin:0 0 16px;">
|
||||
<a href="mailto:{{ email }}" style="color:#00aeef;text-decoration:none;">{{ email }}</a>
|
||||
</p>
|
||||
|
||||
<p class="field-label" style="color:#6b7280;font-size:12px;text-transform:uppercase;letter-spacing:0.6px;margin:0 0 4px;">Phone</p>
|
||||
<p class="field-value" style="color:#212121;font-size:15px;margin:0 0 16px;">{{ phone }}</p>
|
||||
|
||||
<p class="field-label" style="color:#6b7280;font-size:12px;text-transform:uppercase;letter-spacing:0.6px;margin:0 0 4px;">Address</p>
|
||||
<p class="field-value" style="color:#212121;font-size:15px;margin:0 0 16px;white-space:pre-wrap;">{{ address }}</p>
|
||||
|
||||
<p class="field-label" style="color:#6b7280;font-size:12px;text-transform:uppercase;letter-spacing:0.6px;margin:0 0 4px;">Message</p>
|
||||
<p class="field-value" style="color:#212121;font-size:15px;margin:0 0 16px;white-space:pre-wrap;">{{ message }}</p>
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
New contact form inquiry — {{ brand_name|default:"Print Forge" }}
|
||||
|
||||
Name: {{ name }}
|
||||
Email: {{ email }}
|
||||
Phone: {{ phone }}
|
||||
Address:
|
||||
{{ address }}
|
||||
|
||||
Message:
|
||||
{{ message }}
|
||||
@@ -13,5 +9,5 @@ Message:
|
||||
{% endif %}
|
||||
—
|
||||
{{ brand_name|default:"Print Forge" }}
|
||||
{{ site_url|default:"https://mkdrealtor.com" }}
|
||||
{{ site_url|default:"https://printforgeprints.com" }}
|
||||
{% if brand_tagline %}{{ brand_tagline }}{% endif %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% block title %}Contact {{ SITE_NAME }} · Get in Touch{% endblock %}
|
||||
{% block og_title %}Contact {{ SITE_NAME }} · Get in Touch{% endblock %}
|
||||
{% block twitter_title %}Contact {{ SITE_NAME }} · Get in Touch{% endblock %}
|
||||
@@ -60,74 +59,13 @@
|
||||
<form class="rd-form" method="post" action="{% url 'public:contact' %}">
|
||||
{% csrf_token %}
|
||||
<div class="row row-20 gutter-20">
|
||||
<div class="col-sm-6">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.first_name.id_for_label }}">First name</label>
|
||||
{{ form.first_name }}
|
||||
{{ form.first_name.errors }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.last_name.id_for_label }}">Last name</label>
|
||||
{{ form.last_name }}
|
||||
{{ form.last_name.errors }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.phone.id_for_label }}">Phone</label>
|
||||
{{ form.phone }}
|
||||
{{ form.phone.errors }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="col-12">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.email.id_for_label }}">E-mail</label>
|
||||
{{ form.email }}
|
||||
{{ form.email.errors }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<p class="form-label-outside">Mailing address <span style="font-weight:400;color:#6b7280">(optional)</span></p>
|
||||
</div>
|
||||
<div class="col-12" data-address-autocomplete data-suggest-url="{% url 'address_suggest' %}">
|
||||
<div class="form-wrap address-ac-wrap">
|
||||
<label class="form-label-outside" for="{{ form.address_line1.id_for_label }}">Street address</label>
|
||||
{{ form.address_line1 }}
|
||||
{{ form.address_line1.errors }}
|
||||
</div>
|
||||
<div class="row row-20 gutter-20">
|
||||
<div class="col-sm-6">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.address_line2.id_for_label }}">Apt / suite</label>
|
||||
{{ form.address_line2 }}
|
||||
{{ form.address_line2.errors }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.address_city.id_for_label }}">City</label>
|
||||
{{ form.address_city }}
|
||||
{{ form.address_city.errors }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.address_state.id_for_label }}">State</label>
|
||||
{{ form.address_state }}
|
||||
{{ form.address_state.errors }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.address_zip.id_for_label }}">ZIP</label>
|
||||
{{ form.address_zip }}
|
||||
{{ form.address_zip.errors }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-wrap">
|
||||
<label class="form-label-outside" for="{{ form.interest.id_for_label }}">I am interested in</label>
|
||||
@@ -151,7 +89,7 @@
|
||||
<div class="unit unit-spacing-md form-text">
|
||||
<div class="unit-left"><span class="icon mdi mdi-information-outline"></span></div>
|
||||
<div class="unit-body">
|
||||
<p>By submitting, you agree we may contact you about your inquiry by email and SMS (if you provide a phone number). Unsubscribe anytime.{% if form.captcha %} Protected by reCAPTCHA.{% endif %}</p>
|
||||
<p>By submitting, you agree we may contact you about your inquiry by email. Unsubscribe anytime.{% if form.captcha %} Protected by reCAPTCHA.{% endif %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -165,9 +103,6 @@
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
{% block extra_head %}
|
||||
<link rel="stylesheet" href="{% static 'css/address-autocomplete.css' %}">
|
||||
{% endblock %}
|
||||
{% block tracking_events %}
|
||||
{% if "sent" in request.GET %}
|
||||
<script>
|
||||
@@ -177,6 +112,3 @@
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="{% static 'js/address-autocomplete.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
+3
-26
@@ -60,6 +60,7 @@ def robots_txt(request):
|
||||
"Allow: /",
|
||||
"Disallow: /portal/",
|
||||
"Disallow: /accounts/",
|
||||
"Disallow: /account/",
|
||||
"Disallow: /admin/",
|
||||
"Disallow: /api/",
|
||||
f"Sitemap: {site}/sitemap.xml",
|
||||
@@ -110,48 +111,24 @@ def contact(request):
|
||||
form = ContactForm(request.POST)
|
||||
if form.is_valid():
|
||||
data = form.cleaned_data
|
||||
postal = Contact.make_postal_address(
|
||||
line1=data.get("address_line1") or "",
|
||||
line2=data.get("address_line2") or "",
|
||||
city=data.get("address_city") or "",
|
||||
state=data.get("address_state") or "",
|
||||
zip_code=data.get("address_zip") or "",
|
||||
)
|
||||
submitted_email = data["email"].lower()
|
||||
contact_obj, _created, match_reason = upsert_contact(
|
||||
email=submitted_email,
|
||||
first_name=data["first_name"],
|
||||
last_name=data.get("last_name") or "",
|
||||
phone=data.get("phone") or "",
|
||||
postal_address=postal
|
||||
if Contact.postal_address_has_content(postal)
|
||||
else None,
|
||||
source=Contact.Source.CONTACT_FORM,
|
||||
merge_phone_address=False,
|
||||
)
|
||||
ConsentRecord.objects.update_or_create(
|
||||
contact=contact_obj,
|
||||
channel=Channel.EMAIL,
|
||||
defaults={"opted_in": True, "reason": "contact_form"},
|
||||
)
|
||||
if (data.get("phone") or "").strip():
|
||||
ConsentRecord.objects.update_or_create(
|
||||
contact=contact_obj,
|
||||
channel=Channel.SMS,
|
||||
defaults={"opted_in": True, "reason": "contact_form"},
|
||||
)
|
||||
if Contact.postal_address_has_content(postal):
|
||||
ConsentRecord.objects.get_or_create(
|
||||
contact=contact_obj,
|
||||
channel=Channel.POSTCARD,
|
||||
defaults={"opted_in": True, "reason": "contact_form"},
|
||||
)
|
||||
interest = data.get("interest") or ""
|
||||
interest_label = dict(ContactForm.INTEREST_CHOICES).get(interest, interest)
|
||||
body = data.get("message") or ""
|
||||
if interest_label:
|
||||
body = f"Interest: {interest_label}\n\n{body}".strip()
|
||||
if (
|
||||
match_reason in {"phone", "address"}
|
||||
match_reason
|
||||
and (contact_obj.email or "").lower() != submitted_email
|
||||
):
|
||||
body = (
|
||||
|
||||
Reference in New Issue
Block a user