Skip to content

Commit

Permalink
fix vote form
Browse files Browse the repository at this point in the history
  • Loading branch information
xtian7489 committed Sep 27, 2024
1 parent 33f0782 commit 113d435
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 31 deletions.
8 changes: 1 addition & 7 deletions ext/lib/api-v2/votes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,7 @@ app.post('/votes/create',
// console.log(req.voto2)
// console.log('Facultad')
// console.log(req.facultad)
if (!req.canManage && req.voto1.facultad.toString() !== req.user.facultad.toString()) {
log('User is not in the same facultad as the vote -- sending error')
res.status(403).json({
error: 'Cant vote projects from different zone'
})
return
}


apiV2.votes.create({
user: req.user,
Expand Down
1 change: 1 addition & 0 deletions ext/lib/site/formulario-propuesta/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ class FormularioPropuesta extends Component {
name='facultad'
value={this.state['facultad']}
onChange={this.handleInputChange}
style={{ 'height': '45px' }}
>
<option value=''>Seleccione una facultad...</option>
{facultades.length > 0 && facultades.map(facultad =>
Expand Down
21 changes: 12 additions & 9 deletions ext/lib/site/formulario-votacion/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class FormularioVoto extends Component {
renderStep = (step) => {
const tags = this.state.activeTags.length > 0 ? this.state.activeTags : this.state.tags.map(t => t.id)
const facultades = this.state.activeFacultades.length > 0 ? this.state.activeFacultades : this.state.facultades.map(t => t.id)
const { searchedByName } = this.state

switch (step) {
case 0:
Expand All @@ -284,27 +285,29 @@ class FormularioVoto extends Component {
case 2:
return <Info texts={this.state.texts}/>
case 3:
return <VotoFacultad
topics={this.state.topics}
return <VotoCualquierFacultad
topics={searchedByName ?
this.state.topics.filter(t => searchedByName.include(t.id)) :
this.state.topics.filter(t => tags.includes(t.tag.id) && facultades.includes(t.facultad._id))
}
handler="voto1"
selected={this.state.voto1}
setState={this.handleCheckboxInputChange}
// Filters
tags={this.state.tags}
activeTags={this.state.activeTags}
facultades={this.state.facultades}
activeFacultades={this.state.activeFacultades}
handleFilter={this.handleFilter}
handleDefaultFilter={this.handleDefaultFilter}
clearFilter={this.clearFilter}
handleShowTopicDialog={this.handleShowTopicDialog}
/>
case 4:
const { searchedByName } = this.state
return <VotoCualquierFacultad
topics={searchedByName ?
topics.filter(t => searchedByName.include(t.id)) :
this.state.topics.filter(t => searchedByName.include(t.id)) :
this.state.topics.filter(t => t.id !== this.state.voto1 &&
tags.includes(t.tag.id) &&
facultades.includes(t.facultad._id))
tags.includes(t.tag.id))
}
handler="voto2"
selected={this.state.voto2}
Expand Down Expand Up @@ -367,12 +370,12 @@ class FormularioVoto extends Component {

case 3:
return !voto1 ? {
message: 'El primer voto es obligatorio y se destina a tu facultad indicada al momento de registro',
message: 'El primer voto es obligatorio',
canPass: false
} : {}
case 4:
return !voto2 ? {
message: 'No elegiste ningún proyecto, esto se considerará como VOTO EN BLANCO.',
message: 'No elegiste ningún proyecto para tu segundo voto',
canPass: true
} : {}
default:
Expand Down
2 changes: 1 addition & 1 deletion ext/lib/site/formulario-votacion/steps/confirmacion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import VotoTopicCard from './topic-card/component'

export default ({topics}) => {

const showTopics = topics.length === 1 ? [topics[0], {id: '', mediaTitle: "Voto N°2 en blanco"}] : topics
const showTopics = topics

return (
<div className='form-votacion'>
Expand Down
4 changes: 3 additions & 1 deletion ext/lib/site/formulario-votacion/styles.styl
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@

.dialog-votacion
box-sizing: border-box;

position: fixed
top:45%
z-index: 111
background: #FFFFFF;
border: 3px solid $primary-color-2;
border-radius: 20px;
Expand Down
10 changes: 5 additions & 5 deletions lib/api-v2/stats/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ app.get('/stats/usuariosQueNoVotaron/csv',
res.set({
'Content-Encoding': 'UTF-8',
'Content-Type': 'text/csv; charset=UTF-8',
'Content-Disposition': `attachment; filename=ppunr-facultades-usuarios-que-no-votaron-${moment().format('YYYY-MM-DD-HH-mm-ss')}.csv`
'Content-Disposition': `attachment; filename=ppunmdp-facultades-usuarios-que-no-votaron-${moment().format('YYYY-MM-DD-HH-mm-ss')}.csv`
})
res.write(csv)
res.end()
Expand Down Expand Up @@ -213,7 +213,7 @@ app.get('/stats/listadoDeVotosPorVotante/csv',
]
})

var data = [['DNI', 'Nombre', 'Apellido', 'Registrado?', 'Facultad', 'Claustro', 'Formato', 'Cantidad Votos', 'Voto 1', 'Voto 2', 'Voto 3']]
var data = [['DNI', 'Nombre', 'Apellido', 'Registrado?', 'Facultad', 'Claustro', 'Formato', 'Cantidad Votos', 'Voto 1', 'Voto 2']]
data = data.concat(infoVotes)
json2csv(data, function (err, csv) {
if (err) {
Expand All @@ -224,7 +224,7 @@ app.get('/stats/listadoDeVotosPorVotante/csv',
res.set({
'Content-Encoding': 'UTF-8',
'Content-Type': 'text/csv; charset=UTF-8',
'Content-Disposition': `attachment; filename=ppunr-facultades-listado-votos-por-votantes-${moment().format('YYYY-MM-DD-HH-mm-ss')}.csv`
'Content-Disposition': `attachment; filename=ppunmdp-facultades-listado-votos-por-votantes-${moment().format('YYYY-MM-DD-HH-mm-ss')}.csv`
})
res.write(csv)
res.end()
Expand Down Expand Up @@ -313,7 +313,7 @@ app.get('/stats/listadoDeVotos/csv',
res.set({
'Content-Encoding': 'UTF-8',
'Content-Type': 'text/csv; charset=UTF-8',
'Content-Disposition': `attachment; filename=ppunr-facultades-listado-votos-${moment().format('YYYY-MM-DD-HH-mm-ss')}.csv`
'Content-Disposition': `attachment; filename=ppunmdp-facultades-listado-votos-${moment().format('YYYY-MM-DD-HH-mm-ss')}.csv`
})
res.write(csv)
res.end()
Expand Down Expand Up @@ -365,7 +365,7 @@ app.get('/stats/votosPorProyectos/csv',
res.set({
'Content-Encoding': 'UTF-8',
'Content-Type': 'text/csv; charset=UTF-8',
'Content-Disposition': `attachment; filename=ppunr-facultades-cantidad-votos-por-proyecto-${Math.floor((new Date()) / 1000)}.csv`
'Content-Disposition': `attachment; filename=ppunmdp-facultades-cantidad-votos-por-proyecto-${Math.floor((new Date()) / 1000)}.csv`
})
res.write(csv)
res.end()
Expand Down
2 changes: 1 addition & 1 deletion lib/models/facultad.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Schema = mongoose.Schema
const FacultadSchema = new Schema({
nombre: { type: String, required: true, minlength: 1, maxlength: 200 },
abreviacion: { type: String, required: true, minlength: 1, maxlength: 50 }
}, { id: false })
})
// esto último hace que no esté el campo _id e id duplicado

FacultadSchema.statics.findByName = function (name, cb) {
Expand Down
2 changes: 1 addition & 1 deletion mongo-scripts/dump-facultades-no-validados.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Ejecutar haciendo túnel con servidor mongo a localhost:26017 y después:
mongo --quiet localhost:26017/ppunr-prod dump-users-facultades.js > ppunr-facultades-usuarios.csv
mongo --quiet localhost:26017/ppunmdp-prod dump-users-facultades.js > ppunmdp-facultades-usuarios.csv
*/

print('Nombre,Apellido,Email,DNI,Facultad,Claustro,Fecha de registro,Validado')
Expand Down
2 changes: 1 addition & 1 deletion mongo-scripts/dump-users-escuelas-votantes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Ejecutar haciendo túnel con servidor mongo a localhost:26017 y después:
mongo --quiet localhost:26017/ppunre-prod dump-users-escuelas.js > ppunr-escuelas-usuarios.csv
mongo --quiet localhost:26017/ppunmdpe-prod dump-users-escuelas.js > ppunmdp-escuelas-usuarios.csv
*/

print('Nombre,Apellido,Email,DNI,Escuelas,Claustro,Fecha de registro,Validado')
Expand Down
2 changes: 1 addition & 1 deletion mongo-scripts/dump-users-escuelas.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Ejecutar haciendo túnel con servidor mongo a localhost:26017 y después:
mongo --quiet localhost:26017/ppunre-prod dump-users-escuelas.js > ppunr-escuelas-usuarios.csv
mongo --quiet localhost:26017/ppunmdpe-prod dump-users-escuelas.js > ppunmdp-escuelas-usuarios.csv
*/

print('Nombre,Apellido,Email,DNI,Escuelas,Claustro,Fecha de registro,Validado')
Expand Down
2 changes: 1 addition & 1 deletion mongo-scripts/dump-users-facultades-sin-votar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Ejecutar haciendo túnel con servidor mongo a localhost:26017 y después:
mongo --quiet localhost:26017/ppunr-prod dump-users-facultades.js > ppunr-facultades-usuarios.csv
mongo --quiet localhost:26017/ppunmdp-prod dump-users-facultades.js > ppunmdp-facultades-usuarios.csv
*/

print('Nombre,Apellido,Email,DNI,Facultad,Claustro,Fecha de registro,Validado')
Expand Down
2 changes: 1 addition & 1 deletion mongo-scripts/dump-users-facultades-votantes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Ejecutar haciendo túnel con servidor mongo a localhost:26017 y después:
mongo --quiet localhost:26017/ppunr-prod dump-users-facultades.js > ppunr-facultades-usuarios.csv
mongo --quiet localhost:26017/ppunmdp-prod dump-users-facultades.js > ppunmdp-facultades-usuarios.csv
*/

print('Nombre,Apellido,Email,DNI,Facultad,Claustro,Fecha de registro,Validado')
Expand Down
2 changes: 1 addition & 1 deletion mongo-scripts/dump-users-facultades.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Ejecutar haciendo túnel con servidor mongo a localhost:26017 y después:
mongo --quiet localhost:26017/ppunr-prod dump-users-facultades.js > ppunr-facultades-usuarios.csv
mongo --quiet localhost:26017/ppunmdp-prod dump-users-facultades.js > ppunmdp-facultades-usuarios.csv
*/

print('Nombre,Apellido,Email,Facultad,Claustro,Fecha de registro,Validado')
Expand Down
2 changes: 1 addition & 1 deletion mongo-scripts/dump-users-no-validados.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Ejecutar haciendo túnel con servidor mongo a localhost:26017 y después:
// mongo --quiet localhost:26017/ppunr-prod dump-users-no-validados.js > ppunr-facultades-usuarios-no-validados.csv
// mongo --quiet localhost:26017/ppunmdp-prod dump-users-no-validados.js > ppunmdp-facultades-usuarios-no-validados.csv

print('Nombre,Apellido,Email,Fecha registración')

Expand Down

0 comments on commit 113d435

Please sign in to comment.