Skip to content

Commit

Permalink
add hashtag setting for twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-garrido committed Nov 25, 2013
1 parent a831a50 commit e703575
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion elections/templates/elections/election_base.html
Expand Up @@ -28,7 +28,7 @@
<div class="g-plus" data-action="share" data-annotation="none" data-lang="es-419"></div>
</div>
<div class="col-md-4">
<a href="https://twitter.com/share" class="twitter-share-button" data-lang="es" data-count="none" data-hashtags="votainteligente">Tweet</a>
<a href="https://twitter.com/share" class="twitter-share-button" data-lang="es" data-count="none" data-hashtags="{{ 'hashtags'|website_twitter }}">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<div class="col-md-4">
Expand Down
9 changes: 8 additions & 1 deletion elections/templatetags/votainteligente_extras.py
Expand Up @@ -115,4 +115,11 @@ def twitter_on_ranking(context,btn_text,popup_text):
'popup_text' : popup_text
}

register.inclusion_tag('elections/twitter/ranking_twitter.html', takes_context=True)(twitter_on_ranking)
register.inclusion_tag('elections/twitter/ranking_twitter.html', takes_context=True)(twitter_on_ranking)

@register.filter
#website general settings
def website_twitter(value):
if value in settings.WEBSITE_TWITTER:
return settings.WEBSITE_TWITTER[value]
return ''
11 changes: 10 additions & 1 deletion elections/tests/template_tags_tests.py
Expand Up @@ -37,6 +37,9 @@ def setUp(self):
settings.WEBSITE_IMGUR = {
'client_id' : 'eb18642b5b220484864483b8e21386c3' #example client_id, only works with 50 pic a day
}
settings.WEBSITE_TWITTER = {
'hashtags' : 'votainformado,eslaloslas'
}

def test_bring_all_elections_with_their_tags_as_json(self):
expected_elections = []
Expand Down Expand Up @@ -133,4 +136,10 @@ def test_website_imgur(self):
template = Template("{% load votainteligente_extras %}{{ 'client_id'|website_imgur }}")
context = Context({})

self.assertEqual(template.render(context), u'eb18642b5b220484864483b8e21386c3')
self.assertEqual(template.render(context), u'eb18642b5b220484864483b8e21386c3')

def test_website_twitter(self):
template = Template("{% load votainteligente_extras %}{{ 'hashtags'|website_twitter }}")
context = Context({})

self.assertEqual(template.render(context), u'votainformado,eslaloslas')
5 changes: 4 additions & 1 deletion votainteligente/settings.py
Expand Up @@ -302,7 +302,10 @@
WEBSITE_GENERAL_SETTINGS = {
'home_title' : 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.'
}

#twitter sepparated by comma, eg: votainteligente,votainformado,othertag
WEBSITE_TWITTER = {
'hashtags' : 'votainteligente'
}
USE_POPIT = True
#if you set USE_POPIT to False the USE_WRITEIT param will automatically be interpreted as False
USE_WRITEIT = True
Expand Down

0 comments on commit e703575

Please sign in to comment.