Basic CRUD operations for managing registered admin users Encrypted personal information Still missing sections on managing tests and results Also missing dashboards/index/category landing pages
		
			
				
	
	
		
			157 lines
		
	
	
		
			8.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			157 lines
		
	
	
		
			8.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
{% extends "admin/components/base.html" %}
 | 
						|
{% block title %} SKA Referee Test | Manage Users {% endblock %}
 | 
						|
{% block datatable_css %}
 | 
						|
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap5.min.css"/>
 | 
						|
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.0.1/css/buttons.bootstrap5.min.css"/>
 | 
						|
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/colreorder/1.5.5/css/colReorder.bootstrap5.min.css"/>
 | 
						|
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/fixedheader/3.2.0/css/fixedHeader.bootstrap5.min.css"/>
 | 
						|
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/keytable/2.6.4/css/keyTable.bootstrap5.min.css"/>
 | 
						|
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.9/css/responsive.bootstrap5.min.css"/>
 | 
						|
{% endblock %}
 | 
						|
{% block content %}
 | 
						|
    <h1>Manage Users</h1>
 | 
						|
 | 
						|
    <table id="user-table" class="table table-striped" style="width:100%">
 | 
						|
        <thead>
 | 
						|
            <tr>
 | 
						|
                <th>
 | 
						|
                    
 | 
						|
                </th>
 | 
						|
                <th data-priority="1">
 | 
						|
                    Username
 | 
						|
                </th>
 | 
						|
                <th>
 | 
						|
                    Email Address
 | 
						|
                </th>
 | 
						|
                <th data-priority="1">
 | 
						|
                    Actions
 | 
						|
                </th>
 | 
						|
            </tr>
 | 
						|
        </thead>
 | 
						|
        <tbody>
 | 
						|
            {% for user in users %}
 | 
						|
                <tr class="user-table-row">
 | 
						|
                    <td>
 | 
						|
                        {% if user._id == get_id_from_cookie() %}
 | 
						|
                            <div class="text-success" title="Current User">
 | 
						|
                                <svg  xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi success bi-caret-right-fill" viewBox="0 0 16 16">
 | 
						|
                                    <path d="m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"/>
 | 
						|
                                </svg>
 | 
						|
                            </div>
 | 
						|
                        {% endif %}
 | 
						|
                    </td>
 | 
						|
                    <td>
 | 
						|
                        {{ user.username }}
 | 
						|
                    </td>
 | 
						|
                    <td>
 | 
						|
                        {{ user.email }}
 | 
						|
                    </td>
 | 
						|
                    <td class="user-row-actions">
 | 
						|
                        <a
 | 
						|
                            href="
 | 
						|
                            {% if not user._id == get_id_from_cookie() %}
 | 
						|
                                {{ url_for('admin_views.update_user', _id = user._id ) }}
 | 
						|
                            {% else %}
 | 
						|
                                {{ url_for('admin_auth.account') }}
 | 
						|
                            {% endif %}
 | 
						|
                            "
 | 
						|
                            class="btn btn-primary"
 | 
						|
                            title="Update User"
 | 
						|
                        >
 | 
						|
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-person-lines-fill" viewBox="0 0 16 16">
 | 
						|
                                <path d="M6 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-5 6s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H1zM11 3.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5zm.5 2.5a.5.5 0 0 0 0 1h4a.5.5 0 0 0 0-1h-4zm2 3a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1h-2zm0 3a.5.5 0 0 0 0 1h2a.5.5 0 0 0 0-1h-2z"/>
 | 
						|
                            </svg>
 | 
						|
                        </a>
 | 
						|
                        <a
 | 
						|
                            href="
 | 
						|
                            {% if not user._id == get_id_from_cookie()  %}
 | 
						|
                                {{ url_for('admin_views.delete_user', _id = user._id ) }}
 | 
						|
                            {% else %}
 | 
						|
                                #
 | 
						|
                            {% endif %}
 | 
						|
                            "
 | 
						|
                            class="btn btn-danger {% if user._id == get_id_from_cookie()  %} disabled {% endif %}"
 | 
						|
                            title="Delete User"
 | 
						|
                            {% if user._id == get_id_from_cookie()  %} onclick="return false" {% endif %}
 | 
						|
                        >
 | 
						|
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-person-x-fill" viewBox="0 0 16 16">
 | 
						|
                                <path fill-rule="evenodd" d="M1 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H1zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm6.146-2.854a.5.5 0 0 1 .708 0L14 6.293l1.146-1.147a.5.5 0 0 1 .708.708L14.707 7l1.147 1.146a.5.5 0 0 1-.708.708L14 7.707l-1.146 1.147a.5.5 0 0 1-.708-.708L13.293 7l-1.147-1.146a.5.5 0 0 1 0-.708z"></path>
 | 
						|
                            </svg>
 | 
						|
                        </button>
 | 
						|
                    </td>
 | 
						|
                </tr>
 | 
						|
            {% endfor %}
 | 
						|
        </tbody>
 | 
						|
    </table>
 | 
						|
 | 
						|
    <div class="form-container">
 | 
						|
        <form name="form-create-user" class="form-signin">
 | 
						|
            <h2 class="form-signin-heading">Create User</h2>
 | 
						|
            {{ form.hidden_tag() }}
 | 
						|
            <div class="form-label-group">
 | 
						|
                {{ form.username(class_="form-control", placeholder="Enter Username") }}
 | 
						|
                {{ form.username.label }}
 | 
						|
            </div>
 | 
						|
            <div class="form-label-group">
 | 
						|
                {{ form.email(class_="form-control", placeholder="Enter Email") }}
 | 
						|
                {{ form.email.label }}
 | 
						|
            </div>
 | 
						|
            <div class="form-label-group">
 | 
						|
                If you do not enter a password, a random one will be generated.
 | 
						|
            </div>
 | 
						|
            <div class="form-label-group">
 | 
						|
                {{ form.password(class_="form-control", placeholder="Enter Password") }}
 | 
						|
                {{ form.password.label }}
 | 
						|
            </div>
 | 
						|
            {% include "admin/components/client-alerts.html" %}
 | 
						|
            <div class="container form-submission-button">
 | 
						|
                <div class="row">
 | 
						|
                    <div class="col text-center">
 | 
						|
                        <button title="Create User" class="btn btn-md btn-success btn-block" type="submit">
 | 
						|
                            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-person-plus-fill" viewBox="0 0 20 20">
 | 
						|
                                <path d="M1 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H1zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
 | 
						|
                                <path fill-rule="evenodd" d="M13.5 5a.5.5 0 0 1 .5.5V7h1.5a.5.5 0 0 1 0 1H14v1.5a.5.5 0 0 1-1 0V8h-1.5a.5.5 0 0 1 0-1H13V5.5a.5.5 0 0 1 .5-.5z"/>
 | 
						|
                            </svg>
 | 
						|
                            Create User
 | 
						|
                        </button>
 | 
						|
                    </div>
 | 
						|
                </div>
 | 
						|
            </div>
 | 
						|
        </form>
 | 
						|
    </div>
 | 
						|
{% endblock %}
 | 
						|
{% block datatable_scripts %}
 | 
						|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/1.11.3/js/dataTables.bootstrap5.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.0.1/js/dataTables.buttons.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.0.1/js/buttons.bootstrap5.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.0.1/js/buttons.colVis.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.0.1/js/buttons.html5.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.0.1/js/buttons.print.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/colreorder/1.5.5/js/dataTables.colReorder.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/fixedheader/3.2.0/js/dataTables.fixedHeader.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/keytable/2.6.4/js/dataTables.keyTable.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js"></script>
 | 
						|
<script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.9/js/responsive.bootstrap5.js"></script>
 | 
						|
    <script>
 | 
						|
        $(document).ready(function() {
 | 
						|
            $('#user-table').DataTable({
 | 
						|
                'columnDefs': [
 | 
						|
                    {'sortable': false, 'targets': [0,3]}
 | 
						|
                ],
 | 
						|
                'order': [[1, 'asc'], [2, 'asc']],
 | 
						|
                'buttons': [
 | 
						|
                    'copy', 'excel', 'pdf'
 | 
						|
                ],
 | 
						|
                'responsive': 'true',
 | 
						|
                'colReorder': 'true',
 | 
						|
                'fixedHeader': 'true'
 | 
						|
            });
 | 
						|
        } );
 | 
						|
        $('#user-table').show();
 | 
						|
        $(window).trigger('resize');
 | 
						|
    </script>
 | 
						|
{% endblock %} |