remove actions collection
This commit is contained in:
parent
9bace889d5
commit
134dc550fc
4 changed files with 2 additions and 45 deletions
3
angular_app/js/controllers.js
vendored
3
angular_app/js/controllers.js
vendored
|
@ -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() {
|
||||
|
|
7
angular_app/js/services.js
vendored
7
angular_app/js/services.js
vendored
|
@ -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) {
|
||||
|
|
|
@ -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 {}
|
||||
|
||||
|
|
|
@ -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<id_>\w+)?/?(?P<resource>\w+)?", PersonsHandler, init_params),
|
||||
(r"/events/?(?P<id_>\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"})
|
||||
|
|
Loading…
Reference in a new issue