move REST logic into services
This commit is contained in:
parent
7fa4855d22
commit
b6b870fc06
4 changed files with 18 additions and 25 deletions
|
@ -6,7 +6,9 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="/static/js/angular.min.js"></script>
|
||||
<script src="/static/js/angular-route.js"></script>
|
||||
<script src="/static/js/angular-resource.js"></script>
|
||||
<script src="/js/app.js"></script>
|
||||
<script src="/js/services.js"></script>
|
||||
<script src="/js/controllers.js"></script>
|
||||
<title>Event Man(ager)</title>
|
||||
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
@ -17,6 +19,7 @@
|
|||
<div class="main-header" ng-controller="navigation as n">
|
||||
<input type="button" id="events-button" ng-click="n.go('/events')" class="btn btn-link" value="Events" />
|
||||
<input type="button" id="new-event-button" ng-click="n.go('/new-event')" class="btn btn-link" value="Add Event" />
|
||||
<input type="button" id="persons-button" ng-click="n.go('/persons')" class="btn btn-link" value="Persons" />
|
||||
<input type="button" id="persons-button" ng-click="n.go('/new-person')" class="btn btn-link" value="Add Persons" />
|
||||
</div>
|
||||
|
||||
|
|
1
angular_app/js/app.js
vendored
1
angular_app/js/app.js
vendored
|
@ -1,5 +1,6 @@
|
|||
var eventManApp = angular.module('eventManApp', [
|
||||
'ngRoute',
|
||||
'eventManServices',
|
||||
'eventManControllers'
|
||||
]);
|
||||
|
||||
|
|
33
angular_app/js/controllers.js
vendored
33
angular_app/js/controllers.js
vendored
|
@ -12,41 +12,32 @@ eventManControllers.controller('navigation', ['$location',
|
|||
);
|
||||
|
||||
|
||||
eventManControllers.controller('EventsListCtrl', ['$scope', '$http',
|
||||
function ($scope, $http) {
|
||||
$http.get('/events').success(function(data) {
|
||||
$scope.events = data.events;
|
||||
});
|
||||
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event',
|
||||
function ($scope, Event) {
|
||||
$scope.events = Event.all();
|
||||
$scope.orderProp = 'begin-datetime';
|
||||
}]
|
||||
);
|
||||
|
||||
|
||||
eventManControllers.controller('EventDetailsCtrl', ['$scope', '$http', '$routeParams',
|
||||
function ($scope, $http, $routeParams) {
|
||||
$http.get("/events/" + $routeParams.eventID).success(function(data) {
|
||||
|
||||
$scope.event = data.event;
|
||||
});
|
||||
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', '$routeParams',
|
||||
function ($scope, Event, $routeParams) {
|
||||
$scope.event = Event.get($routeParams);
|
||||
}]
|
||||
);
|
||||
|
||||
|
||||
eventManControllers.controller('PersonsListCtrl', ['$scope', '$http',
|
||||
function ($scope, $http) {
|
||||
$http.get('/persons').success(function(data) {
|
||||
$scope.persons = data.persons;
|
||||
});
|
||||
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person',
|
||||
function ($scope, Person) {
|
||||
$scope.persons = Person.all();
|
||||
$scope.orderProp = 'name';
|
||||
}]
|
||||
);
|
||||
|
||||
|
||||
eventManControllers.controller('PersonDetailsCtrl', ['$scope', '$http', '$routeParams',
|
||||
function ($scope, $http, $routeParams) {
|
||||
$http.get("/persons/" + $routeParams.personID).success(function(data) {
|
||||
$scope.person = data.person;
|
||||
});
|
||||
eventManControllers.controller('PersonDetailsCtrl', ['$scope', 'Person', '$routeParams',
|
||||
function ($scope, Person, $routeParams) {
|
||||
$scope.person = Person.get($routeParams);
|
||||
}]
|
||||
);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class PersonsHandler(BaseHandler):
|
|||
@gen.coroutine
|
||||
def get(self, id_=None):
|
||||
if id_ is not None:
|
||||
self.write({'person': MOCKUP_PERSONS[int(id_)]})
|
||||
self.write(MOCKUP_PERSONS[int(id_)])
|
||||
return
|
||||
self.write({'persons': MOCKUP_PERSONS.values()})
|
||||
|
||||
|
@ -75,13 +75,11 @@ class EventsHandler(BaseHandler):
|
|||
@gen.coroutine
|
||||
def get(self, id_=None):
|
||||
if id_ is not None:
|
||||
self.write({'event': MOCKUP_EVENTS[int(id_)]})
|
||||
self.write(MOCKUP_EVENTS[int(id_)])
|
||||
return
|
||||
self.write({'events': MOCKUP_EVENTS.values()})
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
define("port", default=5242, help="run on the given port", type=int)
|
||||
define("data", default=os.path.join(os.path.dirname(__file__), "data"),
|
||||
|
|
Loading…
Reference in a new issue