Commit f6b1c213 authored by D’jalmar Gutierrez Titirico's avatar D’jalmar Gutierrez Titirico 🚲

Merge branch '3-Desarrollo-Cargos-Postulaciones-Categorias-Comentarios' into desarrollo

Conflicts:
	server/api/postulacion/postulacion.controller.js
parents 23ff89a9 a33f6898
Modulo Personal
===================
Cargos
------
> **Titulo**
Mostrar los Cargos
> **URL**
/cargos
> **Metodo**
<kbd>GET</kbd>
> **Respuesta correcta**
> **Codigo:** 200
**Contenido:**
```json
[
{
"_id": 1,
"nombre": "Director general",
"fecha_creacion": "2016-03-14T15:06:36.051Z",
"fecha_modificacion": "2016-03-14T15:06:36.051Z"
},
{
"_id": 2,
"nombre": "Jefe de personal",
"fecha_creacion": "2016-03-14T15:28:20.063Z",
"fecha_modificacion": "2016-03-14T15:28:20.063Z"
}
]
```
> **Respuesta de error**
**Codigo:** 500
**Contenido:** Error en el servidor.
**Codigo:** 4xx
**Contenido:** Error en el servidor.
**Crear un cargo**
----
* **URL**
/cargos
* **Método:**
`POST`
* **Parametros del cuerpo**
``{
"nombre": "Director general"
}``
* **Respuesta correcta:**
<_What should the status code be on success and is there any returned data? This is useful when people need to to know what their callbacks should expect!_>
* **Code:** 200
**Content:**
```javascript
{
"_id": 1,
"nombre": "Director general",
"fecha_modificacion": "2016-03-14T15:06:36.051Z",
"fecha_creacion": "2016-03-14T15:06:36.051Z"
}
```
* **Error Response:**
<_Most endpoints will have many ways they can fail. From unauthorized access, to wrongful parameters etc. All of those should be liste d here. It might seem repetitive, but it helps prevent assumptions from being made where they should be._>
* **Code:** 401 UNAUTHORIZED <br />
**Content:** `{ error : "Log in" }`
OR
* **Code:** 422 UNPROCESSABLE ENTRY <br />
**Content:** `{ error : "Email Invalid" }`
* **Sample Call:**
<_Just a sample call to your endpoint in a runnable format ($.ajax call or a curl request) - this makes life easier and more predictable._>
* **Notes:**
<_This is where all uncertainties, commentary, discussion etc. can go. I recommend timestamping and identifying oneself when leaving comments here._>
......@@ -14,7 +14,15 @@ export default function(sequelize, DataTypes) {
primaryKey: true,
autoIncrement: true
},
nombre: DataTypes.STRING
nombre: {
type: DataTypes.STRING,
allowNull: false,
validate: {
notEmpty: {
msg:'Ingrese un nombre para el cargo'
}
}
}
}, {
schema:'public',
tableName: 'cargo',
......
......@@ -11,6 +11,7 @@
import _ from 'lodash';
import {Comentario} from '../../sqldb';
import {Postulante} from '../../sqldb';
function respondWithResult(res, statusCode) {
statusCode = statusCode || 200;
......@@ -111,3 +112,17 @@ export function destroy(req, res) {
.then(removeEntity(res))
.catch(handleError(res));
}
export function comentarios(req, res) {
Postulante.find({
where: {
_id: req.params.id
}
})
.then(handleEntityNotFound(res))
.then(function (postulante) {
postulante.getComentarios()
.then(respondWithResult(res))
})
.catch(handleError(res));
}
......@@ -14,7 +14,15 @@ export default function(sequelize, DataTypes) {
primaryKey: true,
autoIncrement: true
},
contenido: DataTypes.STRING
contenido: {
type: DataTypes.TEXT,
allowNull:false,
validate:{
notEmpty:{
msg:'Por favor ingrese un comentario'
}
}
}
}, {
schema: 'public',
tableName: 'comentario',
......
......@@ -12,4 +12,6 @@ router.put('/:id', controller.update);
router.patch('/:id', controller.update);
router.delete('/:id', controller.destroy);
router.get('/postulante/:id',controller.comentarios);
module.exports = router;
......@@ -11,6 +11,8 @@ router.post('/', controller.create);
router.put('/:id', controller.update);
router.patch('/:id', controller.update);
router.delete('/:id', controller.destroy);
router.get('/postulante/:id',controller.postulaciones);
router.get('/cargo/:id',controller.postulantes);
module.exports = router;
......@@ -11,6 +11,8 @@
import _ from 'lodash';
import {Postulacion} from '../../sqldb';
import {Postulante} from '../../sqldb';
import {Cargo} from '../../sqldb';
function respondWithResult(res, statusCode) {
statusCode = statusCode || 200;
......@@ -103,21 +105,24 @@ export function update(req, res) {
// Deletes a Postulacion from the DB
export function destroy(req, res) {
Postulacion.find({
where: {
_id: req.params.id
}
})
where: {
_id: req.params.id
}
})
.then(handleEntityNotFound(res))
.then(removeEntity(res))
.catch(handleError(res));
}
///
export function postulante(req, res) {
/**
* Obtiene las postulaciones de un determinado postulante
* @param req
* @param res
*/
export function postulaciones(req, res) {
Postulante.find({
where: {
_id: req.params.idPostulante
_id: req.params.id
}
})
.then(handleEntityNotFound(res))
......@@ -129,3 +134,24 @@ export function postulante(req, res) {
})
.catch(handleError(res));
}
/**
* Obtiene los postulantes a un determinado cargo
* @param req
* @param res
*/
export function postulantes(req, res) {
Cargo.find({
where: {
_id: req.params.id
}
})
.then(handleEntityNotFound(res))
.then(function (cargos) {
cargos.getPostulantes()
.then(function (postulantes) {
return res.json(postulantes);
})
})
.catch(handleError(res));
}
......@@ -8,7 +8,15 @@ export default function(sequelize, DataTypes) {
primaryKey: true,
autoIncrement: true
},
presentacion: DataTypes.TEXT
presentacion: {
type: DataTypes.TEXT,
allowNull:false,
validate:{
notEmpty:{
msg:'Por favor ingrese un mensaje de presentacion'
}
}
}
}, {
schema: 'public',
tableName: 'postulacion',
......
......@@ -14,7 +14,15 @@ export default function(sequelize, DataTypes) {
primaryKey: true,
autoIncrement: true
},
nombre: DataTypes.STRING
nombre: {
type:DataTypes.STRING,
allowNull:false,
validate:{
notEmpty:{
msg:'Por favor ingrese un nombre para el tag'
}
}
}
}, {
schema: 'public',
tableName: 'tag',
......
......@@ -12,4 +12,7 @@ router.put('/:id', controller.update);
router.patch('/:id', controller.update);
router.delete('/:id', controller.destroy);
router.get('/postulante/:id',controller.tags);
router.get('/tags/:id',controller.postulantes);
module.exports = router;
......@@ -11,6 +11,8 @@
import _ from 'lodash';
import {TagPostulante} from '../../sqldb';
import {Postulante} from '../../sqldb';
import {Tag} from '../../sqldb';
function respondWithResult(res, statusCode) {
statusCode = statusCode || 200;
......@@ -111,3 +113,26 @@ export function destroy(req, res) {
.then(removeEntity(res))
.catch(handleError(res));
}
export function tags(req,res) {
Postulante.find({
where: {_id: req.params.id}
})
.then(handleEntityNotFound(res))
.then(function (postulante) {
postulante.getTags()
.then(respondWithResult(res))
})
.catch(handleError(res));
}
export function postulantes(req, res) {
Tag.find({
where: {_id: req.params.id}
})
.then(handleEntityNotFound(res))
.then(function (tag) {
tag.getPostulantes()
.then(respondWithResult(res))
})
.catch(handleError(res));
}
......@@ -25,7 +25,7 @@ var all = {
ip: process.env.IP || '0.0.0.0',
// Should we populate the DB with sample data?
seedDB: false,
seedDB: true,
// Secret for session, you will want to change this and make it an environment variable
secrets: {
......
......@@ -5,40 +5,52 @@
'use strict';
import sqldb from '../sqldb';
var Thing = sqldb.Thing;
Thing.sync()
.then(() => {
return Thing.destroy({ where: {} });
var Tag = sqldb.Tag;
var Cargo = sqldb.Cargo;
//var Comentario = sqldb.Comentario;
//Comentario.sync()
// .then(()=>{
// return Comentario.destroy({where:{}});
// })
// .then(()=>{
// Comentario.bulkCreate([{
//
// }])
// })
Cargo.sync()
.then(()=>{
return Cargo.destroy({where:{}});
})
.then(() => {
Thing.bulkCreate([{
name: 'Development Tools',
info: 'Integration with popular tools such as Bower, Grunt, Babel, Karma, ' +
'Mocha, JSHint, Node Inspector, Livereload, Protractor, Jade, ' +
'Stylus, Sass, and Less.'
}, {
name: 'Server and Client integration',
info: 'Built with a powerful and fun stack: MongoDB, Express, ' +
'AngularJS, and Node.'
}, {
name: 'Smart Build System',
info: 'Build system ignores `spec` files, allowing you to keep ' +
'tests alongside code. Automatic injection of scripts and ' +
'styles into your index.html'
}, {
name: 'Modular Structure',
info: 'Best practice client and server structures allow for more ' +
'code reusability and maximum scalability'
}, {
name: 'Optimized Build',
info: 'Build process packs up your templates as a single JavaScript ' +
'payload, minifies your scripts/css/images, and rewrites asset ' +
'names for caching.'
}, {
name: 'Deployment Ready',
info: 'Easily deploy your app to Heroku or Openshift with the heroku ' +
'and openshift subgenerators'
}]);
.then(()=> {
Cargo.bulkCreate([{
nombre: 'Secretario'
}, {
nombre: 'Encargado de sistemas'
}, {
nombre: 'Jefe de Unidad'
}, {
nombre: 'Director Ejecutivo'
}, {
nombre: 'Consultor'
}])
});
Tag.sync()
.then(()=>{
return Tag.destroy({where:{}});
})
.then(()=> {
Tag.bulkCreate([{
nombre: 'C#'
}, {
nombre: 'Postgres'
}, {
nombre: 'Laravel'
}, {
nombre: 'Node'
}, {
nombre: 'Angular'
}, {
nombre: 'Sequelize'
}
])
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment