Skip to content

Commit

Permalink
Merge pull request #98 from African-Cities-Lab/fix-home-style
Browse files Browse the repository at this point in the history
fix: Review content
  • Loading branch information
nabilraimi authored Apr 3, 2023
2 parents 72e8a31 + ac3f6e4 commit 6d1bdb0
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 103 deletions.
6 changes: 6 additions & 0 deletions .envs/.local/.django
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
# ------------------------------------------------------------------------------
USE_DOCKER=yes
IPYTHONDIR=/app/.ipython


MAILCHIMP_API_KEY=3f9067355b99a57765606d6255f51e0e-us17
MAILCHIMP_DATA_CENTER=us17
MAILCHIMP_NEWSLETTER_EN_ID=5ae555d5d3
MAILCHIMP_NEWSLETTER_FR_ID=02ddbabc1c
16 changes: 13 additions & 3 deletions african_cities_conference/home/templates/home/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
101 changes: 66 additions & 35 deletions african_cities_conference/home/templates/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ <h5 class="font-weight-500">
{% translate "Hybrid event" %}<span class="text_primary mx-2">|</span>{% translate "May 23-24" %}
</h5>
<h1 class="font-size-3-50em mt-3 mb-4">{% translate "African Cities Lab 2023 SUMMIT" %}</h1>
<div class="xxl-title-font-family xxl-title">{% translate "DATAFRICATION" %}</div>
<div class="h2 font-weight-500 text-center">{% translate "Digital and smart cities" %}</div>
<!--div class="xxl-title-font-family xxl-title">{% translate "DATAFRICATION" %}</div-->
<!--div class="h2 font-weight-500 text-center">{% translate "Digital and smart cities" %}</div-->
<div class="row justify-content-center">
<div class="col-12 col-md-7">
<div class="h1 font-size-2-75em font-weight-500">{% translate "Join the movement to transform African cities" %}</div>
</div>
</div>
<div class="font-size-18 pt-4 pb-5">
<i class="fas fa-map-marker-alt font-size-22 mx-2"></i>{% translate "Sèmè City (Cotonou, Benin)" %} | {% translate "UM6P (Ben Guérir, Morocco)" %} | {% translate "Online" %}
</div>
Expand Down Expand Up @@ -78,7 +83,7 @@ <h1 class="font-size-3-50em mt-3 mb-4">{% translate "African Cities Lab 2023 SUM
<div class="col-12 col-lg-6 font-size-16 pt-md-5">
<h3 class="font-weight-500 pb-3 pt-4">
{% blocktranslate %}
Join a cross-sectoral event to uplift african cities development
Join us for the African Cities Lab 2023 Summit - Digital and Smart Cities: Datafrication
{% endblocktranslate %}
</h3>
<p>
Expand Down Expand Up @@ -315,11 +320,9 @@ <h3 class="section-title mb-3">
professionals and entrepreneurs, will work together to find solutions that make African Cities digital and smart.
{% endblocktranslate %}
</p>
<div class="mt-5">
<div class="mt-5 d-none d-lg-block">
<a class="btn btn__primary btn__small"
href="https://acc2023.africancitieslab.org/en/program/">
{% translate "Go to the program" %}
</a>
href="{% localized_slugurl 'program' %}">{% translate "Go to the program" %}</a>
</div>
</div>
<div class="col-12 col-lg-6 p-5">
Expand Down Expand Up @@ -466,6 +469,12 @@ <h4 class="accordion-header" id="flush-heading11">
</div>
</div>
</div>
<div class="mt-5 d-lg-none text-center">
<a class="btn btn__primary btn__small"
href="{% localized_slugurl 'program' %}">
{% translate "Go to the program" %}
</a>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -559,40 +568,62 @@ <h3 class="section-title text-center">
</div>
</div>
</section>
{% comment %}
<section class="py-5" style="background-image: url({% static "images/assets/banner-pattern.png" %})">
<div class="container-xl py-3">
<div class="row justify-content-between align-items-center text-white">
<div class="col-12 col-md-4">
<h3 class="section-title mb-2">
{% translate "Get notified about event" %}
</h3>
<div>
{% blocktranslate %}
<section id="newsletter"
class="py-5"
style="background-image: url({% static "images/assets/banner-pattern.png" %});
background-size: cover">
<div class="container-xl py-3">
<div class="row justify-content-between align-items-center text-white">
<div class="col-12 col-md-4">
<h3 class="section-title mb-2">
{% translate "Let's keep in touch" %}
</h3>
<div>
{% blocktranslate %}
Register to our newsletter to be first to hear about speakers annoucements, program release, special events, and much more!
{% endblocktranslate %}
</div>
</div>
<div class="col-12 col-md-7">
<form method="post" action="">
{% csrf_token %}
<div class="row">
<div class="col-12 col-lg-5 mt-3">
<input type="text" name="NAME" class="form-control" placeholder="{% translate 'Your First and Last Name' %}" required>
</div>
<div class="col-12 col-lg-5 mt-3">
<input type="email" name="EMAIL" class="form-control" placeholder="{% translate 'Your email here' %}" required>
</div>
<div class="col-12 col-lg-2 mt-3 text-center">
<button type="submit" class="btn h-100 btn__primary btn__small">{% translate "Register" %}</button>
</div>
</div>
<div class="col-12 col-md-7 ">
<form method="post" action="{% url 'newsletter' %}">
{% csrf_token %}
<div class="row">
<div class="col-12 col-lg-5 mt-3">
<input type="text"
name="NAME"
class="form-control"
placeholder="{% translate "Your First and Last Name" %}"
required/>
</div>
</form>
</div>
<div class="col-12 col-lg-5 mt-3">
<input type="email"
name="EMAIL"
class="form-control"
placeholder="{% translate "Your email here" %}"
required/>
</div>
<input name="site_language" type="hidden" value="{{ LANGUAGE_CODE }}" />
<div class="col-12 col-lg-2 mt-3 text-center">
<button type="submit" class="btn h-100 btn__primary btn__small">
{% translate "Register" %}
</button>
</div>
</div>
<!-- message if email is sent -->
{% if messages %}
{% for message in messages %}
<div class="mt-1">
<p class="m-0 text-white font-size-16">
{{ message }}
</p>
</div>
{% endfor %}
{% endif %}
</form>
</div>
</div>
</section>
{% endcomment %}
</div>
</section>
<section class="bg-map"
style="background-image: url({% static "images/assets/bg-map.jpeg" %})">
<div class="container">
Expand Down
3 changes: 3 additions & 0 deletions african_cities_conference/home/urls.py
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"),
]
70 changes: 70 additions & 0 deletions african_cities_conference/home/views.py
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")
7 changes: 7 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,12 @@
},
}

# Mailchimp
# ------------------------------------------------------------------------------
MAILCHIMP_API_KEY = env("MAILCHIMP_API_KEY")
MAILCHIMP_DATA_CENTER = env("MAILCHIMP_DATA_CENTER")
MAILCHIMP_NEWSLETTER_EN_ID = env("MAILCHIMP_NEWSLETTER_EN_ID")
MAILCHIMP_NEWSLETTER_FR_ID = env("MAILCHIMP_NEWSLETTER_FR_ID")

# Your stuff...
# ------------------------------------------------------------------------------
Binary file modified locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 6d1bdb0

Please sign in to comment.