Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Talk submit #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions common/models/speaker.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "DENY"
}

],
"methods": {}
}
9 changes: 6 additions & 3 deletions common/models/talk.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ module.exports = function (Talk) {
const speakerEmail = response.speakerEmail;
const meetupTitle = response.meetupTitle;
const meetupDate = response.meetupDate;
sendEmailToSpeaker(process.env.MAIN_ADMIN_EMAIL, approved, pending, speakerEmail, speakerName, meetupTitle, meetupDate)
.then(() => next())
sendEmailToSpeaker(process.env.ADMIN_EMAIL, approved, pending, speakerEmail, speakerName, meetupTitle, meetupDate)
.then(() => next())
.catch(err => next(err));
})
.catch(err => next(err));
Expand All @@ -280,7 +280,7 @@ module.exports = function (Talk) {
const speakerEmail = response.speakerEmail;
const meetupTitle = response.meetupTitle;
const meetupDate = response.meetupDate;
sendEmailToSpeaker(process.env.MAIN_ADMIN_EMAIL, approved, pending, speakerEmail, speakerName, meetupTitle, meetupDate)
sendEmailToSpeaker(process.env.ADMIN_EMAIL, approved, pending, speakerEmail, speakerName, meetupTitle, meetupDate)
.then(() => next())
.catch(err => next(err));
})
Expand Down Expand Up @@ -314,3 +314,6 @@ module.exports = function (Talk) {

});
};



3 changes: 2 additions & 1 deletion server/boot/authentication.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

