Skip to content
Permalink
Browse files

migration script for new maps and placeholder in UI

  • Loading branch information...
leider committed Oct 25, 2019
1 parent 9e26733 commit fd122034da624420358290fe6071e7619aa30a52
Showing with 60 additions and 2 deletions.
  1. +58 −0 softwerkskammer/convertcoordinates.js
  2. +2 −2 softwerkskammer/lib/groups/views/groups-forms.pug
@@ -0,0 +1,58 @@
/*eslint no-process-exit: 0 */
/* eslint no-console: 0 */
'use strict';

const async = require('async');

require('./configure'); // initializing parameters
const beans = require('simple-configure').get('beans');
const groupstore = beans.get('groupstore');

const MAP_COORDINATES_NORTH = 55.05864;
const MAP_COORDINATES_EAST = 17.160749;
const MAP_COORDINATES_SOUTH = 45.817920;
const MAP_COORDINATES_WEST = 5.866944;
const MAP_COORDINATES_WIDTH = MAP_COORDINATES_EAST - MAP_COORDINATES_WEST;
const MAP_COORDINATES_HEIGHT = MAP_COORDINATES_NORTH - MAP_COORDINATES_SOUTH;

const really = process.argv[2];
if (!really || really !== 'really') {
console.log('If you want to run this script, append "really" to the command line.');
process.exit();
}

groupstore.allGroups((err, groups) => {
if (err) {
console.log(err);
process.exit();
}

function updateGroup(g) {
if (g.mapX) {
const oldX = parseFloat(g.mapX);
const oldY = parseFloat(g.mapY);
g.mapX = MAP_COORDINATES_WEST + oldX / 342 * MAP_COORDINATES_WIDTH;
g.mapY = MAP_COORDINATES_SOUTH + (1 - (oldY / 441)) * MAP_COORDINATES_HEIGHT;

console.log(g.id + ' alt X: ' + oldX + ' Y: ' + oldY + ' -- neu X: ' + g.mapX + ' Y: ' + g.mapY);
}
}

async.each(groups, (group, callback) => {
updateGroup(group);
groupstore.saveGroup(group, (err2, res) => {
console.log(res);
callback(err2, res);
});
}, err1 => {
if (err1) {
console.log('Error on save');
console.log(err1);
process.exit();
}
console.log('All groups processed');
process.exit();
});

});

@@ -40,9 +40,9 @@ mixin groupform(group, allTypes, organizersChecked)
#mapstuff.col-md-6
.row
.col-md-6
+text('mapY', t('groups.y_coord'), group.mapY, t('groups.tooltip.y_coord'))
+text('mapY', t('groups.y_coord'), group.mapY, t('groups.tooltip.y_coord'), t('groups.tooltip.y_coord'))
.col-md-6
+text('mapX', t('groups.x_coord'), group.mapX, t('groups.tooltip.x_coord'))
+text('mapX', t('groups.x_coord'), group.mapX, t('groups.tooltip.x_coord'), t('groups.tooltip.x_coord'))
+text('shortName', t('groups.map_label'), group.shortName, t('groups.tooltip.map_label'))
+text('meetupURL', t('groups.meetupURL_label'), group.meetupURL, t('groups.tooltip.meetupURL_label'))
+checkboxWithDescription('contactingOrganizersEnabled', t('groups.mail_the_contact_persons'), group.contactingOrganizersEnabled, t('groups.tooltip.mail_the_contact_persons'))

0 comments on commit fd12203

Please sign in to comment.
You can’t perform that action at this time.