Skip to content

Commit

Permalink
Added karma points below number of questions and solutions on answers…
Browse files Browse the repository at this point in the history
… page. [bug 670170]
  • Loading branch information
rlr committed Jul 11, 2011
1 parent f31b7e0 commit c6651dc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apps/questions/models.py
@@ -1,18 +1,18 @@
from datetime import datetime, timedelta
import re
import random
import string

from django.db import models
from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django.contrib.contenttypes import generic

from product_details import product_details
from redis.exceptions import ConnectionError
from taggit.models import Tag

from activity.models import ActionMixin
from flagit.models import FlaggedObject
from karma.actions import KarmaManager
import questions as constants
from questions.question_config import products
from questions.tasks import (update_question_votes, update_answer_pages,
Expand Down Expand Up @@ -328,6 +328,13 @@ def creator_num_solutions(self):
solution__in=Answer.objects.filter(
creator=self.creator)).count()

@property
def creator_num_points(self):
try:
return KarmaManager().total_points(self.creator)
except ConnectionError:
return None

@property
def num_helpful_votes(self):
"""Get the number of helpful votes for this answer."""
Expand Down Expand Up @@ -402,7 +409,7 @@ def _tenths_version(full_version):

def _has_beta(version, dev_releases):
"""Returns True if the version has a beta release.
For example, if:
dev_releases={...u'4.0rc2': u'2011-03-18',
u'5.0b1': u'2011-05-20',
Expand Down
7 changes: 7 additions & 0 deletions apps/questions/templates/questions/includes/answer.html
Expand Up @@ -15,6 +15,13 @@
{% if question.creator != answer.creator %}
<span class="solutions">{{ _('{num} solutions')|f(num=answer.creator_num_solutions) }}</span>
<span class="answers">{{ _('{num} answers')|f(num=answer.creator_num_answers) }}</span>
{% if waffle.switch('karma') and waffle.flag('karma') %}
{% with pts = answer.creator_num_points %}
{% if pts != None %}
<span class="points">{{ pts }}</span>
{% endif %}
{% endwith %}
{% endif %}
{% endif %}
</div>
<div class="asked-on">
Expand Down
5 changes: 5 additions & 0 deletions media/css/questions.css
Expand Up @@ -420,6 +420,11 @@ div.user-section div.asked-by span.answers {
font-weight: normal;
}

div.user-section div.asked-by span.points {
color: green;
font-size: 110%;
}

div.user-section div.asked-on {
margin: 4px 0 0;
}
Expand Down

0 comments on commit c6651dc

Please sign in to comment.