mirror of
https://github.com/adrigongv23/G26---Telemetry-Software.git
synced 2026-08-25 19:43:16 +02:00
Gestión usuarios añadida
This commit is contained in:
parent
319a95cc91
commit
97d38a086c
8 changed files with 284 additions and 3 deletions
125
Plataform_Web/templates/gestion_usuarios.html
Normal file
125
Plataform_Web/templates/gestion_usuarios.html
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}Gestión de Usuarios | Gades Manager{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mb-3 flex-shrink-0">
|
||||
<div class="col-12">
|
||||
<div class="bg-dark text-white p-3 rounded-3 shadow-sm" style="border-left: 5px solid #0d6efd;">
|
||||
<h1 class="display-6 fw-bold mb-1">Gestión de Usuarios</h1>
|
||||
<p class="text-white-50 mb-0">Administra las cuentas del sistema: edita o elimina usuarios.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-4" style="overflow-y: auto;">
|
||||
|
||||
{% if messages %}
|
||||
<div class="col-12">
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-success py-2 small mb-0">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body p-4">
|
||||
|
||||
<form method="get" class="row g-2 align-items-end mb-4">
|
||||
<div class="col-12 col-md-3">
|
||||
<label class="form-label small text-secondary mb-1">Rol</label>
|
||||
<select name="rol" class="form-select">
|
||||
<option value="">Todos los roles</option>
|
||||
{% for value, label in rol_choices %}
|
||||
<option value="{{ value }}" {% if filtro_rol == value %}selected{% endif %}>{{ label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3">
|
||||
<label class="form-label small text-secondary mb-1">Área Técnica</label>
|
||||
<select name="especialidad" class="form-select">
|
||||
<option value="">Todas las áreas</option>
|
||||
{% for value, label in especialidad_choices %}
|
||||
<option value="{{ value }}" {% if filtro_especialidad == value %}selected{% endif %}>{{ label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-4">
|
||||
<label class="form-label small text-secondary mb-1">Apellido</label>
|
||||
<input type="text" name="apellido" class="form-control" placeholder="Buscar por apellido..." value="{{ filtro_apellido }}">
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-2 d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary fw-bold flex-grow-1">Buscar</button>
|
||||
{% if filtro_rol or filtro_especialidad or filtro_apellido %}
|
||||
<a href="{% url 'gestion_usuarios' %}" class="btn btn-outline-secondary" title="Limpiar filtros">×</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Usuario</th>
|
||||
<th>Nombre</th>
|
||||
<th>Apellidos</th>
|
||||
<th>Email</th>
|
||||
<th>Área Técnica</th>
|
||||
<th>Rol</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for usuario in usuarios %}
|
||||
<tr>
|
||||
<td>{{ usuario.username }}</td>
|
||||
<td>{{ usuario.first_name }}</td>
|
||||
<td>{{ usuario.last_name }}</td>
|
||||
<td>{{ usuario.email }}</td>
|
||||
<td>{{ usuario.get_especialidad_display|default:"—" }}</td>
|
||||
<td>{{ usuario.get_rol_display }}</td>
|
||||
<td class="d-flex gap-2">
|
||||
<a href="{% url 'editar_usuario' usuario.pk %}" class="btn btn-sm btn-outline-primary">Editar</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" data-bs-toggle="modal" data-bs-target="#eliminarModal{{ usuario.pk }}">Eliminar</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<div class="modal fade" id="eliminarModal{{ usuario.pk }}" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Confirmar eliminación</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
¿Seguro que quieres eliminar al usuario <strong>{{ usuario.username }}</strong>? Esta acción no se puede deshacer.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button>
|
||||
<form method="post" action="{% url 'eliminar_usuario' usuario.pk %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-danger fw-bold">Eliminar</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="7" class="text-center text-secondary py-4">No se han encontrado usuarios con los filtros seleccionados.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue