Repository: LibraryOfCongress/concordia

Issue:
Improve Contact Us form
Based on the first 24 hours of user emails, we should implement some usability improvements to contact us page to improve the public and community manager experience of creating and understanding emails.

As a community manager, I want to have crowdsourcing automatically indicated in the subject line when I respond to users' emails.
* [x] Change subject line generated by contact us form to “Contact crowd.loc.gov: [subject]” (currently is "Contact us: [subject]")

As a community manager, I want every user email to have a subject line, user email address, and content.
* [x] Make ~~email address~~, subject, and ~~body~~ required fields.
* [x] Indicate to users which fields are required

As a user, I want to understand when I have submitted an email via the contact us form.
* [x] Change “save” button to “send” or "send message"

As a user I want clearer form instructions
* [ ] Add help text for fields


Discussion:
As a community manager, I want to make sure I can view replies
- Automatically populate replies with cc: crowd at loc dot gov

As a user I want to understand what kind of response I can expect
Provide an automatic reply that indicates expected time to receive a response, like how many days, where else to find help or resources in the meantime, HH, etc

“Change field text to instructions rather than just field name” — this really should be adding help text in addition to the field name. You can see the `help_text` usage on other fields in https://github.com/LibraryOfCongress/concordia/blob/master/concordia/forms.py
`Automatically populate replies with cc: crowd at loc dot gov` — aren't all replies being sent with that as the from address, as was the case with the test message I sent? 
Re: automatic replies, we have a generic message to the user telling them that their message has been sent. What kind of response time are we comfortably promising?

Resolving patch:
diff --git a/concordia/forms.py b/concordia/forms.py
--- a/concordia/forms.py
+++ b/concordia/forms.py
@@ -44,7 +44,7 @@ class ContactUsForm(forms.Form):
     )
 
     email = forms.EmailField(label="Your email:", required=True)
-    subject = forms.CharField(label="Subject:", required=False)
+    subject = forms.CharField(label="Subject:", required=True)
 
     link = forms.URLField(
         label="Have a specific page you need help with? Add the link below:",
diff --git a/concordia/settings_template.py b/concordia/settings_template.py
--- a/concordia/settings_template.py
+++ b/concordia/settings_template.py
@@ -281,6 +281,9 @@
 ROBOTS_USE_SITEMAP = False
 ROBOTS_USE_HOST = False
 
+# django-bootstrap4 customization:
+BOOTSTRAP4 = {"required_css_class": "form-group-required"}
+
 # Transcription-related settings
 
 #: Number of seconds an asset reservation is valid for
diff --git a/concordia/views.py b/concordia/views.py
--- a/concordia/views.py
+++ b/concordia/views.py
@@ -718,9 +718,16 @@ def form_valid(self, form):
         html_template = loader.get_template("emails/contact_us_email.html")
         html_message = html_template.render(form.cleaned_data)
 
+        confirmation_template = loader.get_template(
+            "emails/contact_us_confirmation_email.txt"
+        )
+        confirmation_message = confirmation_template.render(form.cleaned_data)
+
         try:
             send_mail(
-                "Contact Us: %(subject)s" % form.cleaned_data,
+                "Contact {}: {}".format(
+                    self.request.get_host(), form.cleaned_data["subject"]
+                ),
                 message=text_message,
                 html_message=html_message,
                 from_email=settings.DEFAULT_FROM_EMAIL,
@@ -741,6 +748,24 @@ def form_valid(self, form):
                 "Your message could not be sent. Our support team has been notified.",
             )
 
+        try:
+            send_mail(
+                "Contact {}: {}".format(
+                    self.request.get_host(), form.cleaned_data["subject"]
+                ),
+                message=confirmation_message,
+                from_email=settings.DEFAULT_FROM_EMAIL,
+                recipient_list=[form.cleaned_data['email']],
+            )
+        except SMTPException as exc:
+            logger.error(
+                "Unable to send contact message to %s: %s",
+                form.cleaned_data['email'],
+                exc,
+                exc_info=True,
+                extra={"data": form.cleaned_data},
+            )
+
         return redirect("contact")
 
 


Test patch: