Revision history [back]
For those who still want to sort their question by view, I made it, here is my git diff for this feature (maybe I'll do a pull request for it ...)
diff --git a/askbot/const/__init__.py b/askbot/const/__init__.py
index e693a63..48a477a 100644
--- a/askbot/const/__init__.py
+++ b/askbot/const/__init__.py
@@ -50,6 +50,8 @@ POST_SORT_METHODS = (
('answers-asc', _('coldest')),
('votes-desc', _('most voted')),
('votes-asc', _('least voted')),
+ ('views-desc', _('most viewed')),
+ ('views-asc', _('least viewed')),
('relevance-desc', _('relevance')),
)
diff --git a/askbot/models/question.py b/askbot/models/question.py
index 2bb9e80..cf8633f 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -290,7 +290,8 @@ class ThreadManager(models.Manager):
'answers-asc': 'answer_count',
'votes-desc': '-score',
'votes-asc': 'score',
-
+ 'views-desc': '-view_count',
+ 'views-asc': 'view_count',
'relevance-desc': '-relevance', # special Postgresql-specific ordering, 'relevance' quaso-column is added by get_for_query()
}
orderby = QUESTION_ORDER_BY_MAP[search_state.sort]
diff --git a/askbot/skins/default/templates/main_page/tab_bar.html b/askbot/skins/default/templates/main_page/tab_bar.html
index 17ab810..9620d32 100644
--- a/askbot/skins/default/templates/main_page/tab_bar.html
+++ b/askbot/skins/default/templates/main_page/tab_bar.html
@@ -75,6 +75,15 @@
search_state = search_state,
)
}}
+ {{macros.reversible_sort_button(
+ button_sort_criterium = 'views',
+ label = gettext('by views'),
+ asc_tooltip = gettext('click to see least viewed questions'),
+ desc_tooltip = gettext('click to see most viewed questions'),
+ current_sort_method = sort,
+ search_state = search_state,
+ )
+ }}
</div>
</div>