diff --git a/angular_app/js/controllers.js b/angular_app/js/controllers.js index e4271b7..ce0f464 100644 --- a/angular_app/js/controllers.js +++ b/angular_app/js/controllers.js @@ -78,9 +78,6 @@ eventManControllers.controller('PersonDetailsCtrl', ['$scope', '$routeParams', ' function ($scope, $routeParams, Person) { if ($routeParams.id) { $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 $scope.save = function() { diff --git a/angular_app/js/services.js b/angular_app/js/services.js index b6ff1be..e9b4c7b 100644 --- a/angular_app/js/services.js +++ b/angular_app/js/services.js @@ -3,13 +3,6 @@ /* Services that are used to interact with the backend. */ var eventManServices = angular.module('eventManServices', ['ngResource']); -/* -eventManServices.factory('Action', ['$resource', - function($resource) { - return $resource('actions'); - }] -); -*/ eventManServices.factory('Event', ['$resource', function($resource) { diff --git a/backend.py b/backend.py index 5eb4867..651f79f 100644 --- a/backend.py +++ b/backend.py @@ -132,7 +132,7 @@ class EventManDB(object): ret = db[collection].update(data, {'$set': data}, upsert=True) 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. :param collection: update a document in this collection @@ -156,7 +156,7 @@ class EventManDB(object): if '_id' in data: del data['_id'] 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 {} return lastErrorObject.get('updatedExisting', False), res.get('value') or {} diff --git a/eventman_server.py b/eventman_server.py index 078f9b1..3b8f3e7 100755 --- a/eventman_server.py +++ b/eventman_server.py @@ -97,44 +97,12 @@ class PersonsHandler(CollectionHandler): """Handle requests for Persons.""" collection = 'persons' 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): """Handle requests for Events.""" collection = 'events' 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): @@ -220,7 +188,6 @@ def run(): application = tornado.web.Application([ (r"/persons/?(?P\w+)?/?(?P\w+)?", PersonsHandler, init_params), (r"/events/?(?P\w+)?", EventsHandler, init_params), - (r"/actions/?.*", ActionsHandler, init_params), (r"/(?:index.html)?", RootHandler, init_params), (r"/ebcsvpersons", EbCSVImportPersonsHandler, init_params), (r'/(.*)', tornado.web.StaticFileHandler, {"path": "angular_app"})