Jinja2: add SORTS_COMMON and SORTS_ALL
This commit is contained in:
parent
384b4fbd22
commit
ba96decb9b
4 changed files with 5 additions and 3 deletions
|
@ -86,6 +86,8 @@ def inject_constants():
|
|||
"PERMS":PERMS,
|
||||
"FEATURES":FEATURES,
|
||||
"RENDER_DEPTH_LIMIT":RENDER_DEPTH_LIMIT,
|
||||
"SORTS_COMMON":SORTS_COMMON,
|
||||
"SORTS_POSTS":SORTS_POSTS,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ def settings_profile_post(v):
|
|||
|
||||
defaultsortingcomments = request.values.get("defaultsortingcomments")
|
||||
if defaultsortingcomments:
|
||||
if defaultsortingcomments in SORTS_ALL:
|
||||
if defaultsortingcomments in SORTS_COMMON:
|
||||
v.defaultsortingcomments = defaultsortingcomments
|
||||
updated = True
|
||||
else: abort(400)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<button class="btn btn-secondary dropdown-toggle" role="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas {{SORTS_POSTS[sort]}} mr-1"></i> {{sort|capitalize}}
|
||||
</button>
|
||||
{% for possible_sort in (SORTS_ALL if is_comment else SORTS_POSTS) %}
|
||||
{% for possible_sort in (SORTS_COMMON if is_comment else SORTS_POSTS) %}
|
||||
{%- if sort != possible_sort -%}
|
||||
<a class="dropdown-item" href="?{{extra_query ~ '&' if extra_query else ''}}sort={{possible_sort}}&t={{t}}"><i class="fas {{SORTS_POSTS[possible_sort]}} mr-1"></i> {{possible_sort | capitalize}}</a>
|
||||
{%- endif -%}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<p>Change the default sorting for comments.</p>
|
||||
<div class="input-group mb2">
|
||||
<select autocomplete="off" id='defaultsortingcomments' class="form-control" form="profile-settings" name="defaultsortingcomments" onchange="post_toast(this,'/settings/profile?defaultsortingcomments='+document.getElementById('defaultsortingcomments').value)">
|
||||
{% for entry in SORTS_ALL %}
|
||||
{% for entry in SORTS_COMMON %}
|
||||
<option value="{{entry}}"{{' selected' if v.defaultsortingcomments==entry}}>{{entry}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue