diff --git a/files/helpers/sorting_and_time.py b/files/helpers/sorting_and_time.py index bc442b86e..b14575b4e 100644 --- a/files/helpers/sorting_and_time.py +++ b/files/helpers/sorting_and_time.py @@ -53,6 +53,8 @@ def sort_objects(sort, objects, cls): return objects.order_by((cls.upvotes+1)/(cls.downvotes+1) + (cls.downvotes+1)/(cls.upvotes+1), cls.downvotes.desc(), cls.created_utc.desc()) elif sort == "bottom": return objects.order_by(cls.upvotes - cls.downvotes, cls.created_utc.desc()) + elif sort == "random": + return objects.order_by(func.random()) else: return objects.order_by(cls.downvotes - cls.upvotes, cls.created_utc.desc()) diff --git a/files/templates/home.html b/files/templates/home.html index 5e0482766..e253527b7 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -115,6 +115,7 @@ {% if sort=="comments" %}{% endif %} {% if sort=="subscriptions" %}{% endif %} {% if sort=="saves" %}{% endif %} + {% if sort=="random" %}{% endif %} {{sort | capitalize}} diff --git a/files/templates/home_comments.html b/files/templates/home_comments.html index 2326bb9d0..a65ade4fe 100644 --- a/files/templates/home_comments.html +++ b/files/templates/home_comments.html @@ -37,6 +37,7 @@ {% if sort=="old" %}{% endif %} {% if sort=="controversial" %}{% endif %} {% if sort=="saves" %}{% endif %} + {% if sort=="random" %}{% endif %} {{sort | capitalize}} diff --git a/files/templates/post.html b/files/templates/post.html index faea3c45f..18f8a0c07 100644 --- a/files/templates/post.html +++ b/files/templates/post.html @@ -299,6 +299,7 @@ {% if sort=="new" %}{% endif %} {% if sort=="old" %}{% endif %} {% if sort=="controversial" %}{% endif %} + {% if sort=="random" %}{% endif %} {{sort | capitalize}} diff --git a/files/templates/search.html b/files/templates/search.html index 9360e901c..469724d0e 100644 --- a/files/templates/search.html +++ b/files/templates/search.html @@ -127,6 +127,7 @@ {% if sort=="comments" %}{% endif %} {% if sort=="subscriptions" %}{% endif %} {% if sort=="saves" %}{% endif %} + {% if sort=="random" %}{% endif %} {{sort | capitalize}} @@ -148,63 +150,36 @@ -{% if not '/users' in request.path %} -
- -
- {% endif %} -
-
-
- -
+
+
+
+
-
-
-
- {% block listing_template %} - {% include "post_listing.html" %} - {% endblock %} -
+
+
+
+
+ {% block listing_template %} + {% include "post_listing.html" %} + {% endblock %}
- {% endblock %} - {% block pagenav %} - {% include "pagination.html" %} - {% endblock %} +
+{% endblock %} +{% block pagenav %} +{% include "pagination.html" %} +{% endblock %} diff --git a/files/templates/userpage/header.html b/files/templates/userpage/header.html index 058f32e4e..c099c1fd2 100644 --- a/files/templates/userpage/header.html +++ b/files/templates/userpage/header.html @@ -59,6 +59,7 @@ {% if sort=="new" %}{% endif %} {% if sort=="old" %}{% endif %} {% if sort=="controversial" %}{% endif %} + {% if sort=="random" %}{% endif %} {{sort | capitalize}}