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>
|
||||
</td>
|
||||
<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>
|
||||
<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('event|delete')" ng-click="remove(event._id)" type="button" class="btn btn-link fa fa-trash fa-lg" title="{{'Delete' | translate}}"></button>
|
||||
</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) {
|
||||
$scope.message = {};
|
||||
$scope.event = {};
|
||||
$scope.ticket = {};
|
||||
|
||||
$scope.newTicket = $state.is('event.ticket.new');
|
||||
|
||||
|
@ -373,7 +374,7 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
|||
|
||||
if ($state.params.ticket_id) {
|
||||
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);
|
||||
personObj.$save(function(p) {
|
||||
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);
|
||||
person._id = $state.params.id; // that's the id of the event, not the person.
|
||||
EventTicket.add(person, function(ticket) {
|
||||
$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},
|
||||
transformResponse: function(data, headers) {
|
||||
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;
|
||||
return data.person;
|
||||
}
|
||||
},
|
||||
|
||||
addTicket: {
|
||||
add: {
|
||||
method: 'POST',
|
||||
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);
|
||||
data = angular.fromJson(data);
|
||||
return data.person;
|
||||
}
|
||||
},
|
||||
|
||||
updateTicket: {
|
||||
update: {
|
||||
method: 'PUT',
|
||||
interceptor : {responseError: $rootScope.errorHandler},
|
||||
isArray: false,
|
||||
|
|
|
@ -18,29 +18,33 @@
|
|||
<form>
|
||||
<div class="input-group input-group-sm">
|
||||
<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 class="input-group input-group-sm top5">
|
||||
<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 class="input-group top5">
|
||||
<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 class="input-group top5">
|
||||
<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 class="input-group top5">
|
||||
<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>
|
||||
|
||||
<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>
|
||||
{{'Add' | translate}}
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -68,9 +68,7 @@ class BaseHandler(tornado.web.RequestHandler):
|
|||
permissions = {
|
||||
'event|read': True,
|
||||
'events|read': True,
|
||||
'event:tickets|create': True,
|
||||
'event:tickets|update': True,
|
||||
'event:tickets|read': True,
|
||||
'event:tickets|all': True,
|
||||
'person|create': True
|
||||
}
|
||||
|
||||
|
@ -532,13 +530,15 @@ class EventsHandler(CollectionHandler):
|
|||
|
||||
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.
|
||||
self._clean_dict(data)
|
||||
uuid, arguments = self.uuid_arguments
|
||||
query = dict([('persons.%s' % k, v) for k, v in arguments.iteritems()])
|
||||
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
|
||||
old_person_data = {}
|
||||
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))
|
||||
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):
|
||||
# Remove a specific person from the list of persons registered at this event.
|
||||
|
|
Loading…
Reference in a new issue