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