Commit 7e525a06b1fa213984de07f65a573920a15027bc
1 parent
5d8300b3ab
Exists in
master
creada la gestion de los usuarios y la permisologia de vista de los servicios a traves del ROL
Showing
13 changed files
with
239 additions
and
88 deletions
Show diff stats
app/Resources/views/base_app.html.twig
| ... | ... | @@ -51,10 +51,10 @@ |
| 51 | 51 | <div class="subnavbar-inner"> |
| 52 | 52 | <div class="container"> |
| 53 | 53 | <ul class="mainnav"> |
| 54 | - <li {% if (app.request.attributes.get('_route') == 'cea_index') %} class="active" {% endif %}><a href="{{path('cea_index')}}"><i class="fa fa-list"></i><span>Principal</span> </a> </li> | |
| 54 | + <li {% if (app.request.attributes.get('_route') == 'cea_index') %} class="active" {% endif %}><a href="{{path('cea_index')}}"><i class="fa fa-leaf"></i><span>Principal</span> </a> </li> | |
| 55 | 55 | {% if is_granted('ROLE_ADSCRITO') %} |
| 56 | 56 | <li class="dropdown"> |
| 57 | - <a class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-dashboard"></i> | |
| 57 | + <a class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-gears"></i> | |
| 58 | 58 | <span>Servicios Docente</span> <b class="caret"></b> |
| 59 | 59 | </a> |
| 60 | 60 | <ul class="dropdown-menu"> |
| ... | ... | @@ -66,8 +66,8 @@ |
| 66 | 66 | {% endif %} |
| 67 | 67 | </ul> |
| 68 | 68 | <ul class="pull-right"> |
| 69 | - {% if is_granted('ROLE_COORDINADOR_NACIONAL') %} | |
| 70 | - <li class="dropdown"><a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-dashboard"></i><span>Ver Adscripciones</span> <b class="caret"></b></a> | |
| 69 | + {% if is_granted('ROLE_COORDINADOR_REGIONAL') %} | |
| 70 | + <li class="dropdown"><a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-list"></i><span>Ver Adscripciones</span> <b class="caret"></b></a> | |
| 71 | 71 | <ul class="dropdown-menu"> |
| 72 | 72 | <li> <a data-toggle="modal" data-target="#buscarAdscripcion">Buscar Adscripcion</a></li> |
| 73 | 73 | <li><a href="{{ path('cea_adscripciones')}}">En espera de Aprobación</a></li> |
| ... | ... | @@ -76,7 +76,7 @@ |
| 76 | 76 | </ul> |
| 77 | 77 | </li> |
| 78 | 78 | |
| 79 | - <li class="dropdown"><a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-dashboard"></i><span>Ver Solicitudes</span> <b class="caret"></b></a> | |
| 79 | + <li class="dropdown"><a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-group"></i><span>Ver Solicitudes</span> <b class="caret"></b></a> | |
| 80 | 80 | <ul class="dropdown-menu"> |
| 81 | 81 | <li> <a data-toggle="modal" data-target="#buscarServicios">Buscar Servicios</a></li> |
| 82 | 82 | <li><a href="{{ path('cea_servicios', {'tipo' : 'antiguedad'})}}">En espera de Aprobación</a></li> |
| ... | ... | @@ -84,8 +84,12 @@ |
| 84 | 84 | <li><a href="{{ path('cea_servicios', { 'tipo' : 'antiguedad', 'estatus': 3 })}}">Rechazadas</a></li> |
| 85 | 85 | </ul> |
| 86 | 86 | </li> |
| 87 | - </ul> | |
| 88 | 87 | {% endif %} |
| 88 | + {% if is_granted('ROLE_ADMINISTRADOR') %} | |
| 89 | + <li {% if (app.request.attributes.get('_route') == 'admin_usuarios_index') %} class="active" {% endif %}><a href="{{path('admin_usuarios_index')}}"><i class="fa fa-user"></i><span>Gestión de Usuarios</span> </a> </li> | |
| 90 | + {% endif %} | |
| 91 | + </ul> | |
| 92 | + | |
| 89 | 93 | </div> |
| 90 | 94 | <!-- /container --> |
| 91 | 95 | </div> | ... | ... |
app/Resources/views/cea/servicios.html.twig
| ... | ... | @@ -21,6 +21,8 @@ |
| 21 | 21 | </thead> |
| 22 | 22 | <tbody> |
| 23 | 23 | {% for servicio in servicios %} |
| 24 | + {% if not is_granted('ROLE_COORDINADOR_NACIONAL') %} | |
| 25 | + {% if servicio.idRolInstitucion.idInstitucion.idEjeParroquia.idEje == app.user.idRolInstitucion.idInstitucion.idEjeParroquia.idEje %} | |
| 24 | 26 | <tr> |
| 25 | 27 | <td>{{servicio.id}}</td> |
| 26 | 28 | <td> |
| ... | ... | @@ -31,7 +33,7 @@ |
| 31 | 33 | |
| 32 | 34 | </td> |
| 33 | 35 | <td> |
| 34 | - {{servicio.idRolInstitucion.IdRol.IdAreaPersona.nombre}} | |
| 36 | + {{servicio.idRolInstitucion.IdRol.IdAreaInstitucion.nombre}} | |
| 35 | 37 | </td> |
| 36 | 38 | <td> |
| 37 | 39 | {{servicio.idRolInstitucion.idInstitucion.idEjeParroquia.IdEje}} |
| ... | ... | @@ -44,6 +46,33 @@ |
| 44 | 46 | </td> |
| 45 | 47 | |
| 46 | 48 | </tr> |
| 49 | + {%endif%} | |
| 50 | + {%else%} | |
| 51 | + | |
| 52 | + <tr> | |
| 53 | + <td>{{servicio.id}}</td> | |
| 54 | + <td> | |
| 55 | + {{servicio.idRolInstitucion.idRol.idPersona.PrimerNombre}} | |
| 56 | + {{servicio.idRolInstitucion.idRol.idPersona.PrimerApellido}} | |
| 57 | + ( {{servicio.idRolInstitucion}} ) | |
| 58 | + | |
| 59 | + | |
| 60 | + </td> | |
| 61 | + <td> | |
| 62 | + {{servicio.idRolInstitucion.IdRol.IdAreaInstitucion.nombre}} | |
| 63 | + </td> | |
| 64 | + <td> | |
| 65 | + {{servicio.idRolInstitucion.idInstitucion.idEjeParroquia.IdEje}} | |
| 66 | + </td> | |
| 67 | + <td>{{servicio.idRolInstitucion.idInstitucion.idEjeParroquia.idParroquia.idMunicipio.idEstado}} </td> | |
| 68 | + <td> | |
| 69 | + <a href="{{ path('cea_servicio_show', { 'id': servicio.id }) }}" class="btn btn-xs btn-info"><i class="fa fa-eye"> </i></a> | |
| 70 | + <a href="javascript:;" class="btn btn-xs btn-success"><i class="fa fa-check"> </i></a> | |
| 71 | + <a href="javascript:;" class="btn btn-danger btn-xs"><i class="fa fa-times"> </i></a></td> | |
| 72 | + </td> | |
| 73 | + | |
| 74 | + </tr> | |
| 75 | + {%endif%} | |
| 47 | 76 | {% endfor %} |
| 48 | 77 | |
| 49 | 78 | </tbody> | ... | ... |
app/Resources/views/cea/solicitudes.html.twig
| ... | ... | @@ -21,29 +21,58 @@ |
| 21 | 21 | </thead> |
| 22 | 22 | <tbody> |
| 23 | 23 | {% for adscripcion in adscripciones %} |
| 24 | - <tr> | |
| 25 | - <td>{{adscripcion.id}}</td> | |
| 26 | - <td> | |
| 27 | - {{adscripcion.idRolInstitucion.idRol.idPersona.PrimerNombre}} | |
| 28 | - {{adscripcion.idRolInstitucion.idRol.idPersona.PrimerApellido}} | |
| 29 | - ( {{adscripcion.idRolInstitucion}} ) | |
| 30 | - | |
| 31 | - | |
| 32 | - </td> | |
| 33 | - <td> | |
| 34 | - {{adscripcion.idRolInstitucion.IdRol.IdAreaPersona.nombre}} | |
| 35 | - </td> | |
| 36 | - <td> | |
| 37 | - {{adscripcion.idRolInstitucion.idInstitucion.idEjeParroquia.IdEje}} | |
| 38 | - </td> | |
| 39 | - <td>{{adscripcion.idRolInstitucion.idInstitucion.idEjeParroquia.idParroquia.idMunicipio.idEstado}} </td> | |
| 40 | - <td> | |
| 41 | - <a href="{{ path('cea_solicitudes_show', { 'id': adscripcion.id }) }}" class="btn btn-xs btn-info"><i class="fa fa-eye"> </i></a> | |
| 42 | - <a href="javascript:;" class="btn btn-xs btn-success"><i class="fa fa-check"> </i></a> | |
| 43 | - <a href="javascript:;" class="btn btn-danger btn-xs"><i class="fa fa-times"> </i></a></td> | |
| 44 | - </td> | |
| 45 | - | |
| 46 | - </tr> | |
| 24 | + {% if not is_granted('ROLE_COORDINADOR_NACIONAL') %} | |
| 25 | + {% if adscripcion.idRolInstitucion.idInstitucion.idEjeParroquia.idEje == app.user.idRolInstitucion.idInstitucion.idEjeParroquia.idEje %} | |
| 26 | + <tr> | |
| 27 | + <td>{{adscripcion.id}}</td> | |
| 28 | + <td> | |
| 29 | + {{adscripcion.idRolInstitucion.idRol.idPersona.PrimerNombre}} | |
| 30 | + {{adscripcion.idRolInstitucion.idRol.idPersona.PrimerApellido}} | |
| 31 | + ( {{adscripcion.idRolInstitucion}} ) | |
| 32 | + | |
| 33 | + | |
| 34 | + </td> | |
| 35 | + <td> | |
| 36 | + {{adscripcion.idRolInstitucion.IdRol.IdAreaInstitucion.nombre}} | |
| 37 | + </td> | |
| 38 | + <td> | |
| 39 | + {{adscripcion.idRolInstitucion.idInstitucion.idEjeParroquia.IdEje}} | |
| 40 | + </td> | |
| 41 | + <td>{{adscripcion.idRolInstitucion.idInstitucion.idEjeParroquia.idParroquia.idMunicipio.idEstado}} </td> | |
| 42 | + <td> | |
| 43 | + <a href="{{ path('cea_solicitudes_show', { 'id': adscripcion.id }) }}" class="btn btn-xs btn-info"><i class="fa fa-eye"> </i></a> | |
| 44 | + <a href="javascript:;" class="btn btn-xs btn-success"><i class="fa fa-check"> </i></a> | |
| 45 | + <a href="javascript:;" class="btn btn-danger btn-xs"><i class="fa fa-times"> </i></a></td> | |
| 46 | + </td> | |
| 47 | + | |
| 48 | + </tr> | |
| 49 | + {% endif %} | |
| 50 | + {% else %} | |
| 51 | + <tr> | |
| 52 | + <td>{{adscripcion.id}}</td> | |
| 53 | + <td> | |
| 54 | + {{adscripcion.idRolInstitucion.idRol.idPersona.PrimerNombre}} | |
| 55 | + {{adscripcion.idRolInstitucion.idRol.idPersona.PrimerApellido}} | |
| 56 | + ( {{adscripcion.idRolInstitucion}} ) | |
| 57 | + | |
| 58 | + | |
| 59 | + </td> | |
| 60 | + <td> | |
| 61 | + {{adscripcion.idRolInstitucion.IdRol.IdAreaInstitucion.nombre}} | |
| 62 | + </td> | |
| 63 | + <td> | |
| 64 | + {{adscripcion.idRolInstitucion.idInstitucion.idEjeParroquia.IdEje}} | |
| 65 | + </td> | |
| 66 | + <td>{{adscripcion.idRolInstitucion.idInstitucion.idEjeParroquia.idParroquia.idMunicipio.idEstado}} </td> | |
| 67 | + <td> | |
| 68 | + <a href="{{ path('cea_solicitudes_show', { 'id': adscripcion.id }) }}" class="btn btn-xs btn-info"><i class="fa fa-eye"> </i></a> | |
| 69 | + <a href="javascript:;" class="btn btn-xs btn-success"><i class="fa fa-check"> </i></a> | |
| 70 | + <a href="javascript:;" class="btn btn-danger btn-xs"><i class="fa fa-times"> </i></a></td> | |
| 71 | + </td> | |
| 72 | + | |
| 73 | + </tr> | |
| 74 | + | |
| 75 | + {% endif %} | |
| 47 | 76 | {% endfor %} |
| 48 | 77 | |
| 49 | 78 | </tbody> | ... | ... |
app/Resources/views/usuarios/edit.html.twig
| 1 | -{% extends 'base.html.twig' %} | |
| 1 | +{% extends 'base_app.html.twig' %} | |
| 2 | 2 | |
| 3 | 3 | {% block body %} |
| 4 | - <h1>Usuarios edit</h1> | |
| 4 | + <div class="container"> | |
| 5 | + {% form_theme edit_form 'bootstrap_3_horizontal_layout.html.twig' %} | |
| 6 | + <h1>Edición de Usuarios</h1> | |
| 5 | 7 | |
| 6 | 8 | {{ form_start(edit_form) }} |
| 7 | 9 | {{ form_widget(edit_form) }} |
| ... | ... | @@ -18,4 +20,5 @@ |
| 18 | 20 | {{ form_end(delete_form) }} |
| 19 | 21 | </li> |
| 20 | 22 | </ul> |
| 23 | + </div> | |
| 21 | 24 | {% endblock %} | ... | ... |
app/Resources/views/usuarios/index.html.twig
| 1 | -{% extends 'base.html.twig' %} | |
| 1 | +{% extends 'base_app.html.twig' %} | |
| 2 | 2 | |
| 3 | 3 | {% block body %} |
| 4 | - <h1>Usuarios list</h1> | |
| 5 | - | |
| 6 | - <table> | |
| 7 | - <thead> | |
| 8 | - <tr> | |
| 9 | - <th>Username</th> | |
| 10 | - <th>Password</th> | |
| 11 | - <th>Id</th> | |
| 12 | - <th>Actions</th> | |
| 13 | - </tr> | |
| 14 | - </thead> | |
| 15 | - <tbody> | |
| 4 | + <div class="container"> | |
| 5 | + <div class="widget widget-table action-table"> | |
| 6 | + <div class="widget-header"> | |
| 7 | + <div class="row"> | |
| 8 | + <div class="col-sm-9"><i class="fa fa-list"></i> | |
| 9 | + <h3>Listado de usuarios Registrados</h3></div> | |
| 10 | + <div class="col-sm-2"><input type="text" class="form-control"></div> | |
| 11 | + </div> | |
| 12 | + </div> | |
| 13 | + <div class="widget-content"> | |
| 14 | + <table class="table table-striped table-bordered table-condensed"> | |
| 15 | + <thead> | |
| 16 | + <tr> | |
| 17 | + <th>Id</th> | |
| 18 | + <th>Nombres y Apellidos</th> | |
| 19 | + <th>Eje</th> | |
| 20 | + <th>Estado</th> | |
| 21 | + <th>Nombre de Usuario</th> | |
| 22 | + <th>Acciones</th> | |
| 23 | + </tr> | |
| 24 | + </thead> | |
| 25 | + <tbody> | |
| 16 | 26 | {% for usuario in usuarios %} |
| 17 | 27 | <tr> |
| 18 | - <td><a href="{{ path('admin_usuarios_show', { 'id': usuario.id }) }}">{{ usuario.username }}</a></td> | |
| 19 | - <td>{{ usuario.password }}</td> | |
| 20 | 28 | <td>{{ usuario.id }}</td> |
| 29 | + <td>{{ usuario.idRolInstitucion.idRol.idPersona.primerNombre }}, {{ usuario.idRolInstitucion.idRol.idPersona.primerApellido }}</td> | |
| 30 | + <td>{{usuario.idRolInstitucion.idInstitucion.idEjeParroquia.idEje}}</td> | |
| 31 | + <td>{{usuario.idRolInstitucion.idInstitucion.idEjeParroquia.idParroquia.idMunicipio.idEstado}}</td> | |
| 21 | 32 | <td> |
| 22 | - <ul> | |
| 23 | - <li> | |
| 24 | - <a href="{{ path('admin_usuarios_show', { 'id': usuario.id }) }}">show</a> | |
| 25 | - </li> | |
| 26 | - <li> | |
| 27 | - <a href="{{ path('admin_usuarios_edit', { 'id': usuario.id }) }}">edit</a> | |
| 28 | - </li> | |
| 29 | - </ul> | |
| 33 | + <a href="{{ path('admin_usuarios_show', { 'id': usuario.id }) }}">{{ usuario.username }}</a> | |
| 34 | + </td> | |
| 35 | + <td> | |
| 36 | + <a href="{{ path('admin_usuarios_show', { 'id': usuario.id }) }}" class="btn btn-xs btn-info"><i class="fa fa-eye" ></i></a> | |
| 37 | + <a href="{{ path('admin_usuarios_edit', { 'id': usuario.id }) }}" class="btn btn-xs btn-primary"><i class="fa fa-edit"></i></a> | |
| 30 | 38 | </td> |
| 31 | 39 | </tr> |
| 32 | 40 | {% endfor %} |
| ... | ... | @@ -38,4 +46,5 @@ |
| 38 | 46 | <a href="{{ path('admin_usuarios_new') }}">Create a new entry</a> |
| 39 | 47 | </li> |
| 40 | 48 | </ul> |
| 49 | + </div> | |
| 41 | 50 | {% endblock %} | ... | ... |
app/Resources/views/usuarios/new.html.twig
| 1 | -{% extends 'base.html.twig' %} | |
| 1 | +{% extends 'base_app.html.twig' %} | |
| 2 | 2 | |
| 3 | 3 | {% block body %} |
| 4 | - <h1>Usuarios creation</h1> | |
| 5 | - | |
| 4 | + <div class="container"> | |
| 5 | + <h1>Nuevo Usuario</h1> | |
| 6 | +{% form_theme form 'bootstrap_3_horizontal_layout.html.twig' %} | |
| 6 | 7 | {{ form_start(form) }} |
| 7 | 8 | {{ form_widget(form) }} |
| 8 | 9 | <input type="submit" value="Create" /> |
| ... | ... | @@ -13,4 +14,5 @@ |
| 13 | 14 | <a href="{{ path('admin_usuarios_index') }}">Back to the list</a> |
| 14 | 15 | </li> |
| 15 | 16 | </ul> |
| 17 | + </div> | |
| 16 | 18 | {% endblock %} | ... | ... |
app/Resources/views/usuarios/show.html.twig
| 1 | -{% extends 'base.html.twig' %} | |
| 1 | +{% extends 'base_app.html.twig' %} | |
| 2 | 2 | |
| 3 | 3 | {% block body %} |
| 4 | - <h1>Usuarios</h1> | |
| 5 | - | |
| 6 | - <table> | |
| 7 | - <tbody> | |
| 4 | + <div class="container"> | |
| 5 | + <div class="widget widget-table action-table"> | |
| 6 | + <div class="widget-header"> | |
| 7 | + <div class="row"> | |
| 8 | + <div class="col-sm-9"><i class="fa fa-list"></i> | |
| 9 | + <h3>Mostrando usuario</h3></div> | |
| 10 | + <div class="col-sm-2"><input type="text" class="form-control"></div> | |
| 11 | + </div> | |
| 12 | + </div> | |
| 13 | + <div class="widget-content"> | |
| 14 | + <table class="table table-striped table-bordered table-condensed"> | |
| 15 | + <thead></thead> | |
| 8 | 16 | <tr> |
| 9 | 17 | <th>Username</th> |
| 10 | 18 | <td>{{ usuario.username }}</td> |
| ... | ... | @@ -18,19 +26,18 @@ |
| 18 | 26 | <td>{{ usuario.id }}</td> |
| 19 | 27 | </tr> |
| 20 | 28 | </tbody> |
| 29 | + </table> | |
| 21 | 30 | </table> |
| 31 | + | |
| 32 | + | |
| 33 | + {{ form_start(delete_form) }} | |
| 34 | + <a href="{{ path('admin_usuarios_index') }}" class="btn btn-sm btn-warning">Regresar</a> | |
| 35 | + <a href="{{ path('admin_usuarios_edit', { 'id': usuario.id }) }}" class="btn btn-sm btn-info">Modificar</a> | |
| 36 | + <input type="submit" value="Delete" class="btn btn-sm btn-danger"> | |
| 37 | + {{ form_end(delete_form) }} | |
| 22 | 38 | |
| 23 | - <ul> | |
| 24 | - <li> | |
| 25 | - <a href="{{ path('admin_usuarios_index') }}">Back to the list</a> | |
| 26 | - </li> | |
| 27 | - <li> | |
| 28 | - <a href="{{ path('admin_usuarios_edit', { 'id': usuario.id }) }}">Edit</a> | |
| 29 | - </li> | |
| 30 | - <li> | |
| 31 | - {{ form_start(delete_form) }} | |
| 32 | - <input type="submit" value="Delete"> | |
| 33 | - {{ form_end(delete_form) }} | |
| 34 | - </li> | |
| 35 | - </ul> | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + </div> | |
| 36 | 43 | {% endblock %} | ... | ... |
app/config/security.yml
| ... | ... | @@ -5,7 +5,7 @@ security: |
| 5 | 5 | AppBundle\Entity\Usuarios: |
| 6 | 6 | algorithm: bcrypt |
| 7 | 7 | role_hierarchy: |
| 8 | - ROLE_COORDINADOR_NACIONAL: [ROLE_COORDINADOR] | |
| 8 | + ROLE_COORDINADOR_NACIONAL: [ROLE_COORDINADOR_REGIONAL] | |
| 9 | 9 | |
| 10 | 10 | # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers |
| 11 | 11 | providers: | ... | ... |
src/AppBundle/Controller/AdscripcionController.php
| ... | ... | @@ -217,7 +217,7 @@ class AdscripcionController extends Controller |
| 217 | 217 | * |
| 218 | 218 | * @Route("/solicitudes/adscripcion/{estatus}", name="cea_adscripciones") |
| 219 | 219 | * @Method({"GET", "POST"}) |
| 220 | - * @Security("has_role('ROLE_COORDINADOR')") | |
| 220 | + * @Security("has_role('ROLE_COORDINADOR_REGIONAL')") | |
| 221 | 221 | */ |
| 222 | 222 | public function verSolicitudesAdscripcionAction($estatus = 2, Request $request) |
| 223 | 223 | { |
| ... | ... | @@ -274,7 +274,7 @@ class AdscripcionController extends Controller |
| 274 | 274 | * |
| 275 | 275 | * @Route("/solicitudes/{id}", name="cea_solicitudes_show") |
| 276 | 276 | * @Method("GET") |
| 277 | - * @Security("has_role('ROLE_COORDINADOR')") | |
| 277 | + * @Security("has_role('ROLE_COORDINADOR_REGIONAL')") | |
| 278 | 278 | */ |
| 279 | 279 | public function solicitudesAdscripcionShowAction(Adscripcion $adscripcion) |
| 280 | 280 | { |
| ... | ... | @@ -295,7 +295,7 @@ class AdscripcionController extends Controller |
| 295 | 295 | * |
| 296 | 296 | * @Route("/solicitudes/actualizar/{id}/{estatus}", name="cea_solicitudes_actualizar") |
| 297 | 297 | * @Method({"GET", "POST"}) |
| 298 | - * @Security("has_role('ROLE_COORDINADOR')") | |
| 298 | + * @Security("has_role('ROLE_COORDINADOR_REGIONAL')") | |
| 299 | 299 | */ |
| 300 | 300 | public function solicitudesAdscripcionEditAction(Adscripcion $adscripcion, $estatus) |
| 301 | 301 | { | ... | ... |
src/AppBundle/Controller/UsuariosController.php
| ... | ... | @@ -12,7 +12,7 @@ use AppBundle\Form\UsuariosType; |
| 12 | 12 | /** |
| 13 | 13 | * Usuarios controller. |
| 14 | 14 | * |
| 15 | - * @Route("/admin/usuarios") | |
| 15 | + * @Route("ceapp/admin/usuarios") | |
| 16 | 16 | */ |
| 17 | 17 | class UsuariosController extends Controller |
| 18 | 18 | { |
| ... | ... | @@ -42,9 +42,10 @@ class UsuariosController extends Controller |
| 42 | 42 | public function newAction(Request $request) |
| 43 | 43 | { |
| 44 | 44 | $usuario = new Usuarios(); |
| 45 | - $form = $this->createForm('AppBundle\Form\UsuariosType', $usuario); | |
| 45 | + $form = $this->createForm('AppBundle\Form\UsuarioNuevoType', $usuario); | |
| 46 | 46 | $form->handleRequest($request); |
| 47 | - | |
| 47 | + $pass = $usuario->getPlainPassword(); | |
| 48 | + if(!$pass) $usuario->setPlainPassword ("0000"); | |
| 48 | 49 | if ($form->isSubmitted() && $form->isValid()) { |
| 49 | 50 | $password = $this->get('security.password_encoder') |
| 50 | 51 | ->encodePassword($usuario, $usuario->getPlainPassword()); | ... | ... |
src/AppBundle/Entity/Usuarios.php
src/AppBundle/Form/UsuarioNuevoType.php
| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace AppBundle\Form; | |
| 4 | + | |
| 5 | +use Symfony\Component\Form\AbstractType; | |
| 6 | +use Symfony\Component\Form\FormBuilderInterface; | |
| 7 | +use Symfony\Component\OptionsResolver\OptionsResolver; | |
| 8 | +use Symfony\Component\Form\Extension\Core\Type\RepeatedType; | |
| 9 | +use Symfony\Component\Form\Extension\Core\Type\PasswordType; | |
| 10 | +use Symfony\Component\Form\Extension\Core\Type\EmailType; | |
| 11 | + | |
| 12 | +use Symfony\Component\Validator\Constraints\Email; | |
| 13 | +use Symfony\Component\Validator\Constraints\NotBlank; | |
| 14 | +use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |
| 15 | + | |
| 16 | +class UsuarioNuevoType extends AbstractType | |
| 17 | +{ | |
| 18 | + /** | |
| 19 | + * @param FormBuilderInterface $builder | |
| 20 | + * @param array $options | |
| 21 | + */ | |
| 22 | + public function buildForm(FormBuilderInterface $builder, array $options) | |
| 23 | + { | |
| 24 | + $builder | |
| 25 | + ->add('username') | |
| 26 | + ->add('idRolInstitucion',EntityType::class, array( | |
| 27 | + 'class' => 'AppBundle:RolInstitucion', | |
| 28 | + 'choice_label' => 'getIdRol.getIdPersona', | |
| 29 | + )) | |
| 30 | + ->add('rol', EntityType::class, array( | |
| 31 | + 'class' => 'AppBundle:Role', | |
| 32 | + 'multiple' => TRUE, | |
| 33 | + 'expanded' => TRUE, | |
| 34 | + )) | |
| 35 | + ->add('email', EmailType::class, array( | |
| 36 | + 'attr' => array('placeholder' => 'Dirección de Correo...'), | |
| 37 | + 'constraints' => array( | |
| 38 | + new NotBlank(), | |
| 39 | + new Email() | |
| 40 | + ) | |
| 41 | + )) | |
| 42 | + ->add('plainPassword', RepeatedType::class, array( | |
| 43 | + 'type' => PasswordType::class, | |
| 44 | + 'first_options' => array('label' => 'Password'), | |
| 45 | + 'second_options' => array('label' => 'Repeat Password'), | |
| 46 | + )) | |
| 47 | + ; | |
| 48 | + } | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * @param OptionsResolver $resolver | |
| 52 | + */ | |
| 53 | + public function configureOptions(OptionsResolver $resolver) | |
| 54 | + { | |
| 55 | + $resolver->setDefaults(array( | |
| 56 | + 'data_class' => 'AppBundle\Entity\Usuarios' | |
| 57 | + )); | |
| 58 | + } | |
| 59 | +} | ... | ... |
src/AppBundle/Form/UsuariosType.php
| ... | ... | @@ -7,6 +7,7 @@ use Symfony\Component\Form\FormBuilderInterface; |
| 7 | 7 | use Symfony\Component\OptionsResolver\OptionsResolver; |
| 8 | 8 | use Symfony\Component\Form\Extension\Core\Type\RepeatedType; |
| 9 | 9 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; |
| 10 | +use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |
| 10 | 11 | |
| 11 | 12 | class UsuariosType extends AbstractType |
| 12 | 13 | { |
| ... | ... | @@ -18,13 +19,20 @@ class UsuariosType extends AbstractType |
| 18 | 19 | { |
| 19 | 20 | $builder |
| 20 | 21 | ->add('username') |
| 21 | - ->add('idRolInstitucion') | |
| 22 | - ->add('rol') | |
| 23 | - ->add('plainPassword', RepeatedType::class, array( | |
| 22 | + /*->add('idRolInstitucion',EntityType::class, array( | |
| 23 | + 'class' => 'AppBundle:RolInstitucion', | |
| 24 | + 'choice_label' => 'getIdRol.getIdPersona', | |
| 25 | + ))*/ | |
| 26 | + ->add('rol', EntityType::class, array( | |
| 27 | + 'class' => 'AppBundle:Role', | |
| 28 | + 'multiple' => TRUE, | |
| 29 | + 'expanded' => TRUE, | |
| 30 | + )) | |
| 31 | + /*->add('plainPassword', RepeatedType::class, array( | |
| 24 | 32 | 'type' => PasswordType::class, |
| 25 | 33 | 'first_options' => array('label' => 'Password'), |
| 26 | 34 | 'second_options' => array('label' => 'Repeat Password'), |
| 27 | - )) | |
| 35 | + ))*/ | |
| 28 | 36 | ; |
| 29 | 37 | } |
| 30 | 38 | ... | ... |