File size: 1,658 Bytes
9173642
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{% extends "base.html" %}
{% block title %}Admin Dashboard{% endblock %}
{% block content %}
<div class="bg-white p-6 rounded shadow">
  <h2 class="text-2xl font-bold mb-4">Admin Panel</h2>
  <p class="mb-4"><strong>Total Users:</strong> {{ total_users }}</p>
 <table class="w-full table-auto border-collapse">
    <thead>
      <tr class="bg-gray-100">
        <th class="p-2">ID</th>
        <th class="p-2">Name</th>
        <th class="p-2">Email</th>
        <th class="p-2">Last CGPA</th>
        <th class="p-2">Actions</th>
      </tr>
    </thead>
    <tbody>
      {% for u in users %}
      {% set last = u.id | tojson | int and (crud.get_predictions(u.id)|last) %}
      <tr class="hover:bg-gray-50">
        <td class="p-2">{{ u.id }}</td>
        <td class="p-2">{{ u.name }}</td>
        <td class="p-2">{{ u.email }}</td>
        <td class="p-2 text-center">
          {% if last %}
            <span class="px-2 py-1 rounded 

              {% if last.predicted < 6 %}bg-red-200 text-red-800{% else %}bg-green-200 text-green-800{% endif %}">
              {{ last.predicted | round(2) }}
            </span>
          {% else %}
            —
          {% endif %}
        </td>
        <td class="p-2 space-x-2">
          <form class="inline" method="post" action="/admin/user/delete">
            <input type="hidden" name="user_id" value="{{ u.id }}">
            <button class="px-2 py-1 bg-red-600 text-white rounded hover:bg-red-700">
              Delete
            </button>
          </form>
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>
{% endblock %}