Compare commits

...

10 Commits

Author SHA1 Message Date
Ben Ramey
9c574049f9 Fix how sengrid is constructed 2016-02-05 08:05:38 -06:00
Ben Ramey
9307e81fb6 Update sendgrid package 2016-02-05 08:01:20 -06:00
Ben Ramey
dab5097730 Update how to use sendgrid 2016-02-05 08:00:04 -06:00
Ben Ramey
5a9357ba76 Sails-mongo version 2015-10-21 20:18:13 -05:00
Ben Ramey
98f32bb6bc Cedar 14 update 2015-10-21 20:10:30 -05:00
Ben Ramey
52a6c8c8bc Send to 404 if invitee doesn't exist 2014-07-04 15:00:04 -05:00
Ben Ramey
303254ce9d HTML emails, fixes formatting 2014-07-04 14:55:20 -05:00
Ben Ramey
353ffcf8dd Version bump to 1.3.0 2014-07-04 13:59:08 -05:00
Ben Ramey
43e18b7eb9 Fix styles for run actions 2014-07-04 13:57:33 -05:00
Ben Ramey
1316b58ab2 Completed edit run functionality 2014-07-04 13:51:27 -05:00
13 changed files with 92 additions and 43 deletions

View File

@@ -1,29 +1,36 @@
// EmailService.js // EmailService.js
var sendgrid = require("sendgrid"); var thenJade = require("then-jade");
exports.sendOrderEmail = function(inviteeData) { exports.sendOrderEmail = function(inviteeData) {
var sendgrid = require("sendgrid")(sails.config.email.apiKey);
Run.findOne({ id: inviteeData.run_id }, function(err, runData) { Run.findOne({ id: inviteeData.run_id }, function(err, runData) {
if (err) { if (err) {
console.log(err); console.log(err);
return; return;
} }
var emailText = "You've been invited to " + runData.creatorName + "'s lunch run: '"
+ runData.name + "'! \n\n Put in your order here:\nhttp://www.lunchrun.me/#/order/"
+ inviteeData.id;
var options = { var options = {
fromname: runData.creatorName + " via LunchRun.me", fromname: runData.creatorName + " via LunchRun.me",
from: sails.config.email.fromAddress, from: sails.config.email.fromAddress,
to: inviteeData.email, to: inviteeData.email,
toname: inviteeData.name, toname: inviteeData.name,
subject: "You've been invited to a lunch run!", subject: "You've been invited to a lunch run!",
replyto: runData.creatorEmail, replyto: runData.creatorEmail
text: emailText
}; };
var sg = sendgrid(sails.config.email.apiUser, sails.config.email.apiKey);
sg.send(options, function(err, response) { thenJade.renderFile(
'./views/emails/new-invitee.jade',
{ runData: runData, inviteeData: inviteeData },
function(err, result) {
if (err) {
console.log(err);
return;
}
options.html = result;
sendgrid.send(options, function(err, response) {
if (err) { if (err) {
console.log(err); console.log(err);
} else { } else {
@@ -33,4 +40,5 @@ exports.sendOrderEmail = function(inviteeData) {
console.log(options); console.log(options);
}); });
});
}; };

View File

@@ -8,7 +8,8 @@ lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', '$location', 's
$scope.addInvitee = () -> $scope.addInvitee = () ->
$scope.invitees.push {} $scope.invitees.push {}
$scope.removeInvitee = (index) -> $scope.removeInvitee = (invitee) ->
index = $scope.invitees.indexOf invitee
$scope.invitees.splice index, 1 $scope.invitees.splice index, 1
$scope.create = (run,invitees) -> $scope.create = (run,invitees) ->

View File

@@ -1,7 +1,7 @@
lunchControllers = angular.module 'lunchControllers' lunchControllers = angular.module 'lunchControllers'
lunchControllers.controller 'EditRunCtrl', ['$scope', 'socket', '$routeParams', '$sce', lunchControllers.controller 'EditRunCtrl', ['$scope', 'socket', '$routeParams', '$sce', '$location',
EditRunController = ($scope, socket, $routeParams, $sce) -> EditRunController = ($scope, socket, $routeParams, $sce, $location) ->
$scope.show = false $scope.show = false
socket.get '/run/' + $routeParams['id'], socket.get '/run/' + $routeParams['id'],
@@ -20,8 +20,18 @@ lunchControllers.controller 'EditRunCtrl', ['$scope', 'socket', '$routeParams',
$scope.addInvitee = () -> $scope.addInvitee = () ->
$scope.invitees.push {} $scope.invitees.push {}
$scope.removeInvitee = (index) -> $scope.removeInvitee = (invitee) ->
if invitee.id
socket.delete '/invitee/destroy/' + invitee.id, (deleteResponse) ->
console.log deleteResponse
$scope.spliceInvitee invitee
else
$scope.spliceInvitee invitee
$scope.spliceInvitee = (invitee) ->
index = $scope.invitees.indexOf invitee
$scope.invitees.splice index, 1 $scope.invitees.splice index, 1
$scope.$apply()
$scope.update = (run,invitees) -> $scope.update = (run,invitees) ->
runData = angular.copy run runData = angular.copy run
@@ -30,12 +40,22 @@ lunchControllers.controller 'EditRunCtrl', ['$scope', 'socket', '$routeParams',
creatorInvitee.name = runData.creatorName creatorInvitee.name = runData.creatorName
creatorInvitee.email = runData.creatorEmail creatorInvitee.email = runData.creatorEmail
socket.put '/run/update/' + runData.id, runData, (runResponse) -> socket.put '/run/' + runData.id, runData, (runResponse) ->
inviteesCreated = 0
inviteesUpdated = 0
for i in inviteeData for i in inviteeData
socket.put '/invitee/update/' + i.id, i, (inviteeResponse) -> if i.id
inviteesCreated++ socket.put '/invitee/' + i.id, i, (inviteeResponse) ->
if inviteesCreated is inviteeData.length inviteesUpdated++
$location.path '/run/' + runResponse.id $scope.redirectIfAllInviteesUpdated inviteesUpdated, inviteeData.length
else
i.run_id = runData.id
socket.post '/invitee', i, (inviteeResponse) ->
inviteesUpdated++
$scope.redirectIfAllInviteesUpdated inviteesUpdated, inviteeData.length
$scope.redirectIfAllInviteesUpdated = (updatedCount, inviteeCount) ->
if updatedCount is inviteeCount
$location.path '/run/' + $scope.run.id
$scope.$apply() $scope.$apply()
] ]

View File

@@ -8,6 +8,10 @@ lunchControllers.controller 'UpdateOrderCtrl', ['$scope','socket','$routeParams'
$scope.menuUrl = '' $scope.menuUrl = ''
socket.get '/invitee/findOne', id: $routeParams['inviteeId'], (inviteeResponse) -> socket.get '/invitee/findOne', id: $routeParams['inviteeId'], (inviteeResponse) ->
if inviteeResponse.status is 404
window.location = '/404'
return
$scope.invitee = inviteeResponse $scope.invitee = inviteeResponse
socket.get '/run/' + inviteeResponse.run_id, socket.get '/run/' + inviteeResponse.run_id,

View File

@@ -21,7 +21,7 @@ form {
right: 5px; right: 5px;
} }
} }
.create-run-form { .edit-run-form, .create-run-form {
.invitees { .invitees {
.btn-default { .btn-default {
margin-top: 20px; margin-top: 20px;

View File

@@ -13,6 +13,7 @@
margin-right: 2px; margin-right: 2px;
padding: 5px 20px; padding: 5px 20px;
} }
}
.run-show-actions a.back-to-run { .run-show-actions a.back-to-run {
display: none; display: none;
} }
@@ -20,7 +21,6 @@
display: none; display: none;
} }
} }
}
footer { footer {
position: absolute; position: absolute;

View File

@@ -60,7 +60,7 @@
span.glyphicon.glyphicon-ok.form-control-feedback(ng-show='inviteeForm.Name.$dirty && inviteeForm.Name.$valid') span.glyphicon.glyphicon-ok.form-control-feedback(ng-show='inviteeForm.Name.$dirty && inviteeForm.Name.$valid')
.col-xs-2.deletebtn-wrapper .col-xs-2.deletebtn-wrapper
button.btn.btn-block.btn-lg.btn-warning(ng-click='removeInvitee($index)') button.btn.btn-block.btn-lg.btn-warning(ng-click='removeInvitee(i)')
span.glyphicon.glyphicon-remove span.glyphicon.glyphicon-remove
.col-xs-10.email-wrapper .col-xs-10.email-wrapper

View File

@@ -5,7 +5,7 @@ block pagetitle
| update your lunch run | update your lunch run
block interiorcontent block interiorcontent
.create-run-form(ng-controller='EditRunCtrl') .edit-run-form(ng-controller='EditRunCtrl')
form.row(name='form',novalidate,role='form',ng-show="show") form.row(name='form',novalidate,role='form',ng-show="show")
include _form include _form
section.submit section.submit

View File

@@ -3,6 +3,6 @@
// //
module.exports.email = { module.exports.email = {
apiUser: "benjaminramey", apiUser: "benjaminramey",
apiKey: "AVidasUPthub6pY3fFGe", apiKey: "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",
fromAddress: "ben.ramey@gmail.com" fromAddress: "no-reply@lunchrun.me"
}; };

View File

@@ -23,14 +23,16 @@ module.exports.policies = {
RunController: { RunController: {
'*': false, '*': false,
'find': true, 'find': true,
'create': true 'create': true,
'update': true
}, },
InviteeController: { InviteeController: {
'*': false, '*': false,
'find': true, 'find': true,
'create': true, 'create': true,
'update': true 'update': true,
'destroy': true
}, },
SessionController: { SessionController: {

View File

@@ -1,7 +1,7 @@
{ {
"name": "lunchrun.me", "name": "lunchrun.me",
"private": true, "private": true,
"version": "1.2.0", "version": "1.3.0",
"description": "Lunch runs made easy!", "description": "Lunch runs made easy!",
"dependencies": { "dependencies": {
"sails": "0.9.9", "sails": "0.9.9",
@@ -9,11 +9,11 @@
"sails-disk": "~0.9.0", "sails-disk": "~0.9.0",
"optimist": "0.3.4", "optimist": "0.3.4",
"then-jade": "1.1.0", "then-jade": "1.1.0",
"sails-mongo": "latest", "sails-mongo": "0.9.x",
"mongodb": "latest", "mongodb": "latest",
"load-grunt-tasks": "~0.3.0", "load-grunt-tasks": "~0.3.0",
"glob": "3.2.8", "glob": "3.2.8",
"sendgrid": "1.0.2", "sendgrid": "2.0.0",
"grunt-contrib-clean": "~0.5.0", "grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.5.0", "grunt-contrib-copy": "~0.5.0",
"grunt-contrib-concat": "~0.3.0", "grunt-contrib-concat": "~0.3.0",

6
views/emails/layout.jade Normal file
View File

@@ -0,0 +1,6 @@
doctype html
html(lang="en")
head
body
block content

View File

@@ -0,0 +1,8 @@
extends layout
block content
p= "You've been invited to " + runData.creatorName + "'s lunch run: " + runData.name + "!"
p
a(href='http://www.lunchrun.me/#/order/' + inviteeData.id) Put in your order!