Permalink
Browse files

Thing changes

  • Loading branch information...
1 parent 62d8194 commit 3f8309a916932cc4e196f83344cd60dd8374add3 @pydanny committed Feb 11, 2012
Showing with 16 additions and 7 deletions.
  1. +4 −2 project/pitch/models.py
  2. +1 −1 project/pitch/views.py
  3. +11 −4 project/templates/pitch/pitch_detail.html
View
@@ -15,7 +15,7 @@ class PitchManager(models.Manager):
def top_pitches(self):
#FIXME Use correct number of pitches
top_ids = [c['pitch_id'] for c in
- Comment.objects.values("pitch_id").aggregate(agg_votes=Sum("votes")).order_by("-agg_votes")[:10]
+ Comment.objects.values("pitch_id").aggregate(agg_votes=Sum("vote")).order_by("-agg_votes")[:10]
]
pitches = self.filter(id__in=top_ids).in_bulk()
return map(lambda x: pitches[x], top_ids)
@@ -38,6 +38,8 @@ class Pitch(models.Model):
related_pitch_1 = models.TextField(blank=True, null=True)
related_pitch_2 = models.TextField(blank=True, null=True)
related_pitch_3 = models.TextField(blank=True, null=True)
+
+ objects = PitchManager()
def __unicode__(self):
return u'%s' % self.name
@@ -107,7 +109,7 @@ class Comment(models.Model):
objects = CommentManager()
class Meta:
- ordering = ["-pub_date"]
+ ordering = ["-id"]
@receiver(pre_save, sender=Pitch)
View
@@ -9,7 +9,7 @@
from pitch.models import Pitch, Comment
class PitchListView(ListView):
- queryset=Pitch.objects.order_by('-pub_date')
+ queryset=Pitch.objects.top_pitches()
context_object_name='latest_pitch_list'
template_name='pitch/pitch_list.html'
@@ -20,7 +20,7 @@ <h1 class='pitch-name'>{{ pitch.name }}</h1>
<div class="row comments-container">
<div class="span16">
- <h3>Comments</h3>
+ <h3>Comments ({{ pitch.comment_set.count }})</h3>
</div>
</div>
@@ -32,6 +32,9 @@ <h1 class='pitch-name'>{{ pitch.name }}</h1>
{% if comment.vote == 1 %}
<img src="{{ STATIC_URL }}img/pro-60x60.png" />
{% endif %}
+ {% if comment.vote == 0 %}
+ <img src="{{ STATIC_URL }}img/meh-60x60.png" />
+ {% endif %}
{% if comment.vote == -1 %}
<img src="{{ STATIC_URL }}img/con-60x60.png" />
{% endif %}
@@ -57,11 +60,15 @@ <h1 class='pitch-name'>{{ pitch.name }}</h1>
</p>
{% endif %}
+ {% if pitch.related_pitch_1 or pitch.related_pitch_2 or pitch.related_pitch_3 %}
+ <hr />
+ {% endif %}
+
{% if pitch.related_pitch_1 %}
<div class="row ">
<div class="span8">
<h3>Related Concept: {{ pitch.related_pitch_title_1 }}</h3>
- {{ pitch.related_pitch_1|safe }}
+ {{ pitch.related_pitch_1|safe|truncatewords_html:"100" }}
</div>
</div>
{% endif %}
@@ -71,7 +78,7 @@ <h1 class='pitch-name'>{{ pitch.name }}</h1>
<div class="row ">
<div class="span8">
<h3>Related Concept: {{ pitch.related_pitch_title_2 }}</h3>
- {{ pitch.related_pitch_2|safe }}
+ {{ pitch.related_pitch_2|safe|truncatewords_html:"100" }}
</div>
</div>
{% endif %}
@@ -80,7 +87,7 @@ <h1 class='pitch-name'>{{ pitch.name }}</h1>
<div class="row ">
<div class="span8">
<h3>Related Concept: {{ pitch.related_pitch_title_3 }}</h3>
- {{ pitch.related_pitch_3|safe }}
+ {{ pitch.related_pitch_3|safe|truncatewords_html:"100" }}
</div>
</div>
{% endif %}

0 comments on commit 3f8309a

Please sign in to comment.