frontpage: Fix issues with hidden property

- Fix incorrect use of compound boolean expression in if statement.
  'a and b or c' is treated as '((a and b) or c)'.

- Allow unhiding a shortcut.

- Raise exception when shortcut requested does not exist.  This is the
  Python way.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2017-03-30 11:47:03 +05:30
parent 6e2f70063b
commit 561f8f2d90
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 24 additions and 25 deletions

View File

@ -68,10 +68,7 @@ def remove_shortcut(shortcut_id):
if not match(shortcut)} if not match(shortcut)}
def hide_shortcut(shortcut_id): def hide_shortcut(shortcut_id, hide=True):
""" """Mark a shortcut as hidden or not hidden."""
Makes the shortcut hidden
"""
global shortcuts global shortcuts
if shortcut_id in shortcuts.keys(): shortcuts[shortcut_id]['hidden'] = hide
shortcuts[shortcut_id]['hidden'] = True

View File

@ -27,7 +27,8 @@
{% if shortcuts %} {% if shortcuts %}
{% for shortcut in shortcuts %} {% for shortcut in shortcuts %}
{% if shortcut.hidden is False and user.is_authenticated or shortcut.login_required is False %} {% if not shortcut.hidden %}
{% if user.is_authenticated or not shortcut.login_required %}
<div class="col-sm-3"> <div class="col-sm-3">
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
{% if selected_id == shortcut.id %} {% if selected_id == shortcut.id %}
@ -47,6 +48,7 @@
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
{% endif %}
{% endfor %} {% endfor %}
{% else %} {% else %}