Añadinedo limitaciones l los controladores para que un aluno, usuario normal, no puede borra, editar o crear cosas que no debe tener acceso. Es una medida pesonalizada como no podria conseguir que funcciona medidas normales @RolesAllowed y el alumnos solo puede editar sus datos y nada mas. Puede ver todas las listas pero no tiene autorización a borar o crear. Pero solo puede editar su informacion
parent
624094c58a
commit
9d8830a10e
@ -0,0 +1,205 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Creacion: Alumno</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Añadir Alumno<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/contacto/save}" method="post" enctype="multipart/form-data" th:object="${alumno}">
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="1" maxlength="100" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="cif">Apellido</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{apellido}" required minlength="1" maxlength="100" title="Entra un nombre" class="form-control" id="cif">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="apellido2">Apellido2</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{apellido2}" required minlength="1" maxlength="100" class="form-control" id="apellido2">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="fechaNacimiento">Fecha de Nacimiento</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="date" th:field="*{fechaNacimiento}" required class="form-control" id="fechaNacimiento" title="Introduce fecha">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="genero">Genero</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{genero}" class="form-control" id="genero" required>
|
||||
<option value="">Selecciona un genero</option>
|
||||
<option value="Mujer">Mujer</option>
|
||||
<option value="Varon">Varon</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nia">Nia</label>
|
||||
<div class = "col-sm-9">
|
||||
<!--TODO: Añadir validacion de nia-->
|
||||
<input type="text" th:field="*{nia}" required minlength="8" maxlength="8" title="Entra un nia correcto" class="form-control" id="nia">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="dni">DNI/NIE</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{dni}" required minlength="8" maxlength="8" class="form-control" id="dni" title="Introduce DNI/NIE">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="correo">Correo</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="email" th:field="*{correo}" required minlength="5" maxlength="100" class="form-control" id="correo" title="Introduce correo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="correo2">Correo2</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="email" th:field="*{correo2}" required minlength="5" maxlength="100" class="form-control" id="correo2" title="Introduce correo alternativo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nacionalidad">Nacionalidad</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{nacionalidad}" class="form-control" id="nacionalidad" title="Introduce nacionalidad">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="keywords">Keywords</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{keywords}" class="form-control" id="keywords" title="Introduce keywords">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ciclos -->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="ciclo">Ciclo</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{ciclo.id}" class="form-control" id="ciclo">
|
||||
<option th:each="ciclo : ${ciclos}" th:value="${ciclo.id}" th:text="${ciclo.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skills-container">
|
||||
<h2>Select Skills</h2>
|
||||
<select id="skills" multiple>
|
||||
<option th:each="skill : ${skills}" th:value="${skill.id}" th:text="${skill.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#skills').select2();
|
||||
});
|
||||
|
||||
function goBack() {
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var formDataArray = $(this).serializeArray();
|
||||
formDataArray.push({name: 'ciclo', value: $('#ciclo').val()});
|
||||
formDataArray.push({name: 'skills', value: $('#skills').val()});
|
||||
|
||||
$.ajax({
|
||||
url: '/alumno/save',
|
||||
type: 'post',
|
||||
data: $.param(formDataArray),
|
||||
success: function (message) {
|
||||
if(message === "El alumno fue guardado con exito") {
|
||||
alert("El alumno fue guardado con exito")
|
||||
window.history.go(-1);
|
||||
} else if(message === "El alumno ya existe"){
|
||||
alert("El alumno ya existe");
|
||||
window.history.go(-1);
|
||||
}else{
|
||||
alert("Error, consulte a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue