Skip to content

Commit 5de9343

Browse files
committed
Removes the generation of the count badge from a templatetag into the template
- Legacy-Id: 10531
1 parent 2a63f91 commit 5de9343

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

ietf/nomcom/templatetags/nomcom_tags.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,9 @@ def is_chair_or_advisor(user, year):
3030
def has_publickey(nomcom):
3131
return nomcom and nomcom.public_key and True or False
3232

33-
34-
@register.simple_tag
35-
def add_num_nominations(counts, position, nominee):
36-
count = counts.get((position.id,nominee.id),0)
37-
if count:
38-
return '<span class="badge" title="%s earlier comments from you on %s as %s">%s</span>&nbsp;' % (count , nominee.email.address, position, count)
39-
else:
40-
return '<span class="badge" title="You have not yet provided feedback on %s as %s">no feedback</span>&nbsp;' % (nominee.email.address, position)
33+
@register.filter
34+
def lookup(container,key):
35+
return container and container.get(key,None)
4136

4237
@register.filter
4338
def formatted_email(address):

ietf/nomcom/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,10 @@ def feedback(request, year, public):
392392
user_comments = Feedback.objects.filter(nomcom=nomcom,
393393
type='comment',
394394
author__in=request.user.person.email_set.filter(active='True'))
395-
counts = Counter(user_comments.values_list('positions','nominees'))
396-
395+
counter = Counter(user_comments.values_list('positions','nominees'))
396+
counts = dict()
397+
for pos,nom in counter:
398+
counts.setdefault(pos,dict())[nom] = counter[(pos,nom)]
397399
if public:
398400
base_template = "nomcom/nomcom_public_base.html"
399401
else:

ietf/templates/nomcom/feedback.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ <h4>{{ p.name }}</h4>
4444
{% for np in p.nomineeposition_set.accepted.not_duplicated %}
4545
<a class="btn btn-default btn-xs" {% if nomcom.group.state_id != 'conclude' %}href="?nominee={{np.nominee.id}}&position={{ np.position.id}}"{% endif %}>
4646
{{ np.nominee.name }}
47-
{% add_num_nominations counts np.position np.nominee %}
47+
{% with count=counts|lookup:np.position.id|lookup:np.nominee.id %}
48+
<span class="badge"
49+
title="{% if count %}{{count}} earlier comment{{count|pluralize}} from you {% else %}You have not yet provided feedback {% endif %} on {{np.nominee.email.address}} as {{np.position}}">
50+
{{ count | default:"no feedback" }}
51+
</span>&nbsp;
52+
{% endwith %}
4853
</a>
4954
{% endfor %}
5055
</div>
@@ -54,9 +59,9 @@ <h4>{{ p.name }}</h4>
5459
<p>
5560
An number after a name indicates
5661
that you have given comments on this nominee
57-
earlier. If you position the mouse pointer over
58-
it, you should see how many comments
59-
exist from you for this nominee.
62+
earlier. Position the mouse pointer over
63+
the badge, for more information about this
64+
nominee.
6065
</p>
6166
</div>
6267

0 commit comments

Comments
 (0)