-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from African-Cities-Lab/fix-home-style
fix: Review content
- Loading branch information
Showing
9 changed files
with
272 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,7 +151,7 @@ <h4 class="mb-3">{% translate "Visa" %}</h4> | |
</div> | ||
</section> | ||
{% endcomment %} | ||
<section class="py-5"> | ||
<section class="pb-5"> | ||
<div class="row justify-content-center"> | ||
<div class="col-12 col-md-6 offset-md-2 p-5"> | ||
<h3 class="section-title mb-3">{% translate "Contact" %}</h3> | ||
|
@@ -162,8 +162,18 @@ <h3 class="section-title mb-3">{% translate "Contact" %}</h3> | |
{% endblocktranslate %} | ||
</p> | ||
<h6 class="mt-2">{% translate "For any request:" %}</h6> | ||
<a href="mailto:[email protected]" | ||
class="text_primary font-size-16">[email protected]</a> | ||
<div> | ||
<a href="mailto:[email protected]" | ||
class="text_primary font-size-16">[email protected]</a> | ||
</div> | ||
<div class="pt-2"> | ||
<a href="mailto:[email protected]" | ||
class="text_primary font-size-16">[email protected]</a> | ||
</div> | ||
<div class="pt-2"> | ||
<a href="mailto:[email protected]" | ||
class="text_primary font-size-16">[email protected]</a> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
from django.urls import path | ||
from django.views.generic import TemplateView | ||
|
||
from . import views | ||
|
||
urlpatterns = [ | ||
path( | ||
"venue-contact/", | ||
TemplateView.as_view(template_name="home/contact.html"), | ||
name="contact", | ||
), | ||
path("newsletter/", views.newsletter_submission, name="newsletter"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,71 @@ | ||
# Create your views here. | ||
# from django.shortcuts import render | ||
# from multiprocessing import context | ||
import json | ||
|
||
from django.conf import settings | ||
from django.contrib import messages | ||
from django.shortcuts import render | ||
from django.utils.translation import gettext_lazy as _ | ||
from mailchimp_marketing import Client | ||
from mailchimp_marketing.api_client import ApiClientError | ||
|
||
|
||
def _subscribe(email, list_id, merge_fields=None): | ||
""" | ||
Contains code handling the communication to the mailchimp api | ||
to create a contact/member in an audience/list. | ||
""" | ||
|
||
mailchimp = Client() | ||
mailchimp.set_config( | ||
{ | ||
"api_key": settings.MAILCHIMP_API_KEY, | ||
"server": settings.MAILCHIMP_DATA_CENTER, | ||
} | ||
) | ||
|
||
member_info = { | ||
"email_address": email, | ||
"status": "subscribed", | ||
} | ||
|
||
if merge_fields is not None: | ||
member_info["merge_fields"] = merge_fields | ||
|
||
try: | ||
response = mailchimp.lists.add_list_member(list_id, member_info) | ||
print(f"API call successful: {response}") | ||
return response["status"] | ||
except ApiClientError as error: | ||
print(f"An exception occurred: {error.text}") | ||
if json.loads(error.text)["title"] == "Member Exists": | ||
return "exists" | ||
|
||
|
||
def newsletter_submission(request): | ||
|
||
if request.method == "POST": | ||
email = request.POST["EMAIL"] | ||
merge_fields = { | ||
"FNAME": request.POST["NAME"], | ||
} | ||
|
||
if request.POST["site_language"] == "en": | ||
list_id = settings.MAILCHIMP_NEWSLETTER_EN_ID | ||
else: # "fr" | ||
list_id = settings.MAILCHIMP_NEWSLETTER_FR_ID | ||
|
||
status = _subscribe(email, list_id, merge_fields) | ||
if status == "subscribed": | ||
messages.success( | ||
request, | ||
_("Thank you for subscribing to our newsletter!"), | ||
) # message | ||
elif status == "exists": | ||
messages.info( | ||
request, | ||
_("Your email is already registered!"), | ||
) # message | ||
|
||
return render(request, "home/home.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.