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)}
def hide_shortcut(shortcut_id):
"""
Makes the shortcut hidden
"""
def hide_shortcut(shortcut_id, hide=True):
"""Mark a shortcut as hidden or not hidden."""
global shortcuts
if shortcut_id in shortcuts.keys():
shortcuts[shortcut_id]['hidden'] = True
shortcuts[shortcut_id]['hidden'] = hide

View File

@ -27,25 +27,27 @@
{% if shortcuts %}
{% for shortcut in shortcuts %}
{% if shortcut.hidden is False and user.is_authenticated or shortcut.login_required is False %}
<div class="col-sm-3">
<ul class="nav nav-pills nav-stacked">
{% if selected_id == shortcut.id %}
<li class="active">
<a href="{{ shortcut.url }}" class="active">
{% else %}
<li>
<a href="{{ shortcut.url }}">
{% endif %}
<center>
<img src="{% static 'theme/icons/' %}{{ shortcut.icon }}.png" style="max-width: 100px; height: 100px" />
<br>
{{ shortcut.label|linebreaks }}
</center>
</a>
</li>
</ul>
</div>
{% if not shortcut.hidden %}
{% if user.is_authenticated or not shortcut.login_required %}
<div class="col-sm-3">
<ul class="nav nav-pills nav-stacked">
{% if selected_id == shortcut.id %}
<li class="active">
<a href="{{ shortcut.url }}" class="active">
{% else %}
<li>
<a href="{{ shortcut.url }}">
{% endif %}
<center>
<img src="{% static 'theme/icons/' %}{{ shortcut.icon }}.png" style="max-width: 100px; height: 100px" />
<br>
{{ shortcut.label|linebreaks }}
</center>
</a>
</li>
</ul>
</div>
{% endif %}
{% endif %}
{% endfor %}