Skip to content

Commit f27f0bf

Browse files
committed
Merge branch 'hotfix-1.2.1b4'
2 parents 6ff3530 + aacb0e8 commit f27f0bf

File tree

10 files changed

+86
-28
lines changed

10 files changed

+86
-28
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,21 @@ The release versions that are sent to the Python package index (PyPI) are also t
107107

108108
The versioning uses a three part version system, "a.b.c" - "a" represents a major release that may not be backwards compatible. "b" is incremented on minor releases that may contain extra features, but are backwards compatible. "c" releases are bug fixes or other micro changes that developers should feel free to immediately update to.
109109

110-
### Version 1.2 Beta 3
110+
### Hotfix 1.2.1 Beta 4
111111

112-
* **tag**: [v1.1b2](https://github.com/DistrictDataLabs/minimum-entropy/releases/tag/v1.2b3)
112+
* **tag**: [v1.2.1b4](https://github.com/DistrictDataLabs/minimum-entropy/releases/tag/v1.2.1b4)
113113
* **deployment**: Monday, July 11, 2016
114114
* **commit**: [see tag](#)
115115

116-
The third beta fixes the tag grid system which got all wonky in the first implementation when actual data was put in. The new style is similar to the Stack Overflow tag grid style. Moreover, now tags are case insensitive, which should help eliminate duplicates. The activity stream was also updated to use templates for a bit more robust control. The "answered" activity now takes the answer as a target rather than as a theme, and answers have detail links to the question that they're on.
116+
A quick hotfix due to a question and answer ordering by vote bug. Also took the chance to add links to the tags in the question list and detail pages as well as to fix the synonym bug (temporarily). Links for the tags are still not rendered after JavaScript editing though.
117+
118+
### Version 1.2 Beta 3
119+
120+
* **tag**: [v1.2b3](https://github.com/DistrictDataLabs/minimum-entropy/releases/tag/v1.2b3)
121+
* **deployment**: Monday, July 11, 2016
122+
* **commit**: [6ff3530](https://github.com/DistrictDataLabs/minimum-entropy/commit/6ff3530eaf6af0584e65577ddeeedc19aced84a5)
123+
124+
The third beta fixes the tag grid system which got all wonky in the first implementation when actual data was put in. The new style is similar to the Stack Overflow tag grid style. Moreover, now tags are case insensitive, which should help eliminate duplicates. The activity stream was also updated to use templates for a bit more robust control. The "answered" activity now takes the answer as a target rather than as a theme, and answers have detail links to the question that they're on.
117125

118126
### Version 1.1 Beta 2
119127

docs/about.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,21 @@ The release versions that are sent to the Python package index (PyPI) are also t
4949

5050
The versioning uses a three part version system, "a.b.c" - "a" represents a major release that may not be backwards compatible. "b" is incremented on minor releases that may contain extra features, but are backwards compatible. "c" releases are bug fixes or other micro changes that developers should feel free to immediately update to.
5151

52-
### Version 1.2 Beta 3
52+
### Hotfix 1.2.1 Beta 4
5353

54-
* **tag**: [v1.1b2](https://github.com/DistrictDataLabs/minimum-entropy/releases/tag/v1.2b3)
54+
* **tag**: [v1.2.1b4](https://github.com/DistrictDataLabs/minimum-entropy/releases/tag/v1.2.1b4)
5555
* **deployment**: Monday, July 11, 2016
5656
* **commit**: [see tag](#)
5757

58-
The third beta fixes the tag grid system which got all wonky in the first implementation when actual data was put in. The new style is similar to the Stack Overflow tag grid style. Moreover, now tags are case insensitive, which should help eliminate duplicates. The activity stream was also updated to use templates for a bit more robust control. The "answered" activity now takes the answer as a target rather than as a theme, and answers have detail links to the question that they're on.
58+
A quick hotfix due to a question and answer ordering by vote bug. Also took the chance to add links to the tags in the question list and detail pages as well as to fix the synonym bug (temporarily). Links for the tags are still not rendered after JavaScript editing though.
59+
60+
### Version 1.2 Beta 3
61+
62+
* **tag**: [v1.2b3](https://github.com/DistrictDataLabs/minimum-entropy/releases/tag/v1.2b3)
63+
* **deployment**: Monday, July 11, 2016
64+
* **commit**: [6ff3530](https://github.com/DistrictDataLabs/minimum-entropy/commit/6ff3530eaf6af0584e65577ddeeedc19aced84a5)
65+
66+
The third beta fixes the tag grid system which got all wonky in the first implementation when actual data was put in. The new style is similar to the Stack Overflow tag grid style. Moreover, now tags are case insensitive, which should help eliminate duplicates. The activity stream was also updated to use templates for a bit more robust control. The "answered" activity now takes the answer as a target rather than as a theme, and answers have detail links to the question that they're on.
5967

6068
### Version 1.1 Beta 2
6169

fugato/managers.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
from django.db import models
2121
from minent.utils import signature, normalize_query
22-
22+
from django.db.models.functions import Coalesce
2323

2424
##########################################################################
25-
## Tag QuerySet
25+
## Question QuerySet
2626
##########################################################################
2727

2828
class QuestionQuerySet(models.query.QuerySet):
@@ -40,7 +40,7 @@ def count_votes(self):
4040
"""
4141
Returns questions annotated with the number of votes they have.
4242
"""
43-
return self.annotate(num_votes=models.Count('votes'))
43+
return self.annotate(num_votes=Coalesce(models.Sum('votes__vote'), 0))
4444

4545
def count_answers(self):
4646
"""
@@ -115,3 +115,39 @@ def get_queryset(self):
115115
Return a QuestionQuerySet instead of the standard queryset.
116116
"""
117117
return QuestionQuerySet(self.model, using=self._db)
118+
119+
120+
##########################################################################
121+
## Answer QuerySet
122+
##########################################################################
123+
124+
class AnswerQuerySet(models.query.QuerySet):
125+
"""
126+
Adds special methods to a query set of question objects.
127+
"""
128+
129+
def count_votes(self):
130+
"""
131+
Returns questions annotated with the number of votes they have.
132+
"""
133+
return self.annotate(num_votes=Coalesce(models.Sum('votes__vote'), 0))
134+
135+
136+
##########################################################################
137+
## Answer Manager
138+
##########################################################################
139+
140+
class AnswerManager(models.Manager):
141+
142+
def count_votes(self):
143+
"""
144+
Returns questions annotated with the number of votes they have.
145+
"""
146+
return self.get_queryset().count_votes()
147+
148+
149+
def get_queryset(self):
150+
"""
151+
Return a QuestionQuerySet instead of the standard queryset.
152+
"""
153+
return AnswerQuerySet(self.model, using=self._db)

fugato/models.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@
1919

2020
import time
2121

22+
from slugify import slugify
2223
from django.db import models
2324
from voting.models import Vote
25+
from operator import itemgetter
2426
from minent.utils import nullable
2527
from autoslug import AutoSlugField
26-
from fugato.managers import QuestionManager
27-
from model_utils.models import TimeStampedModel
2828
from django.core.urlresolvers import reverse
29+
from model_utils.models import TimeStampedModel
30+
from fugato.managers import QuestionManager, AnswerManager
2931
from django.contrib.contenttypes.fields import GenericRelation
30-
from slugify import slugify
31-
from operator import itemgetter
32+
3233

3334
##########################################################################
3435
## Qustion and Answer Models
@@ -49,6 +50,10 @@ class Question(TimeStampedModel):
4950
## Set custom manager on Question
5051
objects = QuestionManager()
5152

53+
class Meta:
54+
db_table = "questions"
55+
get_latest_by = 'created'
56+
5257
def get_absolute_url(self):
5358
"""
5459
Return the detail view of the Question object
@@ -79,20 +84,14 @@ def set_answer_order_by_votes(self):
7984
passes in the order based on the sum of the votes.
8085
"""
8186
# Construct the aggregation query
82-
query = self.answers.values('id')
83-
query = query.annotate(votes=models.Sum('votes__vote'))
87+
query = self.answers.count_votes().values('id', 'num_votes')
8488

8589
order = [
86-
a['id'] for a in sorted(query, key=itemgetter('votes'), reverse=True)
90+
a['id'] for a in sorted(query, key=itemgetter('num_votes'), reverse=True)
8791
]
8892

8993
self.set_answer_order(order)
9094

91-
92-
class Meta:
93-
db_table = "questions"
94-
get_latest_by = 'created'
95-
9695
def __str__(self):
9796
return self.text
9897

@@ -109,6 +108,9 @@ class Answer(TimeStampedModel):
109108
question = models.ForeignKey( 'fugato.Question', related_name="answers" ) # The question this answer answers
110109
votes = GenericRelation( Vote, related_query_name='answers' ) # Votes for the goodness of the answer
111110

111+
## Set custom manager on Answer
112+
objects = AnswerManager()
113+
112114
class Meta:
113115
db_table = "answers"
114116
order_with_respect_to = 'question'

minent/templates/fugato/list.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ <h3>
8282
<span class="label label-info">{{ question.answers.count }} answer{{ question.answers.count|pluralize }}</span>
8383
<span class="label label-info">{{ question.votes.count }} vote{{ question.votes.count|pluralize }}</span>
8484
{% for tag in question.tags.all %}
85-
<span class="label label-primary">{% if tag.is_synonym %}{{ tag.head_word }}{% else %}{{ tag }}{% endif %}</span>
85+
<a href="{% url 'question-list' %}?tag={{ tag.slug }}" title="Show questions tagged: {{ tag.text }}">
86+
<span class="label label-primary">{{ tag }}</span>
87+
</a>
8688
{% endfor %}
8789
</p>
8890
</div>

minent/templates/fugato/question.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ <h2 id="questionText">{{ question.text }}</h2>
129129
<div class="question-tagging">
130130
<div class="pull-left" id="questionTags">
131131
{% for tag in question.tags.all %}
132-
<span class="label label-primary">{% if tag.is_synonym %}{{ tag.head_word }}{% else %}{{ tag }}{% endif %}</span>
132+
<a href="{% url 'question-list' %}?tag={{ tag.slug }}" title="Show questions tagged: {{ tag.text }}">
133+
<span class="label label-primary">{{ tag }}</span>
134+
</a>
133135
{% endfor %}
134136
</div>
135137
<div class="pull-right">

minent/tests/test_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
## Module variables
2424
##########################################################################
2525

26-
EXPECTED_VERSION = "1.2b3"
26+
EXPECTED_VERSION = "1.2.1b4"
2727

2828
##########################################################################
2929
## Initialization Tests

minent/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
__version_info__ = {
2121
'major': 1,
2222
'minor': 2,
23-
'micro': 0,
23+
'micro': 1,
2424
'releaselevel': 'beta',
25-
'serial': 3,
25+
'serial': 4,
2626
}
2727

2828

stream/templatetags/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Copyright (C) 2016 District Data Labs
88
# For license information, see LICENSE.txt
99
#
10-
# ID: __init__.py [] [email protected] $
10+
# ID: __init__.py [001baf8] [email protected] $
1111

1212
"""
1313
Custom inclusion tags for stream activity objects.

stream/templatetags/activity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Copyright (C) 2016 District Data Labs
88
# For license information, see LICENSE.txt
99
#
10-
# ID: activity.py [] [email protected] $
10+
# ID: activity.py [001baf8] [email protected] $
1111

1212
"""
1313
Representations of activity stream objects.

0 commit comments

Comments
 (0)