Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Newsletter opt-in functionality #47

Open
wants to merge 6 commits into
base: v2
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Checks people into our events. Tech@NYU heavily relies on our [API](https://api.

For magnetic strip reading, [the card reader used in development can be found here](http://www.amazon.com/gp/product/B00D3D3L8Y?psc=1&redirect=true&ref_=oh_aui_detailpage_o04_s00), however, any card reader the emulates a HID keyboard device should work fine.

##Development
## Development

To run with production data (on port 3000):
```
git clone ...
Expand All @@ -15,4 +16,4 @@ npm start

To run with test data (on port 3000):

Same as above, but before starting the server, change `RestangularProvider.setBaseUrl('https://api.tnyu.org/v3');` in `app/js/app.js` to use the test url.
Same as above, but before starting the server, change `RestangularProvider.setBaseUrl('https://api.tnyu.org/v3');` in `app/js/app.js` to use the test url.
2 changes: 1 addition & 1 deletion app/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
.container {
max-width: 30em !important;
margin: 1em auto;
}
}
20 changes: 17 additions & 3 deletions app/js/controllers/entry-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

angular
.module('app.controllers')
.controller('EntryCtrl', function($scope, $stateParams, $sce, $q, Restangular, $timeout) {
.controller('EntryCtrl', function($scope, $stateParams, $sce, $q, $http, Restangular, $timeout) {

//used when loading typeahead
$scope.shared = $stateParams.config;
Expand Down Expand Up @@ -56,6 +56,20 @@ angular
});
}

$scope.addToMailingList = function(person) {
var access_token = 'f234e56583e242b25e3f76a7fe4e4789ab98ed0c';
var mailtrain_url = 'http://mailtrain.tnyu.org/api/subscribe/HJNc8AuSz';

$http({
method: 'POST',
crossDomain: true,
url: mailtrain_url + '?access_token=' + access_token,
data: { 'EMAIL': person.attributes.contact.email, 'REQUIRE_CONFIRMATION': 'yes' }
}).success(function(response) {
alert('success! – ' + response.data.id)
})
};

function personExists(url, elseCallback) {
Restangular.one(url)
.get()
Expand Down Expand Up @@ -181,7 +195,7 @@ angular
};

function resetTimeout() {
$timeout(reset, 5000);
$timeout(reset, 10000);
}

function reset() {
Expand All @@ -194,4 +208,4 @@ angular
$scope.needEmail = false;
$scope.allEntered = false;
}
});
});
6 changes: 6 additions & 0 deletions app/partials/entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ <h2>...and your email?</h2>
</div>
<div ng-if="person.attributes.name">
<h2>Hello {{person.attributes.name}}!</h2>
<div ng-if="dirty.email">
<!-- can only submit to mailtrain if there's aan available email -->
<form ng-submit="addToMailingList(person)">
<button type="submit" class="btn flatButton">Auto-subscribe</button>
</form>
</div>
<p ng-show="rsvpd">You have been successfully signed in!</p>
<p ng-hide="rsvpd">Checking you in now...</p>
</div>
Expand Down