-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vote): converted dashboard share buttons to templatetags
- Loading branch information
1 parent
8bd244c
commit 7003da9
Showing
3 changed files
with
51 additions
and
22 deletions.
There are no files selected for viewing
13 changes: 5 additions & 8 deletions
13
app/org_eleicoes/votepeloclima/candidature/static/js/copy-to-clipboard.js
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
32 changes: 32 additions & 0 deletions
32
app/org_eleicoes/votepeloclima/candidature/templatetags/social_share.py
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django import template | ||
from urllib.parse import urlencode | ||
|
||
register = template.Library() | ||
|
||
@register.simple_tag | ||
def share_url(base_url, slug, platform): | ||
url = f"{base_url}/c/{slug}" | ||
|
||
if platform == 'whatsapp': | ||
text = ("Oi! As eleições estão chegando e o futuro da nossa cidade depende do nosso voto. " | ||
"Compartilho com você uma das candidaturas comprometidas na luta pelo meio ambiente e contra as ameaças climáticas. " | ||
"Conheça as propostas na plataforma *Vote pelo Clima!*") | ||
return f"https://wa.me/?text={urlencode({'text': text})}{url}" | ||
|
||
elif platform == 'twitter': | ||
text = ("O clima mudou. A política precisa mudar. #VotePeloClima é a plataforma que reúne candidaturas de todo o Brasil " | ||
"comprometidas com a pauta climática, eu sou uma delas! Acesse o perfil e conheça as propostas.") | ||
return f"https://twitter.com/intent/tweet?url={url}&{urlencode({'text': text})}" | ||
|
||
elif platform == 'linkedin': | ||
title = "O clima mudou. A política precisa mudar." | ||
summary = ("#VotePeloClima é a plataforma que reúne candidaturas de todo o Brasil comprometidas com a pauta climática, " | ||
"eu sou uma delas! Acesse o perfil e conheça as propostas.") | ||
return f"https://www.linkedin.com/shareArticle?mini=true&url={url}&{urlencode({'title': title, 'summary': summary})}" | ||
|
||
elif platform == 'facebook': | ||
quote = ("O clima mudou. A política precisa mudar. #VotePeloClima é a plataforma que reúne candidaturas de todo o Brasil " | ||
"comprometidas com a pauta climática, eu sou uma delas! Acesse o perfil e conheça as propostas.") | ||
return f"https://www.facebook.com/sharer/sharer.php?u={url}&{urlencode({'quote': quote})}" | ||
|
||
return url |