Просмотр исходного кода

Add unread report count to overview

Peter Justin 8 лет назад
Родитель
Сommit
67ead19153
2 измененных файлов с 21 добавлено и 7 удалено
  1. 12 5
      flaskbb/management/views.py
  2. 9 2
      flaskbb/templates/management/overview.html

+ 12 - 5
flaskbb/management/views.py

@@ -60,6 +60,11 @@ def overview():
     else:
         online_users = len(get_online_users())
 
+    unread_reports = Report.query.\
+        filter(Report.zapped == None).\
+        order_by(Report.id.desc()).\
+        count()
+
     celery_inspect = celery.control.inspect()
     try:
         celery_running = True if celery_inspect.ping() else False
@@ -68,28 +73,30 @@ def overview():
         # from redis is also bad because you can run celery with other
         # brokers as well.
         celery_running = False
+
     python_version = "{}.{}.{}".format(
         sys.version_info[0], sys.version_info[1], sys.version_info[2]
     )
 
     stats = {
         "current_app": current_app,
-        # user stats
+        "unread_reports": unread_reports,
+        # stats stats
         "all_users": User.query.count(),
         "banned_users": banned_users,
         "online_users": online_users,
         "all_groups": Group.query.count(),
-        # forum stats
         "report_count": Report.query.count(),
         "topic_count": Topic.query.count(),
         "post_count": Post.query.count(),
-        # misc stats
-        "plugins": get_all_plugins(),
+        # components
         "python_version": python_version,
         "celery_version": celery_version,
         "celery_running": celery_running,
         "flask_version": flask_version,
-        "flaskbb_version": flaskbb_version
+        "flaskbb_version": flaskbb_version,
+        # plugins
+        "plugins": get_all_plugins()
     }
 
     return render_template("management/overview.html", **stats)

+ 9 - 2
flaskbb/templates/management/overview.html

@@ -20,11 +20,18 @@
                 <div class="stats">
                     <div class="row stats-row">
                         <div class="col-md-12 col-sm-12 col-xs-12">
-                            <!-- TODO: (Later) Show new reports, updates, etc -->
+                            {# TODO: I have a feeling that this can be done so much nicer #}
                             {% if not celery_running %}
                             <div class="alert-message alert-message-danger">
                                 <h4>{% trans %}There is a problem.{% endtrans %}</h4>
-                                <p>{% trans config_path=current_app.config["CONFIG_PATH"] %}Celery is <strong>not</strong> running. You can start celery with this command <code>flaskbb --config {{ config_path }} celery worker</code>{% endtrans %}</p>
+                                <p>{% trans %}Celery is <strong>not</strong> running.{% endtrans %}</p>
+                                <p>{% trans %}You can start celery with this command:{% endtrans %}</p>
+                                <pre>flaskbb --config {{ current_app.config["CONFIG_PATH"] }} celery worker</pre>
+                            </div>
+                            {% elif unread_reports > 0 %}
+                            <div class="alert-message alert-message-warning">
+                                <h4>{% trans %}There is something that wants your attention.{% endtrans %}</h4>
+                                <p>{% trans url=url_for('management.unread_reports') %}You have <a href="{{ url }}">{{ unread_reports }} unread reports</a>.{% endtrans %}</p>
                             </div>
                             {% else %}
                             <div class="alert-message alert-message-success">