edit ticket form
This commit is contained in:
parent
88078f64df
commit
db96460ea7
4 changed files with 58 additions and 30 deletions
27
angular_app/js/app.js
vendored
27
angular_app/js/app.js
vendored
|
@ -109,6 +109,20 @@ eventManApp.config(['$stateProvider', '$urlRouterProvider',
|
|||
templateUrl: 'event-info.html',
|
||||
controller: 'EventDetailsCtrl'
|
||||
})
|
||||
.state('event.ticket', {
|
||||
url: '/:id/ticket',
|
||||
templateUrl: 'ticket-main.html'
|
||||
})
|
||||
.state('event.ticket.new', {
|
||||
url: '/new',
|
||||
templateUrl: 'ticket-edit.html',
|
||||
controller: 'EventTicketsCtrl'
|
||||
})
|
||||
.state('event.ticket.edit', {
|
||||
url: '/:ticket_id/edit',
|
||||
templateUrl: 'ticket-edit.html',
|
||||
controller: 'EventTicketsCtrl'
|
||||
})
|
||||
.state('persons', {
|
||||
url: '/persons',
|
||||
templateUrl: 'persons-list.html',
|
||||
|
@ -133,19 +147,6 @@ eventManApp.config(['$stateProvider', '$urlRouterProvider',
|
|||
templateUrl: 'person-info.html',
|
||||
controller: 'PersonDetailsCtrl'
|
||||
})
|
||||
.state('event.ticket', {
|
||||
templateUrl: 'ticket-main.html'
|
||||
})
|
||||
.state('event.ticket.new', {
|
||||
url: '/:id/ticket/new',
|
||||
templateUrl: 'ticket-edit.html',
|
||||
controller: 'EventTicketsCtrl'
|
||||
})
|
||||
.state('event.ticket.edit', {
|
||||
url: '/:id/ticket/edit',
|
||||
templateUrl: 'ticket-edit.html',
|
||||
controller: 'EventTicketsCtrl'
|
||||
})
|
||||
.state('import', {
|
||||
url: '/import',
|
||||
templateUrl: 'import-main.html'
|
||||
|
|
12
angular_app/js/controllers.js
vendored
12
angular_app/js/controllers.js
vendored
|
@ -366,15 +366,21 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
|||
|
||||
$scope.newTicket = $state.is('event.ticket.new');
|
||||
|
||||
if ($stateParams.id) {
|
||||
$scope.event = Event.get($stateParams, function() {
|
||||
if ($state.params.id) {
|
||||
$scope.event = Event.get({id: $state.params.id}, function() {
|
||||
});
|
||||
}
|
||||
|
||||
if ($state.params.ticket_id) {
|
||||
EventTicket.get({id: $state.params.id, ticket_id: $state.params.ticket_id}, function(data) {
|
||||
$scope.newPerson = data.person;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.addTicket = function(person) {
|
||||
var personObj = new Person(person);
|
||||
personObj.$save(function(p) {
|
||||
person.person_id = person._id;
|
||||
person.person_id = p._id;
|
||||
person._id = $stateParams.id; // that's the id of the event, not the person.
|
||||
EventTicket.addTicket(person, function(p) {
|
||||
$log.debug(p);
|
||||
|
|
37
angular_app/js/services.js
vendored
37
angular_app/js/services.js
vendored
|
@ -99,16 +99,24 @@ eventManServices.factory('Event', ['$resource', '$rootScope',
|
|||
|
||||
eventManServices.factory('EventTicket', ['$resource', '$rootScope',
|
||||
function($resource, $rootScope) {
|
||||
return $resource('events/:id/tickets', {id: '@_id', person_id: '@person_id'}, {
|
||||
return $resource('events/:id/tickets', {id: '@_id', ticket_id: '@ticket_id'}, {
|
||||
|
||||
updateTicket: {
|
||||
method: 'PUT',
|
||||
get: {
|
||||
method: 'GET',
|
||||
url: 'events/:id/tickets/:ticket_id',
|
||||
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);
|
||||
data = angular.fromJson(data);
|
||||
convert_dates(data);
|
||||
// strip empty keys.
|
||||
angular.forEach(data.persons || [], function(person, person_idx) {
|
||||
angular.forEach(person, function(value, key) {
|
||||
if (value === "") {
|
||||
delete person[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
return data;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -116,7 +124,18 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
|
|||
method: 'POST',
|
||||
interceptor : {responseError: $rootScope.errorHandler},
|
||||
isArray: false,
|
||||
url: 'events/:id/tickets/:person_id',
|
||||
url: 'events/:id/tickets/:ticket_id',
|
||||
params: {uuid: $rootScope.app_uuid},
|
||||
transformResponse: function(data, headers) {
|
||||
return angular.fromJson(data);
|
||||
}
|
||||
},
|
||||
|
||||
updateTicket: {
|
||||
method: 'PUT',
|
||||
interceptor : {responseError: $rootScope.errorHandler},
|
||||
isArray: false,
|
||||
url: 'events/:id/tickets/:ticket_id',
|
||||
params: {uuid: $rootScope.app_uuid},
|
||||
transformResponse: function(data, headers) {
|
||||
return angular.fromJson(data);
|
||||
|
@ -127,7 +146,7 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
|
|||
method: 'DELETE',
|
||||
interceptor : {responseError: $rootScope.errorHandler},
|
||||
isArray: false,
|
||||
url: 'events/:_id/tickets/:person_id',
|
||||
url: 'events/:_id/tickets/:ticket_id',
|
||||
params: {uuid: $rootScope.app_uuid},
|
||||
transformResponse: function(data, headers) {
|
||||
return angular.fromJson(data);
|
||||
|
|
|
@ -218,8 +218,8 @@ class CollectionHandler(BaseHandler):
|
|||
return doc.get('seq', 0)
|
||||
|
||||
def gen_id(self, seq='ids'):
|
||||
t = str(time.time())
|
||||
seq = str(self.get_next_seq(seq)).replace('.', '_')
|
||||
t = str(time.time()).replace('.', '_')
|
||||
seq = str(self.get_next_seq(seq))
|
||||
rand = ''.join([random.choice(self._id_chars) for x in xrange(32)])
|
||||
return '-'.join((t, seq, rand))
|
||||
|
||||
|
@ -492,20 +492,22 @@ class EventsHandler(CollectionHandler):
|
|||
return person
|
||||
return {}
|
||||
|
||||
def handle_get_persons(self, id_, resource_id=None):
|
||||
def handle_get_persons(self, id_, resource_id=None, match_query=None):
|
||||
# Return every person registered at this event, or the information
|
||||
# about a specific person.
|
||||
query = {'_id': id_}
|
||||
event = self.db.query('events', query)[0]
|
||||
if match_query is None:
|
||||
match_query = resource_id
|
||||
if resource_id:
|
||||
return {'person': self._get_person_data(resource_id, event.get('persons') or [])}
|
||||
return {'person': self._get_person_data(match_query, event.get('persons') or [])}
|
||||
persons = self._filter_results(event.get('persons') or [], self.arguments)
|
||||
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)
|
||||
return self.handle_get_persons(id_, resource_id, {'_id': resource_id})
|
||||
|
||||
def handle_post_persons(self, id_, person_id, data):
|
||||
# Add a person to the list of persons registered at this event.
|
||||
|
|
Loading…
Reference in a new issue