Skip to content

Commit

Permalink
* adds a tab for contact us page in base.html
Browse files Browse the repository at this point in the history
* sends mail to the user who is submitting the feedback
* mails are now sent to usertype admin also for new feedback submitted
* leaves validation for email as of now
  • Loading branch information
taranjeet committed Nov 14, 2015
1 parent ad337d1 commit e97f807
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
17 changes: 15 additions & 2 deletions wye/profiles/views.py
Expand Up @@ -6,7 +6,7 @@
from django.views.generic.edit import FormView
from django.template import Context, loader

from wye.base.emailer_html import send_email_to_list
from wye.base.emailer_html import send_email_to_list, send_email_to_id
from wye.base.constants import WorkshopStatus
from wye.organisations.models import Organisation
from wye.workshops.models import Workshop
Expand Down Expand Up @@ -122,16 +122,29 @@ def form_valid(self, form):
'email_messages/contactus/message.txt').render(email_context)
email_body = loader.get_template(
'email_messages/contactus/message.html').render(email_context)
user_subject = '[PythonExpress] Feedback Received'
user_text_body = loader.get_template(
'email_messages/contactus/message_user.txt').render(email_context)
user_email_body = loader.get_template(
'email_messages/contactus/message_user.html').render(email_context)

try:
regional_lead = models.Profile.objects.filter(
usertype__slug='lead').values_list('user__email', flat=True)
usertype__slug__in=['lead', 'admin']).values_list('user__email', flat=True)
send_email_to_list(
subject,
users_list=regional_lead,
body=email_body,
text_body=text_body)
except Exception as e:
print(e)
try:
send_email_to_id(
user_subject,
body=user_email_body,
email_id=form.cleaned_data['email'],
text_body=user_text_body)
except Exception as e:
print(e)

return super(ContactFormView, self).form_valid(form)
1 change: 1 addition & 0 deletions wye/templates/base.html
Expand Up @@ -36,6 +36,7 @@
{% endif %}
<li><a href="/workshops_info" class="{% if request.resolver_match.url_name == 'workshops_info' %}active{% endif %}">Workshops Info</a></li>
<li><a href="/faq" class="{% if request.resolver_match.url_name == 'faq' %}active{% endif %}">FAQ</a></li>
<li><a href="/contact" class="{% if request.resolver_match.url_name == 'contact' %}active{% endif %}">Contact Us</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% block loginindicator %}
Expand Down
7 changes: 7 additions & 0 deletions wye/templates/email_messages/contactus/message_user.html
@@ -0,0 +1,7 @@
Hey {{contact_name}},

We have received your feedback. Someone from our team will get in touch with you shortly.

May the love of Python spread far and wide!
Warmly,
The PythonExpress Team
7 changes: 7 additions & 0 deletions wye/templates/email_messages/contactus/message_user.txt
@@ -0,0 +1,7 @@
Hey {{contact_name}},

We have received your feedback. Someone from our team will get in touch with you shortly.

May the love of Python spread far and wide!
Warmly,
The PythonExpress Team

0 comments on commit e97f807

Please sign in to comment.