Procházet zdrojové kódy

Added name mentioned report in dashboard

Mohidul Islam před 5 roky
rodič
revize
38f8920393

+ 1 - 0
dashboard/templates/base.html

@@ -29,6 +29,7 @@
             <div class="navbar-nav">
                 <a class="nav-item nav-link" href="{% url 'analytics' %}">Analytics</a>
                 <a class="nav-item nav-link" href="{% url 'review-report' %}">App Report</a>
+                <a class="nav-item nav-link" href="{% url 'leader-board' 12345 %}">Leaderboard</a>
             </div>
           </div>
         </div>

+ 33 - 0
name_extractor/templates/leaderboard.html

@@ -0,0 +1,33 @@
+{% extends "base.html" %}
+{% block report %}
+  <h2 style="text-align: center">Staff Leader Board</h2>
+<hr>
+  <a href="{% url 'leader-board' 12345 %}"><span class="badge badge-info">All Location</span></a>
+  {% for loc in er_locations %}
+    <a href="{% url 'leader-board' loc.location_id %}"><span class="badge badge-info">{{ loc }}</span></a>
+  {% endfor %}
+<hr>
+    <table class="table mt-2">
+      <thead style="text-align: center">
+        <tr class="table-primary">
+          <th scope="col">Name</th>
+          <th scope="col">Department</th>
+          <th scope="col">Location</th>
+          <th scope="col">Total Mentioned</th>
+          <th scope="col">Total Unit</th>
+        </tr>
+      </thead>
+      <tbody style="text-align: center">
+        {% for staff in staffs %}
+          <tr>
+            <th scope="row">{{ staff.name }}</th>
+            <td>{{ staff.department }}</td>
+            <td>{{ staff.location }}</td>
+            <td>{{ staff.name_mentioned }}</td>
+            <td>{{ staff.total_units }}</td>
+          </tr>
+        {% endfor %}
+      </tbody>
+    </table>
+{% endblock %}
+

+ 6 - 0
name_extractor/urls.py

@@ -0,0 +1,6 @@
+from django.urls import path
+from .views import leader_board
+
+urlpatterns = [
+    path('<location_id>/', leader_board, name='leader-board'),
+]

+ 13 - 1
name_extractor/views.py

@@ -1,3 +1,15 @@
 from django.shortcuts import render
+from gauth.models import Location
+from name_extractor.models import Staff
 
-# Create your views here.
+
+def leader_board(request, location_id):
+    if location_id == '12345':
+        staffs = Staff.objects.all().exclude(total_units=0.00).order_by('-total_units')
+    else:
+        staffs = Staff.objects.filter(location_id=location_id).exclude(total_units=0.00).order_by('-total_units')
+
+    locations = Location.objects.all()
+    context = {'er_locations': locations, 'staffs': staffs}
+
+    return render(request, 'leaderboard.html', context=context)

+ 1 - 0
review_automation/urls.py

@@ -12,6 +12,7 @@ urlpatterns = [
     path('nlu/', include('nlu_job.urls')),
     path('dashboard/', include('dashboard.urls')),
     path('analytics/', include('analytics.urls')),
+    path('leaderboard/', include('name_extractor.urls')),
 ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)