update ticket
This commit is contained in:
parent
db96460ea7
commit
b29f90747b
5 changed files with 38 additions and 32 deletions
|
@ -42,10 +42,10 @@
|
||||||
{{'Ends:' | translate}} {{event['end-date'] | date:'fullDate' }} {{event['end-time'] | date:'HH:mm'}}</p>
|
{{'Ends:' | translate}} {{event['end-date'] | date:'fullDate' }} {{event['end-time'] | date:'HH:mm'}}</p>
|
||||||
</td>
|
</td>
|
||||||
<td ng-if="hasPermission('persons|read')" class="hcenter">
|
<td ng-if="hasPermission('persons|read')" class="hcenter">
|
||||||
<p><span ng-init="attendeesNr = (event.persons | attendeesFilter).length">{{attendeesNr}}</span> / {{event.persons.length || 0}} ({{((attendeesNr / (event.persons.length || 0) * 100) || 0).toFixed()}}%)</p>
|
<p><span ng-init="attendeesNr = ((event.persons || []) | attendeesFilter).length">{{attendeesNr}}</span> / {{event.persons.length || 0}} ({{((attendeesNr / (event.persons.length || 0) * 100) || 0).toFixed()}}%)</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button ng-if="hasPermission('event:ticket|create')" ng-click="$state.go('event.ticket.new', {id: event._id})" class="btn btn-link fa fa-user-plus" type="button" title="{{'Register' | translate}}"></button>
|
<button ng-if="hasPermission('event:tickets|create')" ng-click="$state.go('event.ticket.new', {id: event._id})" class="btn btn-link fa fa-user-plus" type="button" title="{{'Register' | translate}}"></button>
|
||||||
<button ng-if="hasPermission('persons|update')" ng-click="$state.go('event.info', {id: event._id})" class="btn btn-link fa fa-list" type="button" title="{{'Manage attendees' | translate}}"></button>
|
<button ng-if="hasPermission('persons|update')" ng-click="$state.go('event.info', {id: event._id})" class="btn btn-link fa fa-list" type="button" title="{{'Manage attendees' | translate}}"></button>
|
||||||
<button ng-if="hasPermission('event|delete')" ng-click="remove(event._id)" type="button" class="btn btn-link fa fa-trash fa-lg" title="{{'Delete' | translate}}"></button>
|
<button ng-if="hasPermission('event|delete')" ng-click="remove(event._id)" type="button" class="btn btn-link fa fa-trash fa-lg" title="{{'Delete' | translate}}"></button>
|
||||||
</td>
|
</td>
|
||||||
|
|
19
angular_app/js/controllers.js
vendored
19
angular_app/js/controllers.js
vendored
|
@ -363,6 +363,7 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
||||||
function ($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.message = {};
|
||||||
$scope.event = {};
|
$scope.event = {};
|
||||||
|
$scope.ticket = {};
|
||||||
|
|
||||||
$scope.newTicket = $state.is('event.ticket.new');
|
$scope.newTicket = $state.is('event.ticket.new');
|
||||||
|
|
||||||
|
@ -373,7 +374,7 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
||||||
|
|
||||||
if ($state.params.ticket_id) {
|
if ($state.params.ticket_id) {
|
||||||
EventTicket.get({id: $state.params.id, ticket_id: $state.params.ticket_id}, function(data) {
|
EventTicket.get({id: $state.params.id, ticket_id: $state.params.ticket_id}, function(data) {
|
||||||
$scope.newPerson = data.person;
|
$scope.ticket = data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,11 +382,19 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
||||||
var personObj = new Person(person);
|
var personObj = new Person(person);
|
||||||
personObj.$save(function(p) {
|
personObj.$save(function(p) {
|
||||||
person.person_id = p._id;
|
person.person_id = p._id;
|
||||||
person._id = $stateParams.id; // that's the id of the event, not the person.
|
person._id = $state.params.id; // that's the id of the event, not the person.
|
||||||
EventTicket.addTicket(person, function(p) {
|
EventTicket.add(person, function(ticket) {
|
||||||
$log.debug(p);
|
$log.debug(ticket);
|
||||||
|
$state.go('event.ticket.edit', {ticket_id: ticket._id});
|
||||||
});
|
});
|
||||||
$scope.newPerson = {};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.updateTicket = function(ticket) {
|
||||||
|
var data = angular.copy(ticket);
|
||||||
|
data.ticket_id = data._id;
|
||||||
|
data._id = $state.params.id;
|
||||||
|
EventTicket.update(data, function(t) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}]
|
}]
|
||||||
|
|
18
angular_app/js/services.js
vendored
18
angular_app/js/services.js
vendored
|
@ -107,31 +107,23 @@ eventManServices.factory('EventTicket', ['$resource', '$rootScope',
|
||||||
interceptor : {responseError: $rootScope.errorHandler},
|
interceptor : {responseError: $rootScope.errorHandler},
|
||||||
transformResponse: function(data, headers) {
|
transformResponse: function(data, headers) {
|
||||||
data = angular.fromJson(data);
|
data = angular.fromJson(data);
|
||||||
convert_dates(data);
|
return data.person;
|
||||||
// strip empty keys.
|
|
||||||
angular.forEach(data.persons || [], function(person, person_idx) {
|
|
||||||
angular.forEach(person, function(value, key) {
|
|
||||||
if (value === "") {
|
|
||||||
delete person[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addTicket: {
|
add: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
interceptor : {responseError: $rootScope.errorHandler},
|
interceptor : {responseError: $rootScope.errorHandler},
|
||||||
isArray: false,
|
isArray: false,
|
||||||
url: 'events/:id/tickets/:ticket_id',
|
url: 'events/:id/tickets/:ticket_id',
|
||||||
params: {uuid: $rootScope.app_uuid},
|
params: {uuid: $rootScope.app_uuid},
|
||||||
transformResponse: function(data, headers) {
|
transformResponse: function(data, headers) {
|
||||||
return angular.fromJson(data);
|
data = angular.fromJson(data);
|
||||||
|
return data.person;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTicket: {
|
update: {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
interceptor : {responseError: $rootScope.errorHandler},
|
interceptor : {responseError: $rootScope.errorHandler},
|
||||||
isArray: false,
|
isArray: false,
|
||||||
|
|
|
@ -18,29 +18,33 @@
|
||||||
<form>
|
<form>
|
||||||
<div class="input-group input-group-sm">
|
<div class="input-group input-group-sm">
|
||||||
<span class="input-group-addon min70-compact">{{'Name' | translate}}</span>
|
<span class="input-group-addon min70-compact">{{'Name' | translate}}</span>
|
||||||
<input type="text" class="form-control" placeholder="{{'Name' | translate}}" ng-model="newPerson.name" ng-required="1">
|
<input type="text" class="form-control" placeholder="{{'Name' | translate}}" ng-model="ticket.name" ng-required="1">
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group input-group-sm top5">
|
<div class="input-group input-group-sm top5">
|
||||||
<span class="input-group-addon min70-compact">{{'Surname' | translate}}</span>
|
<span class="input-group-addon min70-compact">{{'Surname' | translate}}</span>
|
||||||
<input type="text" class="form-control" placeholder="{{'Surname' | translate}}" ng-model="newPerson.surname">
|
<input type="text" class="form-control" placeholder="{{'Surname' | translate}}" ng-model="ticket.surname">
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group top5">
|
<div class="input-group top5">
|
||||||
<span class="input-group-addon min70-compact">{{'Email' | translate}}</span>
|
<span class="input-group-addon min70-compact">{{'Email' | translate}}</span>
|
||||||
<input type="email" name="email" class="form-control" placeholder="{{'name.surname@example.com' | translate}}" ng-model="newPerson.email">
|
<input type="email" name="email" class="form-control" placeholder="{{'name.surname@example.com' | translate}}" ng-model="ticket.email">
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group top5">
|
<div class="input-group top5">
|
||||||
<span class="input-group-addon min70-compact">{{'Company' | translate}}</span>
|
<span class="input-group-addon min70-compact">{{'Company' | translate}}</span>
|
||||||
<input name="company" class="form-control" placeholder="{{'Acme Corporation' | translate}}" ng-model="newPerson.company">
|
<input name="company" class="form-control" placeholder="{{'Acme Corporation' | translate}}" ng-model="ticket.company">
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group top5">
|
<div class="input-group top5">
|
||||||
<span class="input-group-addon min70-compact">{{'Job' | translate}}</span>
|
<span class="input-group-addon min70-compact">{{'Job' | translate}}</span>
|
||||||
<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="ticket.job_title">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button reset-focus ng-disabled="!(newPerson.name && newPerson.surname)" ng-click="addTicket(newPerson)" class="btn btn-success top5">
|
<button ng-if="!(ticket && ticket._id)" reset-focus ng-disabled="!(ticket.name && ticket.surname)" ng-click="addTicket(ticket)" 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>
|
||||||
|
<button ng-if="ticket._id" reset-focus ng-disabled="!(ticket.name && ticket.surname)" ng-click="updateTicket(ticket)" class="btn btn-success top5">
|
||||||
|
<span class="fa fa-save vcenter"></span>
|
||||||
|
{{'Update' | translate}}
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -68,9 +68,7 @@ class BaseHandler(tornado.web.RequestHandler):
|
||||||
permissions = {
|
permissions = {
|
||||||
'event|read': True,
|
'event|read': True,
|
||||||
'events|read': True,
|
'events|read': True,
|
||||||
'event:tickets|create': True,
|
'event:tickets|all': True,
|
||||||
'event:tickets|update': True,
|
|
||||||
'event:tickets|read': True,
|
|
||||||
'person|create': True
|
'person|create': True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,13 +530,15 @@ class EventsHandler(CollectionHandler):
|
||||||
|
|
||||||
handle_post_tickets = handle_post_persons
|
handle_post_tickets = handle_post_persons
|
||||||
|
|
||||||
def handle_put_persons(self, id_, person_id, data):
|
def handle_put_persons(self, id_, person_id, data, ticket=False):
|
||||||
# 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)
|
||||||
uuid, arguments = self.uuid_arguments
|
uuid, arguments = self.uuid_arguments
|
||||||
query = dict([('persons.%s' % k, v) for k, v in arguments.iteritems()])
|
query = dict([('persons.%s' % k, v) for k, v in arguments.iteritems()])
|
||||||
query['_id'] = id_
|
query['_id'] = id_
|
||||||
if person_id is not None:
|
if ticket:
|
||||||
|
query['persons._id'] = person_id
|
||||||
|
elif person_id is not None:
|
||||||
query['persons.person_id'] = person_id
|
query['persons.person_id'] = person_id
|
||||||
old_person_data = {}
|
old_person_data = {}
|
||||||
current_event = self.db.query(self.collection, query)
|
current_event = self.db.query(self.collection, query)
|
||||||
|
@ -573,7 +573,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_put_tickets(self, id_, person_id, data):
|
||||||
|
return self.handle_put_persons(id_, person_id, data, True)
|
||||||
|
|
||||||
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.
|
||||||
|
|
Loading…
Reference in a new issue