draft of Eventbrite API import GUI: #58

This commit is contained in:
Davide Alberani 2017-09-09 19:02:14 +02:00
parent dd23db6462
commit ecd18542e6
6 changed files with 114 additions and 21 deletions

View file

@ -59,6 +59,7 @@ Be sure to have a running MongoDB server, locally. If you want to install the de
sudo pip3 install pymongo # version 3.2.2 or later
sudo pip3 install python-dateutil
sudo pip3 install pycups # only needed if you want to print labels
sudo pip3 install eventbrite # only needed if you want to import from Eventbrite using their API
sudo pip3 install serial # only for the qrcode_reader script
sudo pip3 install requests # only for the qrcode_reader script
git clone https://github.com/raspibo/eventman

View file

@ -1,5 +1,36 @@
<!-- import tickets -->
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-title"><h1>{{'Import tickets with Eventbrite API' | translate}}</h1></div>
</div>
<div class="panel-body">
<form name="ebAPIForm" class="well">
<div class="form-group">
<label for="eb-api-key">{{'API key' | translate}}</label>
<input ng-model="ebAPIkey" id="eb-api-key" type="password" ng-required="true">
</div>
<div class="form-group">
<label for="eb-event-id">{{'Eventbrite Event ID' | translate}}</label>
<input ng-model="ebEventID" id="eb-event-id" ng-required="true">
</div>
<input type="checkbox" ng-model="createNewEvent"> {{'create a new event' | translate}}
<div class="form-group" ng-disabled="createNewEvent">
<label for="forEvent">{{'Associate tickets to this event' | translate}}</label>
<select class="form-control" id="forEvent" ng-model="targetEvent" ng-required="true" ng-disabled="createNewEvent">
<option ng-repeat="event in events" value="{{event._id}}">{{event.title}}</option>
</select>
</div>
<div>
<br />
<input type="submit" value="{{'Import' | translate}}" ng-click="apiImport()" />
</div>
</form>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-title"><h1>{{'Import tickets from Eventbrite CSV' | translate}}</h1></div>

View file

@ -826,14 +826,32 @@ eventManControllers.controller('UsersCtrl', ['$scope', '$rootScope', '$state', '
);
eventManControllers.controller('FileUploadCtrl', ['$scope', '$log', '$upload', 'Event',
function ($scope, $log, $upload, Event) {
eventManControllers.controller('FileUploadCtrl', ['$scope', '$log', '$upload', 'EbAPI', 'Event',
function ($scope, $log, $upload, EbAPI, Event) {
$scope.file = null;
$scope.progress = 0;
$scope.progressbarType = 'warning';
$scope.deduplicate = false;
$scope.targetEvent = null;
$scope.createNewEvent = true;
$scope.ebAPIkey = '';
$scope.ebEventID = '';
$scope.reply = {};
$scope.events = Event.all();
$scope.apiImport = function() {
if (!($scope.ebAPIkey && $scope.ebEventID)) {
$log.warn('missing Eventbrite API key or Event ID');
return;
}
EbAPI.apiImport({
create: $scope.createNewEvent,
eventID: $scope.ebEventID,
targetEvent: $scope.targetEvent,
apiKey: $scope.ebAPIkey
});
};
$scope.upload = function(file, url) {
$log.debug("FileUploadCtrl.upload");
$scope.progress = 0;

View file

@ -22,7 +22,7 @@ eventManServices.factory('Event', ['$resource', '$rootScope',
all: {
method: 'GET',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
isArray: true,
transformResponse: function(data, headers) {
data = angular.fromJson(data);
@ -39,7 +39,7 @@ eventManServices.factory('Event', ['$resource', '$rootScope',
get: {
method: 'GET',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
transformResponse: function(data, headers) {
data = angular.fromJson(data);
convert_dates(data);
@ -57,7 +57,7 @@ eventManServices.factory('Event', ['$resource', '$rootScope',
update: {
method: 'PUT',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
transformResponse: function(data, headers) {
data = angular.fromJson(data);
convert_dates(data);
@ -85,7 +85,7 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
all: {
method: 'GET',
url: '/tickets',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
isArray: true,
transformResponse: function(data, headers) {
data = angular.fromJson(data);
@ -96,7 +96,7 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
get: {
method: 'GET',
url: 'events/:id/tickets/:ticket_id',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
transformResponse: function(data, headers) {
data = angular.fromJson(data);
if (data.error) {
@ -108,7 +108,7 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
add: {
method: 'POST',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
isArray: false,
url: 'events/:event_id/tickets',
params: {uuid: $rootScope.app_uuid},
@ -123,7 +123,7 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
update: {
method: 'PUT',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
isArray: false,
url: 'events/:event_id/tickets/:ticket_id',
params: {uuid: $rootScope.app_uuid},
@ -137,7 +137,7 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
'delete': {
method: 'DELETE',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
isArray: false,
url: 'events/:event_id/tickets/:ticket_id',
params: {uuid: $rootScope.app_uuid},
@ -155,7 +155,7 @@ eventManServices.factory('Setting', ['$resource', '$rootScope',
return $resource('settings/', {}, {
query: {
method: 'GET',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
isArray: true,
transformResponse: function(data, headers) {
data = angular.fromJson(data);
@ -168,7 +168,7 @@ eventManServices.factory('Setting', ['$resource', '$rootScope',
update: {
method: 'PUT',
interceptor : {responseError: $rootScope.errorHandler}
interceptor: {responseError: $rootScope.errorHandler}
}
});
}]
@ -180,7 +180,27 @@ eventManServices.factory('Info', ['$resource', '$rootScope',
return $resource('info/', {}, {
get: {
method: 'GET',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
isArray: false,
transformResponse: function(data, headers) {
data = angular.fromJson(data);
if (data.error) {
return data;
}
return data.info || {};
}
}
});
}]
);
eventManServices.factory('EbAPI', ['$resource', '$rootScope',
function($resource, $rootScope) {
return $resource('ebapi/', {}, {
apiImport: {
method: 'POST',
interceptor: {responseError: $rootScope.errorHandler},
isArray: false,
transformResponse: function(data, headers) {
data = angular.fromJson(data);
@ -200,7 +220,7 @@ eventManServices.factory('User', ['$resource', '$rootScope',
return $resource('users/:id', {id: '@_id'}, {
all: {
method: 'GET',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
isArray: true,
transformResponse: function(data, headers) {
data = angular.fromJson(data);
@ -213,7 +233,7 @@ eventManServices.factory('User', ['$resource', '$rootScope',
get: {
method: 'GET',
interceptor : {responseError: $rootScope.errorHandler},
interceptor: {responseError: $rootScope.errorHandler},
transformResponse: function(data, headers) {
return angular.fromJson(data);
}
@ -221,24 +241,24 @@ eventManServices.factory('User', ['$resource', '$rootScope',
add: {
method: 'POST',
interceptor : {responseError: $rootScope.errorHandler}
interceptor: {responseError: $rootScope.errorHandler}
},
update: {
method: 'PUT',
interceptor : {responseError: $rootScope.errorHandler}
interceptor: {responseError: $rootScope.errorHandler}
},
login: {
method: 'POST',
url: '/login',
interceptor : {responseError: $rootScope.errorHandler}
interceptor: {responseError: $rootScope.errorHandler}
},
logout: {
method: 'GET',
url: '/logout',
interceptor : {responseError: $rootScope.errorHandler}
interceptor: {responseError: $rootScope.errorHandler}
}
});
}]

View file

@ -995,6 +995,20 @@ class UsersHandler(CollectionHandler):
super(UsersHandler, self).put(id_, resource, resource_id, **kwargs)
class EbAPIImportHandler(BaseHandler):
"""Import events and attendees using Eventbrite API."""
@gen.coroutine
@authenticated
def post(self, *args, **kwargs):
reply = {}
data = escape.json_decode(self.request.body or '{}')
apiKey = data.get('apiKey')
targetEvent = data.get('targetEvent')
eventID = data.get('eventID')
create = data.get('create')
self.write(reply)
class EbCSVImportPersonsHandler(BaseHandler):
"""Importer for CSV files exported from Eventbrite."""
csvRemap = {
@ -1259,8 +1273,13 @@ def run():
(r'/v%s%s' % (API_VERSION, _users_path), UsersHandler, init_params),
(r"/(?:index.html)?", RootHandler, init_params),
(r"/ebcsvpersons", EbCSVImportPersonsHandler, init_params),
(r"/v%s/ebcsvpersons" % API_VERSION, EbCSVImportPersonsHandler, init_params),
(r"/ebapi", EbAPIImportHandler, init_params),
(r"/v%s/ebapi" % API_VERSION, EbAPIImportHandler, init_params),
(r"/settings", SettingsHandler, init_params),
(r"/v%s/settings" % API_VERSION, SettingsHandler, init_params),
(r"/info", InfoHandler, init_params),
(r"/v%s/info" % API_VERSION, InfoHandler, init_params),
_ws_handler,
(r'/login', LoginHandler, init_params),
(r'/v%s/login' % API_VERSION, LoginHandler, init_params),

View file

@ -58,12 +58,16 @@
"until": "fino a",
"Delete event": "Cancella l'evento",
"Delete all tickets in event": "Cancella tutti i ticket dell'evento",
"Import tickets with Eventbrite API": "Importa i biglietti tramite le API di Eventbrite",
"API key": "API key",
"Eventbrite Event ID": "Eventbrite Event ID",
"create a new event": "crea un nuovo evento",
"Associate tickets to this event": "Associa i biglietti a questo evento",
"Import": "Importa",
"Import tickets from Eventbrite CSV": "Importa i biglietti da un CSV Eventbrite",
"CSV file": "File CSV",
"CSV exported from Eventbrite": "CSV esportato da Eventbrite",
"Associate tickets to this event": "Associa i biglietti a questo evento",
"deduplicate entries": "deduplica le voci",
"Import": "Importa",
"Users": "Utenti",
"All tickets": "Tutti i biglietti",
"Import tickets": "Importa biglietti",