]> git.lizzy.rs Git - cheatdb.git/commitdiff
Add work queue icon to navigation bar
authorrubenwardy <rw@rubenwardy.com>
Sat, 19 Sep 2020 18:30:33 +0000 (19:30 +0100)
committerrubenwardy <rw@rubenwardy.com>
Sat, 19 Sep 2020 18:30:33 +0000 (19:30 +0100)
app/flatpages/help/ranks_permissions.md
app/template_filters.py
app/templates/base.html

index b03a7cd4234091a08b764728508ba40b220dbcd5..1e1b8efec5418af1968dd73059a7af07a44bd8ec 100644 (file)
@@ -163,7 +163,7 @@ title: Ranks and Permissions
                        <td>Approve Release</td>
                        <td></td> <!-- new -->
                        <td></td>
-                       <td></td> <!-- member -->
+                       <td></td> <!-- member -->
                        <td></td>
                        <td>✓</td> <!-- trusted member -->
                        <td></td>
index 574c1b1f00f975c1f1516ade5289767a830e647b..39d38065e454ec21850cb8ce0e8d281927e87396 100644 (file)
@@ -1,6 +1,7 @@
 from . import app
-from .models import Permission
+from .models import Permission, Package, PackageState, PackageRelease
 from .utils import abs_url_for, url_set_query
+from flask_user import current_user
 from urllib.parse import urlparse
 
 @app.context_processor
@@ -12,6 +13,15 @@ def inject_functions():
        check_global_perm = Permission.checkPerm
        return dict(abs_url_for=abs_url_for, url_set_query=url_set_query, check_global_perm=check_global_perm)
 
+@app.context_processor
+def inject_todo():
+       todo_list_count = None
+       if current_user.is_authenticated and current_user.canAccessTodoList():
+               todo_list_count = Package.query.filter_by(state=PackageState.READY_FOR_REVIEW).count()
+               todo_list_count += PackageRelease.query.filter_by(approved=False, task_id=None).count()
+
+       return dict(todo_list_count=todo_list_count)
+
 @app.template_filter()
 def throw(err):
        raise Exception(err)
index 239cbe431c0623a9f0929f4eb96ccb2a7aa84449..fabe2f6117a485e0fd9f44a02b43fcddb2867f59 100644 (file)
                                </form>
                                <ul class="navbar-nav ml-auto">
                                        {% if current_user.is_authenticated %}
-                                               <li class="nav-item"><a class="nav-link notification-icon" href="{{ url_for('notifications.list_all') }}">
-                                                       {% if current_user.notifications %}
-                                                               <i class="fas fa-bell"></i>
-                                                               <span class="badge badge-pill badge-notify" style="font-size:10px;">{{ current_user.notifications | length }}</span>
-                                                       {% else %}
-                                                               <i class="fas fa-bell" ></i>
-                                                       {% endif %}
-                                               </a></li>
-                                               <li class="nav-item"><a class="nav-link" href="{{ url_for('packages.create_edit') }}">
-                                                       <i class="fas fa-plus"></i>
-                                               </a></li>
+                                               {% if todo_list_count is not none %}
+                                                       <li class="nav-item">
+                                                               <a class="nav-link notification-icon"
+                                                                                       href="{{ url_for('todo.view') }}"
+                                                                                       title="{{ _('Work Queue') }}">
+                                                                       {% if todo_list_count > 0 %}
+                                                                               <i class="fas fa-inbox"></i>
+                                                                               <span class="badge badge-pill badge-notify" style="font-size:10px;">{{ todo_list_count }}</span>
+                                                                       {% else %}
+                                                                               <i class="fas fa-inbox" ></i>
+                                                                       {% endif %}
+                                                               </a>
+                                                       </li>
+                                               {% endif %}
+                                               <li class="nav-item">
+                                                       <a class="nav-link notification-icon"
+                                                                               href="{{ url_for('notifications.list_all') }}"
+                                                                               title="{{ _('Notifications') }}">
+                                                               {% if current_user.notifications %}
+                                                                       <i class="fas fa-bell"></i>
+                                                                       <span class="badge badge-pill badge-notify" style="font-size:10px;">{{ current_user.notifications | length }}</span>
+                                                               {% else %}
+                                                                       <i class="fas fa-bell" ></i>
+                                                               {% endif %}
+                                                       </a>
+                                               </li>
+                                               <li class="nav-item">
+                                                       <a class="nav-link"
+                                                                       href="{{ url_for('packages.create_edit') }}"
+                                                                       title="{{ _('Add Package') }}">
+                                                               <i class="fas fa-plus"></i>
+                                                       </a>
+                                               </li>
                                                <li class="nav-item dropdown">
                                                        <a class="nav-link dropdown-toggle"
                                                                data-toggle="dropdown"
                                                                </li>
                                                                {% if current_user.canAccessTodoList() %}
                                                                        <li class="nav-item"><a class="nav-link" href="{{ url_for('todo.view') }}">{{ _("Work Queue") }}</a></li>
-                                                                       <li class="nav-item"><a  class="nav-link" href="{{ url_for('users.list_all') }}">{{ _("User list") }}</a></li>
                                                                {% endif %}
+                                                               <li class="nav-item"><a  class="nav-link" href="{{ url_for('users.list_all') }}">{{ _("User list") }}</a></li>
                                                                <li class="nav-item">
                                                                        <a class="nav-link" href="{{ url_for('todo.topics') }}">{{ _("All unadded topics") }}</a>
                                                                </li>