fixes a type error in the feedback form. Starts to simplify construction of the feedback badges.
- Legacy-Id: 10525
This commit is contained in:
parent
121c4d2b2d
commit
f4f67425bf
|
@ -483,7 +483,7 @@ class FeedbackForm(BaseNomcomForm, forms.ModelForm):
|
|||
author = emails and emails[0] or None
|
||||
|
||||
if author:
|
||||
feedback.author = author
|
||||
feedback.author = author.address
|
||||
|
||||
feedback.nomcom = self.nomcom
|
||||
feedback.user = self.user
|
||||
|
|
|
@ -31,19 +31,13 @@ def has_publickey(nomcom):
|
|||
|
||||
|
||||
@register.simple_tag
|
||||
def add_num_nominations(user, position, nominee):
|
||||
author = get_user_email(user)
|
||||
|
||||
count = Feedback.objects.filter(positions__in=[position],
|
||||
nominees__in=[nominee],
|
||||
author=author,
|
||||
type='comment').count()
|
||||
def add_num_nominations(user_comments, position, nominee):
|
||||
count = user_comments.filter(positions=position, nominees=nominee).count()
|
||||
if count:
|
||||
return '<span class="badge" title="%s earlier comments from you on %s as %s">%s</span> ' % (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> ' % (nominee.email.address, position)
|
||||
|
||||
|
||||
@register.filter
|
||||
def formatted_email(address):
|
||||
person = None
|
||||
|
|
|
@ -389,6 +389,12 @@ def feedback(request, year, public):
|
|||
|
||||
positions = Position.objects.get_by_nomcom(nomcom=nomcom).opened()
|
||||
|
||||
user_comments = Feedback.objects.filter(nomcom=nomcom,
|
||||
type='comment',
|
||||
author__in=request.user.person.email_set.filter(active='True'))
|
||||
|
||||
|
||||
|
||||
if public:
|
||||
base_template = "nomcom/nomcom_public_base.html"
|
||||
else:
|
||||
|
@ -401,6 +407,7 @@ def feedback(request, year, public):
|
|||
'nomcom': nomcom,
|
||||
'year': year,
|
||||
'selected': 'feedback',
|
||||
'user_comments' : user_comments,
|
||||
'base_template': base_template
|
||||
})
|
||||
|
||||
|
@ -427,6 +434,7 @@ def feedback(request, year, public):
|
|||
'year': year,
|
||||
'positions': positions,
|
||||
'selected': 'feedback',
|
||||
'user_comments' : user_comments,
|
||||
'base_template': base_template
|
||||
})
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
{% 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 user np.position np.nominee %}
|
||||
{% add_num_nominations user_comments np.position np.nominee %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue