Skip to content

Commit

Permalink
add validation for bing-yahoo sitemap
Browse files Browse the repository at this point in the history
Add button for congrats or demand response answers
create template for ranking twitter button
  • Loading branch information
damian-garrido committed Nov 11, 2013
1 parent 64fb42c commit 9a1b4ca
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
1 change: 1 addition & 0 deletions elections/templates/base.html
Expand Up @@ -12,6 +12,7 @@
<meta name="keywords" content="{{ 'keywords'|metadata }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msvalidate.01" content="C6FA1DD2E40865EF714B163F36CBEB92">

<!--for facebook fans-->
<meta property="og:title" content="{{ 'title'|ogpdata }}">
Expand Down
9 changes: 7 additions & 2 deletions elections/templates/elections/ranking_candidates.html
@@ -1,5 +1,6 @@
{% extends "elections/election_base.html" %}
{% load i18n %}
{% load votainteligente_extras %}

{% block title %} - {{election}} - {% trans "Ranking"%}{% endblock title%}

Expand Down Expand Up @@ -44,7 +45,9 @@ <h4>
<p><span>{% trans "Ha respondido" %} <strong>{{bueno.actual_answers}} de {{bueno.possible_answers}}</strong> {% trans "preguntas" %} </span><!-- con {{bueno.points }}--></p>
</td>
<td>
<div class="bt-twitter"><i class="icon-twitter"></i> Felicitalo(a)</div>
{% with candidate=bueno.candidate %}
{% twitter_on_ranking "Felicítalo/a" "Gracias por contestar nuestras inquietudes" %}
{% endwith %}
</td>
</tr>
{% endfor %}
Expand All @@ -71,7 +74,9 @@ <h4>
<p><span>{% trans "Ha respondido" %} <strong>{{malo.actual_answers}} de {{malo.possible_answers}}</strong> {% trans "preguntas" %} </span><!-- con {{malo.points }}--></p>
</td>
<td>
<div class="bt-twitter"><i class="icon-twitter"></i> Exígele</div>
{% with candidate=malo.candidate %}
{% twitter_on_ranking "Exígele" "Contesta nuestras inquietudes" %}
{% endwith %}
</td>
</tr>
{% endfor %}
Expand Down
5 changes: 5 additions & 0 deletions elections/templates/elections/twitter/ranking_twitter.html
@@ -0,0 +1,5 @@
{% load i18n %}{% if twitter %}
<div class="btn btn-default" onclick="window.open('https://twitter.com/share?text={{popup_text}}%20@{{twitter}}&hashtags=ranking,votainteligente','{% trans 'Ventana twitter' %}','width=500,height=280')">
<i class="icon-twitter"></i> {{btn_text}}
</div>
{% else %}{% endif %}
18 changes: 18 additions & 0 deletions elections/templatetags/votainteligente_extras.py
Expand Up @@ -106,3 +106,21 @@ def website_imgur(value):
if value in settings.WEBSITE_IMGUR:
return settings.WEBSITE_IMGUR[value]
return ''

def twitter_on_ranking(context,btn_text,popup_text):
twitter = context["candidate"].relation.twitter
if twitter:
return {
'twitter':twitter,
'candidate':context['candidate'],
'btn_text' : btn_text,
'popup_text' : popup_text
}
return {
'twitter':None,
'candidate':context['candidate'],
'btn_text' : btn_text,
'popup_text' : popup_text
}

register.inclusion_tag('elections/twitter/ranking_twitter.html', takes_context=True)(twitter_on_ranking)
22 changes: 21 additions & 1 deletion elections/tests/candideitorg_popit_tests.py
Expand Up @@ -138,7 +138,27 @@ def test_follow_the_conversation_in_twitter(self):
actual_twitter_button = actual_twitter_button_template.render(Context({"candidate":self.candidato1}))
self.assertEquals(actual_twitter_button, expected_twitter_button)


def test_ranking_twitter_button(self):
link = Link.objects.create(url = 'http://twitter.com/candidato1_twitter',\
name = 'twitter',\
candidate = self.candidato1,\
remote_id = 1,\
resource_uri = 'string')
candidate_person, created = CandidatePerson.objects.get_or_create(
person=self.pedro,
candidate=self.candidato1
)
template_str = get_template('elections/twitter/ranking_twitter.html')
context = Context({
"twitter":"candidato1_twitter",
"candidate":self.candidato1,
'btn_text' : 'message button',
'popup_text' : 'message twitter window'
})
expected_twitter_button = template_str.render(context)
actual_twitter_button_template = Template("{% load votainteligente_extras %}{% twitter_on_ranking 'message button' 'message twitter window' %}")
actual_twitter_button = actual_twitter_button_template.render(Context({"candidate":self.candidato1}))
self.assertEquals(actual_twitter_button, expected_twitter_button)

def test_unicode(self):
candidate_person, created = CandidatePerson.objects.get_or_create(
Expand Down

0 comments on commit 9a1b4ca

Please sign in to comment.