remove actions collection

This commit is contained in:
Davide Alberani 2015-04-04 13:18:20 +02:00
parent 9bace889d5
commit 134dc550fc
4 changed files with 2 additions and 45 deletions

View file

@ -78,9 +78,6 @@ eventManControllers.controller('PersonDetailsCtrl', ['$scope', '$routeParams', '
function ($scope, $routeParams, Person) { function ($scope, $routeParams, Person) {
if ($routeParams.id) { if ($routeParams.id) {
$scope.person = Person.get($routeParams); $scope.person = Person.get($routeParams);
/* Action.get({person_id: $routeParams.id}, function(data) {
$scope.actions = angular.fromJson(data).actions;
}); */
} }
// store a new Person or update an existing one // store a new Person or update an existing one
$scope.save = function() { $scope.save = function() {

View file

@ -3,13 +3,6 @@
/* Services that are used to interact with the backend. */ /* Services that are used to interact with the backend. */
var eventManServices = angular.module('eventManServices', ['ngResource']); var eventManServices = angular.module('eventManServices', ['ngResource']);
/*
eventManServices.factory('Action', ['$resource',
function($resource) {
return $resource('actions');
}]
);
*/
eventManServices.factory('Event', ['$resource', eventManServices.factory('Event', ['$resource',
function($resource) { function($resource) {

View file

@ -132,7 +132,7 @@ class EventManDB(object):
ret = db[collection].update(data, {'$set': data}, upsert=True) ret = db[collection].update(data, {'$set': data}, upsert=True)
return ret['updatedExisting'] return ret['updatedExisting']
def update(self, collection, _id_or_query, data, operator='$set'): def update(self, collection, _id_or_query, data, operator='$set', create=True):
"""Update an existing document. """Update an existing document.
:param collection: update a document in this collection :param collection: update a document in this collection
@ -156,7 +156,7 @@ class EventManDB(object):
if '_id' in data: if '_id' in data:
del data['_id'] del data['_id']
res = db[collection].find_and_modify(query=_id_or_query, res = db[collection].find_and_modify(query=_id_or_query,
update={operator: data}, full_response=True, new=True,upsert=True) update={operator: data}, full_response=True, new=True, upsert=create)
lastErrorObject = res.get('lastErrorObject') or {} lastErrorObject = res.get('lastErrorObject') or {}
return lastErrorObject.get('updatedExisting', False), res.get('value') or {} return lastErrorObject.get('updatedExisting', False), res.get('value') or {}

View file

@ -97,44 +97,12 @@ class PersonsHandler(CollectionHandler):
"""Handle requests for Persons.""" """Handle requests for Persons."""
collection = 'persons' collection = 'persons'
object_id = 'person_id' object_id = 'person_id'
connect_to = 'events'
connect_id = 'event_id'
def _handle_actions(self, id_, action=None, **kwds):
print id_, kwds
self.request.arguments
query = {self.object_id: self.db.toID(id_)}
if action:
query['action'] = action
actions = self.db.query('actions', query)
return {self.connect_to: results}
def handle_registered(self, id_, **kwds):
return self._handle_actions(id_, 'registered', **kwds)
class EventsHandler(CollectionHandler): class EventsHandler(CollectionHandler):
"""Handle requests for Events.""" """Handle requests for Events."""
collection = 'events' collection = 'events'
object_id = 'event_id' object_id = 'event_id'
connect_to = 'persons'
connect_id = 'person_id'
class ActionsHandler(CollectionHandler):
"""Handle requests for Actions."""
collection = 'actions'
object_id = 'action_id'
def get(self, *args, **kwargs):
params = self.request.arguments or {}
if 'event_id' in params:
params['event_id'] = self.db.toID(params['event_id'][0])
if 'person_id' in params:
params['person_id'] = self.db.toID(params['person_id'][0])
data = self.db.query(self.collection, params)
self.write({'actions': data})
class EbCSVImportPersonsHandler(BaseHandler): class EbCSVImportPersonsHandler(BaseHandler):
@ -220,7 +188,6 @@ def run():
application = tornado.web.Application([ application = tornado.web.Application([
(r"/persons/?(?P<id_>\w+)?/?(?P<resource>\w+)?", PersonsHandler, init_params), (r"/persons/?(?P<id_>\w+)?/?(?P<resource>\w+)?", PersonsHandler, init_params),
(r"/events/?(?P<id_>\w+)?", EventsHandler, init_params), (r"/events/?(?P<id_>\w+)?", EventsHandler, init_params),
(r"/actions/?.*", ActionsHandler, init_params),
(r"/(?:index.html)?", RootHandler, init_params), (r"/(?:index.html)?", RootHandler, init_params),
(r"/ebcsvpersons", EbCSVImportPersonsHandler, init_params), (r"/ebcsvpersons", EbCSVImportPersonsHandler, init_params),
(r'/(.*)', tornado.web.StaticFileHandler, {"path": "angular_app"}) (r'/(.*)', tornado.web.StaticFileHandler, {"path": "angular_app"})