Removes the generation of the count badge from a templatetag into the template

- Legacy-Id: 10531
This commit is contained in:
Robert Sparks 2015-12-02 15:45:40 +00:00
parent 2a63f91d31
commit 5de9343359
3 changed files with 16 additions and 14 deletions

View file

@ -30,14 +30,9 @@ def is_chair_or_advisor(user, year):
def has_publickey(nomcom):
return nomcom and nomcom.public_key and True or False
@register.simple_tag
def add_num_nominations(counts, position, nominee):
count = counts.get((position.id,nominee.id),0)
if count:
return '<span class="badge" title="%s earlier comments from you on %s as %s">%s</span>&nbsp;' % (count , nominee.email.address, position, count)
else:
return '<span class="badge" title="You have not yet provided feedback on %s as %s">no feedback</span>&nbsp;' % (nominee.email.address, position)
@register.filter
def lookup(container,key):
return container and container.get(key,None)
@register.filter
def formatted_email(address):

View file

@ -392,8 +392,10 @@ def feedback(request, year, public):
user_comments = Feedback.objects.filter(nomcom=nomcom,
type='comment',
author__in=request.user.person.email_set.filter(active='True'))
counts = Counter(user_comments.values_list('positions','nominees'))
counter = Counter(user_comments.values_list('positions','nominees'))
counts = dict()
for pos,nom in counter:
counts.setdefault(pos,dict())[nom] = counter[(pos,nom)]
if public:
base_template = "nomcom/nomcom_public_base.html"
else:

View file

@ -44,7 +44,12 @@
{% for np in p.nomineeposition_set.accepted.not_duplicated %}
<a class="btn btn-default btn-xs" {% if nomcom.group.state_id != 'conclude' %}href="?nominee={{np.nominee.id}}&position={{ np.position.id}}"{% endif %}>
{{ np.nominee.name }}
{% add_num_nominations counts np.position np.nominee %}
{% with count=counts|lookup:np.position.id|lookup:np.nominee.id %}
<span class="badge"
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}}">
{{ count | default:"no feedback" }}
</span>&nbsp;
{% endwith %}
</a>
{% endfor %}
</div>
@ -54,9 +59,9 @@
<p>
An number after a name indicates
that you have given comments on this nominee
earlier. If you position the mouse pointer over
it, you should see how many comments
exist from you for this nominee.
earlier. Position the mouse pointer over
the badge, for more information about this
nominee.
</p>
</div>