Merge pull request #92 from alberanid/master
fixes #86: only the changed person is returned, updating an attendee status
This commit is contained in:
commit
6548d7bb77
5 changed files with 36 additions and 16 deletions
|
@ -62,7 +62,7 @@ By default, authentication is required; default username and password are *admin
|
|||
License and copyright
|
||||
=====================
|
||||
|
||||
Copyright 2015 Davide Alberani <da@erlug.linux.it>
|
||||
Copyright 2015-2016 Davide Alberani <da@erlug.linux.it>
|
||||
RaspiBO <info@raspibo.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
28
angular_app/js/controllers.js
vendored
28
angular_app/js/controllers.js
vendored
|
@ -124,10 +124,20 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event',
|
|||
$scope.$watchCollection(function() {
|
||||
return $scope.EventUpdates.data;
|
||||
}, function(prev, old) {
|
||||
if (!($scope.EventUpdates.data && $scope.EventUpdates.data.persons)) {
|
||||
if (!($scope.EventUpdates.data && $scope.EventUpdates.data.update)) {
|
||||
return;
|
||||
}
|
||||
$scope.event.persons = $scope.EventUpdates.data.persons;
|
||||
var data = $scope.EventUpdates.data.update;
|
||||
var person_idx = $scope.event.persons.findIndex(function(el, idx, array) {
|
||||
return data.person_id == el.person_id;
|
||||
});
|
||||
if (person_idx == -1) {
|
||||
$log.warn('unable to find person_id ' + person_id);
|
||||
return;
|
||||
}
|
||||
if ($scope.event.persons[person_idx] != data.person) {
|
||||
$scope.event.persons[person_idx] = data.person;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -229,7 +239,19 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event',
|
|||
data[key] = value;
|
||||
Event.updatePerson(data,
|
||||
function(data) {
|
||||
$scope.event.persons = data;
|
||||
if (!(data && data.person_id && data.person)) {
|
||||
return;
|
||||
}
|
||||
var person_idx = $scope.event.persons.findIndex(function(el, idx, array) {
|
||||
return data.person_id == el.person_id;
|
||||
});
|
||||
if (person_idx == -1) {
|
||||
$log.warn('unable to find person_id ' + person_id);
|
||||
return;
|
||||
}
|
||||
if ($scope.event.persons[person_idx] != data.person) {
|
||||
$scope.event.persons[person_idx] = data.person;
|
||||
}
|
||||
if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
|
|
1
angular_app/js/i18n.js
vendored
1
angular_app/js/i18n.js
vendored
|
@ -3,7 +3,6 @@
|
|||
|
||||
|
||||
eventManApp.config(['$translateProvider', function ($translateProvider) {
|
||||
console.log($translateProvider);
|
||||
$translateProvider.useStaticFilesLoader({
|
||||
prefix: '/static/i18n/',
|
||||
suffix: '.json'
|
||||
|
|
7
angular_app/js/services.js
vendored
7
angular_app/js/services.js
vendored
|
@ -33,10 +33,10 @@ eventManServices.factory('Event', ['$resource',
|
|||
|
||||
updatePerson: {
|
||||
method: 'PUT',
|
||||
isArray: true,
|
||||
isArray: false,
|
||||
url: 'events/:id/persons/:person_id',
|
||||
transformResponse: function(data, headers) {
|
||||
return angular.fromJson(data).event.persons;
|
||||
return angular.fromJson(data);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -156,9 +156,8 @@ eventManApp.factory('EventUpdates', ['$websocket', '$location', '$log',
|
|||
'/ws/' + $location.path() + '/updates');
|
||||
dataStream.onMessage(function(message) {
|
||||
$log.debug('EventUpdates message received');
|
||||
data.persons = angular.fromJson(message.data);
|
||||
data.update = angular.fromJson(message.data);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -433,10 +433,10 @@ class EventsHandler(CollectionHandler):
|
|||
if new_person_data.get('attended'):
|
||||
self.run_triggers('attends', stdin_data=stdin_data, env=env)
|
||||
|
||||
ret = {'action': 'update', 'person_id': person_id, 'person': new_person_data}
|
||||
if old_person_data != new_person_data:
|
||||
self.send_ws_message('event/%s/updates' % id_,
|
||||
json.dumps(doc.get('persons') or []))
|
||||
return {'event': doc}
|
||||
self.send_ws_message('event/%s/updates' % id_, json.dumps(ret))
|
||||
return ret
|
||||
|
||||
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