module.exports = function enableAuthentication(server) {
server.enableAuth();
//server.enableAuth();

};
3 changes: 2 additions & 1 deletion server/datasources.production.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
module.exports = {
"sdjs": {
"url": process.env.MONGODB_URI,
"url": MONGODB_ATLAS_URI,
//"url": process.env.MONGODB_URI,
"connector": "mongodb"
}
}
2 changes: 1 addition & 1 deletion server/utils/formatTalkForEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function formatTalkForEmail(speakerId, eventId) {
.then(speaker => {
const speakerName = speaker.speakerName;
const speakerEmail = speaker.speakerEmail
Event.findById(eventId)
return Event.findById(eventId)
.then(selectedEvent => {
const meetupTitle = selectedEvent.name;
const meetupDate = selectedEvent.date;
Expand Down
28 changes: 15 additions & 13 deletions server/utils/getMeetups.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ function getMeetups() {
return new Promise((resolve, reject) => {
let currentDate = new Date();
currentDate.setMonth(currentDate.getMonth() + 3);
axios.get(`https://api.meetup.com/sandiegojs/events?no_later_than=${currentDate.getFullYear()}-${currentDate.getMonth()}-${currentDate.getDay()}`)
.then(response => {
resolve(response.data.map(event => ({
meetupId: event.id,
name: event.name,
date: event.local_date,
time: event.local_time,
venue: event.venue,
link: event.link,
description: event.description,
})));
})
.catch(err => reject(new Error('getMeetups failed to get SDJS meetups')))
const date = `${currentDate.getFullYear()}-${currentDate.getMonth()}-${currentDate.getDay()}`;
axios.get(`https://api.meetup.com/sandiegojs/events?no_later_than=${date}`)
.then( response => resolve(response.data.map(event => ({
meetupId: event.id,
name: event.name,
date: event.local_date,
time: event.local_time,
link: event.link,
description: event.description,
}))))
.catch(err => reject(new Error('getMeetups failed to get SDJS meetups')))
})
}

module.exports = { getMeetups };




19 changes: 10 additions & 9 deletions server/utils/sendGridEmailer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ sgMail.setApiKey(process.env.SENDGRID_API_KEY);

function sendEmailToSpeaker(adminEmail, approved, pending, speakerEmail, speakerName, meetupTitle, meetupDate) {
return new Promise((resolve, reject) => {
console.log('hello in sendEmailToSpeaker')
if (speakerEmail == undefined) {
return reject(new Error('speakerEmail is undefined'));
}
Expand Down Expand Up @@ -38,7 +39,7 @@ function sendEmailToSpeaker(adminEmail, approved, pending, speakerEmail, speaker
to: speakerEmail,
from: adminEmail,
subject: 'SDJS Meetup Speaker Request',
templateId: process.env.EMAIL_TEMPLATE,
templateId: process.env.ADMIN_SPEAKER_EMAIL_TEMPLATE,
dynamic_template_data: {
emailContent: emailContent,
sdjsBtn: false,
Expand Down Expand Up @@ -82,7 +83,7 @@ function sendEmailToAdmin(adminEmail, meetupDate, meetupTitle, speakerEmail, spe
to: adminEmail,
from: adminEmail,
subject: 'SDJS Meetup Speaker Request',
templateId: process.env.EMAIL_TEMPLATE,
templateId: process.env.ADMIN_SPEAKER_EMAIL_TEMPLATE,
dynamic_template_data: {
emailContent: emailContent,
sdjsBtn: false,
Expand Down Expand Up @@ -126,10 +127,10 @@ function sendConfirmCancelToAdmin(confirm, meetupDate, meetupTitle, speakerName)
}

const email = {
to: process.env.MAIN_ADMIN_EMAIL,
from: process.env.MAIN_ADMIN_EMAIL,
to: process.env.ADMIN_EMAIL,
from: process.env.ADMIN_EMAIL,
subject: 'SDJS Meetup Speaker Request',
templateId: process.env.EMAIL_TEMPLATE,
templateId: process.env.ADMIN_SPEAKER_EMAIL_TEMPLATE,
dynamic_template_data: {
emailContent: emailContent,
sdjsBtn: false,
Expand Down Expand Up @@ -164,9 +165,9 @@ function sendEmailToNewAdmin(username, email) {
password go to the Organizers tab and click on the edit button.`;
const newAdminEmail = {
to: email,
from: process.env.MAIN_ADMIN_EMAIL,
from: process.env.ADMIN_EMAIL,
subject: 'SDJS Meetup Admin Appointment',
templateId: process.env.EMAIL_TEMPLATE,
templateId: process.env.ADMIN_SPEAKER_EMAIL_TEMPLATE,
dynamic_template_data: {
emailContent: emailContent,
sdjsBtn: false,
Expand Down Expand Up @@ -244,9 +245,9 @@ function sendEmailToNewAdmin(username, email) {
// const url = 'http://localhost:3000/#/ConfirmOrCancel/?t=';
// const reminder = {
// to: speaker.speakerEmail,
// from: process.env.MAIN_ADMIN_EMAIL,
// from: process.env.ADMIN_EMAIL,
// subject: 'SDJS Meetup Speaker Reminder',
// templateId: 'd-227d9b43edf14c92964db9bd00fdf002',
// templateId: process.env.SPEAKER_REMINDER_EMAIL_TEMPLATE,
// dynamic_template_data: {
// emailContent: emailContent,
// sdjsBtn: true,
Expand Down
50 changes: 24 additions & 26 deletions server/utils/talkSubmit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@ const app = require('../server');
const { getMeetups } = require('./getMeetups');

function talkSubmit(speakerInfo, talkInfo, date) {
return new Promise((resolve, reject) => {
const { Talk, Speaker, Event } = app.models;
Speaker.create(speakerInfo)
.then(response => {
let speakerId = response.id
getMeetups()
.then(meetups => {
const index = meetups.findIndex((item) => item.date == date);
let name = meetups[index].name;
let details = meetups[index].description;
let meetupId = meetups[index].meetupId;
if (index === -1 )
return reject(new Error('NO meetup with that date found!'));
Event.findOrCreate({date, name, details, meetupId})
.then(event => {
let eventId = event[0].id
Talk.create( { ...talkInfo, speakerId, eventId})
.then(talk => resolve(talk))
.catch(err => console.log(err))
})
.catch(err => reject(err))
})
.catch(err => reject(err))
})
.catch(err => reject(err))
})
const { Talk, Speaker, Event } = app.models;
return getMeetups()
.then(meetups => {
const index = meetups.findIndex((item) => item.date == date);
let name = meetups[index].name;
let details = meetups[index].description;
let meetupId = meetups[index].meetupId;
if (index === -1)
return reject(new Error('NO meetup with that date found!'));
return Promise.all([
Event.findOrCreate({
date, name, details,
meetupId
}),
Speaker.create(speakerInfo)])
})
.then(([event, speaker]) => {
let eventId = event[0].id
let speakerId = speaker.id
return Talk.create({
...talkInfo,
speakerId, eventId
})
})
}

module.exports = { talkSubmit };
4 changes: 2 additions & 2 deletions src/components/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Home extends Component {
</p>
<h3>Want to do an extended talk?</h3>
<p>
We do accept extended talks but prefer presentors to have done a
lightning talk before. If you're unsure&nbsp;
We do accept extended talks, but prefer presenters to have done a
lightning talk before. If you're unsure,&nbsp;
<a
href="mailto:[email protected]?subject=Extended%20talk%20request"
className='inline-link'>
Expand Down
1 change: 1 addition & 0 deletions src/components/SignUp/SignUpActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios';

export const talkSubmit = (speakerInfo, talkInfo, date) => ({

type: 'TALK_SUBMIT',
payload: axios.post('api/talks/talkSubmit', {speakerInfo: speakerInfo, talkInfo: talkInfo, date: date})
})
Expand Down