Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jean Michel Rouly
research-questions
Commits
79451e84
Commit
79451e84
authored
Mar 08, 2014
by
Jean Michel Rouly
Browse files
Filter by date as well
parent
3730cfdb
Changes
2
Hide whitespace changes
Inline
Side-by-side
researchquestions/website/templates/index.html
View file @
79451e84
...
...
@@ -26,12 +26,16 @@ Homepage
</div>
{% endif %}
{% if sort
== "comments"
%}
{% if sort %}
<div
class=
"row"
>
<div
class=
"col-lg-10 col-lg-offset-1"
>
<div
class=
"alert alert-dismissable alert-info text-center"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
>
×
</button>
Sorting questions with fewest comments first.
{% if sort == "comments" %}
<strong>
Sorting questions with fewest comments first.
</strong>
{% elif sort == "date" %}
<strong>
Sorting questions most recently first.
</strong>
{% endif %}
</div>
</div>
</div>
...
...
researchquestions/website/views.py
View file @
79451e84
...
...
@@ -59,6 +59,8 @@ def index(request, *args, **kwargs):
if
sort
is
not
None
:
if
sort
==
"comments"
:
questions
=
questions
.
annotate
(
comment_count
=
Count
(
'comments'
)).
order_by
(
'comment_count'
)
if
sort
==
"date"
:
questions
=
questions
.
order_by
(
'-date'
)
paginator
=
Paginator
(
questions
,
10
)
# show 25 questions per page
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment