improve tickets handling
This commit is contained in:
parent
9596922b7d
commit
88078f64df
5 changed files with 91 additions and 9 deletions
4
angular_app/js/app.js
vendored
4
angular_app/js/app.js
vendored
|
@ -139,12 +139,12 @@ eventManApp.config(['$stateProvider', '$urlRouterProvider',
|
||||||
.state('event.ticket.new', {
|
.state('event.ticket.new', {
|
||||||
url: '/:id/ticket/new',
|
url: '/:id/ticket/new',
|
||||||
templateUrl: 'ticket-edit.html',
|
templateUrl: 'ticket-edit.html',
|
||||||
controller: 'EventDetailsCtrl'
|
controller: 'EventTicketsCtrl'
|
||||||
})
|
})
|
||||||
.state('event.ticket.edit', {
|
.state('event.ticket.edit', {
|
||||||
url: '/:id/ticket/edit',
|
url: '/:id/ticket/edit',
|
||||||
templateUrl: 'ticket-edit.html',
|
templateUrl: 'ticket-edit.html',
|
||||||
controller: 'EventDetailsCtrl'
|
controller: 'EventTicketsCtrl'
|
||||||
})
|
})
|
||||||
.state('import', {
|
.state('import', {
|
||||||
url: '/import',
|
url: '/import',
|
||||||
|
|
31
angular_app/js/controllers.js
vendored
31
angular_app/js/controllers.js
vendored
|
@ -95,8 +95,8 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$modal', '
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope',
|
eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'EventTicket', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope',
|
||||||
function ($scope, $state, Event, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope) {
|
function ($scope, $state, Event, EventTicket, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope) {
|
||||||
$scope.personsOrder = ["name", "surname"];
|
$scope.personsOrder = ["name", "surname"];
|
||||||
$scope.countAttendees = 0;
|
$scope.countAttendees = 0;
|
||||||
$scope.message = {};
|
$scope.message = {};
|
||||||
|
@ -359,6 +359,33 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event', 'EventTicket', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope',
|
||||||
|
function ($scope, $state, Event, EventTicket, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope) {
|
||||||
|
$scope.message = {};
|
||||||
|
$scope.event = {};
|
||||||
|
|
||||||
|
$scope.newTicket = $state.is('event.ticket.new');
|
||||||
|
|
||||||
|
if ($stateParams.id) {
|
||||||
|
$scope.event = Event.get($stateParams, function() {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.addTicket = function(person) {
|
||||||
|
var personObj = new Person(person);
|
||||||
|
personObj.$save(function(p) {
|
||||||
|
person.person_id = person._id;
|
||||||
|
person._id = $stateParams.id; // that's the id of the event, not the person.
|
||||||
|
EventTicket.addTicket(person, function(p) {
|
||||||
|
$log.debug(p);
|
||||||
|
});
|
||||||
|
$scope.newPerson = {};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting', '$modal', '$translate', '$rootScope',
|
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting', '$modal', '$translate', '$rootScope',
|
||||||
function ($scope, Person, Setting, $modal, $translate, $rootScope) {
|
function ($scope, Person, Setting, $modal, $translate, $rootScope) {
|
||||||
$scope.persons = Person.all();
|
$scope.persons = Person.all();
|
||||||
|
|
41
angular_app/js/services.js
vendored
41
angular_app/js/services.js
vendored
|
@ -97,6 +97,47 @@ eventManServices.factory('Event', ['$resource', '$rootScope',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
eventManServices.factory('EventTicket', ['$resource', '$rootScope',
|
||||||
|
function($resource, $rootScope) {
|
||||||
|
return $resource('events/:id/tickets', {id: '@_id', person_id: '@person_id'}, {
|
||||||
|
|
||||||
|
updateTicket: {
|
||||||
|
method: 'PUT',
|
||||||
|
interceptor : {responseError: $rootScope.errorHandler},
|
||||||
|
isArray: false,
|
||||||
|
url: 'events/:id/ticketss/:person_id',
|
||||||
|
params: {uuid: $rootScope.app_uuid},
|
||||||
|
transformResponse: function(data, headers) {
|
||||||
|
return angular.fromJson(data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addTicket: {
|
||||||
|
method: 'POST',
|
||||||
|
interceptor : {responseError: $rootScope.errorHandler},
|
||||||
|
isArray: false,
|
||||||
|
url: 'events/:id/tickets/:person_id',
|
||||||
|
params: {uuid: $rootScope.app_uuid},
|
||||||
|
transformResponse: function(data, headers) {
|
||||||
|
return angular.fromJson(data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteTicket: {
|
||||||
|
method: 'DELETE',
|
||||||
|
interceptor : {responseError: $rootScope.errorHandler},
|
||||||
|
isArray: false,
|
||||||
|
url: 'events/:_id/tickets/:person_id',
|
||||||
|
params: {uuid: $rootScope.app_uuid},
|
||||||
|
transformResponse: function(data, headers) {
|
||||||
|
return angular.fromJson(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManServices.factory('Person', ['$resource', '$rootScope',
|
eventManServices.factory('Person', ['$resource', '$rootScope',
|
||||||
function($resource, $rootScope) {
|
function($resource, $rootScope) {
|
||||||
return $resource('persons/:id', {id: '@_id'}, {
|
return $resource('persons/:id', {id: '@_id'}, {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<input name="job_title" class="form-control" placeholder="{{'Evil Ruler' | translate}}" ng-model="newPerson.job_title">
|
<input name="job_title" class="form-control" placeholder="{{'Evil Ruler' | translate}}" ng-model="newPerson.job_title">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button reset-focus ng-disabled="!(newPerson.name && newPerson.surname)" ng-click="addRegisteredPerson(newPerson, true)" class="btn btn-success top5">
|
<button reset-focus ng-disabled="!(newPerson.name && newPerson.surname)" ng-click="addTicket(newPerson)" class="btn btn-success top5">
|
||||||
<span class="fa fa-plus-circle vcenter"></span>
|
<span class="fa fa-plus-circle vcenter"></span>
|
||||||
{{'Add' | translate}}
|
{{'Add' | translate}}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -68,8 +68,9 @@ class BaseHandler(tornado.web.RequestHandler):
|
||||||
permissions = {
|
permissions = {
|
||||||
'event|read': True,
|
'event|read': True,
|
||||||
'events|read': True,
|
'events|read': True,
|
||||||
'event:ticket|all': True,
|
'event:tickets|create': True,
|
||||||
'event:persons|all': True,
|
'event:tickets|update': True,
|
||||||
|
'event:tickets|read': True,
|
||||||
'person|create': True
|
'person|create': True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,8 +287,11 @@ class CollectionHandler(BaseHandler):
|
||||||
return self.build_error(status=401, message='insufficient permissions: %s' % permission)
|
return self.build_error(status=401, message='insufficient permissions: %s' % permission)
|
||||||
method = getattr(self, 'handle_get_%s' % resource, None)
|
method = getattr(self, 'handle_get_%s' % resource, None)
|
||||||
if method and callable(method):
|
if method and callable(method):
|
||||||
self.write(method(id_, resource_id, **kwargs))
|
output = method(id_, resource_id, **kwargs)
|
||||||
|
if output is not None:
|
||||||
|
self.write(output)
|
||||||
return
|
return
|
||||||
|
return self.build_error(status=404, message='unable to access resource: %s' % resource)
|
||||||
if id_ is not None:
|
if id_ is not None:
|
||||||
# read a single document
|
# read a single document
|
||||||
permission = '%s|read' % self.document
|
permission = '%s|read' % self.document
|
||||||
|
@ -498,6 +502,11 @@ class EventsHandler(CollectionHandler):
|
||||||
persons = self._filter_results(event.get('persons') or [], self.arguments)
|
persons = self._filter_results(event.get('persons') or [], self.arguments)
|
||||||
return {'persons': persons}
|
return {'persons': persons}
|
||||||
|
|
||||||
|
def handle_get_tickets(self, id_, resource_id=None):
|
||||||
|
if resource_id is None and not self.has_permission('event:tickets|all'):
|
||||||
|
return self.build_error(status=401, message='insufficient permissions: event:tickets|all')
|
||||||
|
return self.handle_get_persons(id_, resource_id)
|
||||||
|
|
||||||
def handle_post_persons(self, id_, person_id, data):
|
def handle_post_persons(self, id_, person_id, data):
|
||||||
# Add a person to the list of persons registered at this event.
|
# Add a person to the list of persons registered at this event.
|
||||||
uuid, arguments = self.uuid_arguments
|
uuid, arguments = self.uuid_arguments
|
||||||
|
@ -519,6 +528,8 @@ class EventsHandler(CollectionHandler):
|
||||||
create=False)
|
create=False)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
handle_post_tickets = handle_post_persons
|
||||||
|
|
||||||
def handle_put_persons(self, id_, person_id, data):
|
def handle_put_persons(self, id_, person_id, data):
|
||||||
# Update an existing entry for a person registered at this event.
|
# Update an existing entry for a person registered at this event.
|
||||||
self._clean_dict(data)
|
self._clean_dict(data)
|
||||||
|
@ -560,6 +571,8 @@ class EventsHandler(CollectionHandler):
|
||||||
self.send_ws_message('event/%s/updates' % id_, json.dumps(ret))
|
self.send_ws_message('event/%s/updates' % id_, json.dumps(ret))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
handle_put_tickets = handle_put_persons
|
||||||
|
|
||||||
def handle_delete_persons(self, id_, person_id):
|
def handle_delete_persons(self, id_, person_id):
|
||||||
# Remove a specific person from the list of persons registered at this event.
|
# Remove a specific person from the list of persons registered at this event.
|
||||||
uuid, arguments = self.uuid_arguments
|
uuid, arguments = self.uuid_arguments
|
||||||
|
@ -575,6 +588,8 @@ class EventsHandler(CollectionHandler):
|
||||||
self.send_ws_message('event/%s/updates' % id_, json.dumps(ret))
|
self.send_ws_message('event/%s/updates' % id_, json.dumps(ret))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
handle_delete_tickets = handle_delete_persons
|
||||||
|
|
||||||
|
|
||||||
class EbCSVImportPersonsHandler(BaseHandler):
|
class EbCSVImportPersonsHandler(BaseHandler):
|
||||||
"""Importer for CSV files exported from eventbrite."""
|
"""Importer for CSV files exported from eventbrite."""
|
||||||
|
@ -823,7 +838,6 @@ def run():
|
||||||
_ws_handler = (r"/ws/+event/+(?P<event_id>[\w\d_-]+)/+updates/?", WebSocketEventUpdatesHandler)
|
_ws_handler = (r"/ws/+event/+(?P<event_id>[\w\d_-]+)/+updates/?", WebSocketEventUpdatesHandler)
|
||||||
_persons_path = r"/persons/?(?P<id_>[\w\d_-]+)?/?(?P<resource>[\w\d_-]+)?/?(?P<resource_id>[\w\d_-]+)?"
|
_persons_path = r"/persons/?(?P<id_>[\w\d_-]+)?/?(?P<resource>[\w\d_-]+)?/?(?P<resource_id>[\w\d_-]+)?"
|
||||||
_events_path = r"/events/?(?P<id_>[\w\d_-]+)?/?(?P<resource>[\w\d_-]+)?/?(?P<resource_id>[\w\d_-]+)?"
|
_events_path = r"/events/?(?P<id_>[\w\d_-]+)?/?(?P<resource>[\w\d_-]+)?/?(?P<resource_id>[\w\d_-]+)?"
|
||||||
_events_path = r"/events/?(?P<id_>[\w\d_-]+)?/?(?P<resource>[\w\d_-]+)?/?(?P<resource_id>[\w\d_-]+)?"
|
|
||||||
application = tornado.web.Application([
|
application = tornado.web.Application([
|
||||||
(_persons_path, PersonsHandler, init_params),
|
(_persons_path, PersonsHandler, init_params),
|
||||||
(r'/v%s%s' % (API_VERSION, _persons_path), PersonsHandler, init_params),
|
(r'/v%s%s' % (API_VERSION, _persons_path), PersonsHandler, init_params),
|
||||||
|
|
Loading…
Reference in a new issue