Skip to content

Commit

Permalink
feat(general): new core refactor (#271)
Browse files Browse the repository at this point in the history
New core refactor

BREAKING CHANGE: new core refactor
  • Loading branch information
serge1peshcoff authored Jun 12, 2020
1 parent 818d65e commit 1f89d80
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 2,730 deletions.
8 changes: 4 additions & 4 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const config = {
database: process.env.DB_DATABASE || 'statutory',
},
core: {
url: 'http://oms-core-elixir',
port: 4000,
url: 'http://oms-core-js',
port: 8084,
user: {
login: process.env.CORE_LOGIN || 'admin@aegee.org',
password: process.env.CORE_PASSWORD || '5ecr3t'
login: process.env.CORE_LOGIN || 'admin@example.com',
password: process.env.CORE_PASSWORD || '5ecr3t5ecr3t'
}
},
mailer: {
Expand Down
8 changes: 4 additions & 4 deletions lib/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ exports.updateApplication = async (req, res) => {
req.body.first_name = user.first_name;
req.body.last_name = user.last_name;
req.body.gender = user.gender;
req.body.email = user.user.email;
req.body.email = user.email;
req.body.date_of_birth = user.date_of_birth;
if (req.body.body_id) {
// Shouldn't crash, if the person is not a member of a body,
Expand Down Expand Up @@ -296,7 +296,7 @@ exports.updateApplication = async (req, res) => {

if (boardMembers.length > 0) {
await mailer.sendMail({
to: boardMembers.map(member => member.member.user.email),
to: boardMembers.map(member => member.user.email),
subject: `One of your body members changed the application to ${req.event.name}`,
template: 'statutory_board_edited.html',
parameters: {
Expand Down Expand Up @@ -612,7 +612,7 @@ exports.postApplication = async (req, res) => {
req.body.first_name = req.user.first_name;
req.body.last_name = req.user.last_name;
req.body.gender = req.user.gender;
req.body.email = req.user.user.email;
req.body.email = req.user.email;
req.body.body_name = req.user.bodies.find(b => req.body.body_id === b.id).name;
req.body.date_of_birth = req.user.date_of_birth;

Expand Down Expand Up @@ -643,7 +643,7 @@ exports.postApplication = async (req, res) => {

if (boardMembers.length > 0) {
await mailer.sendMail({
to: boardMembers.map(member => member.member.user.email),
to: boardMembers.map(member => member.user.email),
subject: `One of your body members has applied to ${req.event.name}`,
template: 'statutory_board_applied.html',
parameters: {
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function getBodiesListFromPermissions(result) {
return [];
}

return result.reduce((acc, val) => acc.concat(val), [])
return result
.filter(elt => elt.body_id)
.map(elt => elt.body_id)
.filter((elt, index, array) => array.indexOf(elt) === index);
Expand Down
2 changes: 1 addition & 1 deletion lib/plenaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ exports.listPlenariesStats = async (req, res) => {

return [
body.id,
body.legacy_key,
body.code,
body.name,
body.type,
applicationsForBody.length,
Expand Down
4 changes: 2 additions & 2 deletions test/api/plenaries-export-stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ describe('Plenaries exports', () => {
expect(row.length).toEqual(9); // body ID, code, name, type, delegates count, avg%, 3 delegates %

expect(row[0]).toEqual(regularUser.bodies[0].id);
expect(row[1]).toEqual(regularUser.bodies[0].legacy_key);
expect(row[1]).toEqual(regularUser.bodies[0].code);
expect(row[2]).toEqual(regularUser.bodies[0].name);
expect(row[3]).toEqual(regularUser.bodies[0].type);
expect(row[4]).toEqual(3); // 3 delegates
Expand Down Expand Up @@ -542,7 +542,7 @@ describe('Plenaries exports', () => {
expect(row.length).toEqual(6); // body ID, code, name, type, delegates count, avg%, 0 delegates %

expect(row[0]).toEqual(regularUser.bodies[0].id);
expect(row[1]).toEqual(regularUser.bodies[0].legacy_key);
expect(row[1]).toEqual(regularUser.bodies[0].code);
expect(row[2]).toEqual(regularUser.bodies[0].name);
expect(row[3]).toEqual(regularUser.bodies[0].type);
expect(row[4]).toEqual(0); // 3 delegates
Expand Down
Loading

0 comments on commit 1f89d80

Please sign in to comment.