Add view to get categories with their expenses and revenues.

This commit is contained in:
Alexis Lahouze 2015-06-15 13:06:32 +02:00
parent f9acff50d1
commit 68ef144474

View File

@ -130,5 +130,22 @@ class EntryResource(Resource):
return entry return entry
category_resource_fields = {
'category': fields.String,
'expenses': fields.Float,
'revenues': fields.Float
}
class CategoriesResource(Resource):
@session_aware
@marshal_with_field(fields.List(Object(category_resource_fields)))
def get(self, session):
kwargs = range_parser.parse_args()
return Operation.get_categories_for_range(session, **kwargs)
api_api.add_resource(EntryListResource, "/entries") api_api.add_resource(EntryListResource, "/entries")
api_api.add_resource(EntryResource, "/entries/<int:entry_id>") api_api.add_resource(EntryResource, "/entries/<int:entry_id>")
api_api.add_resource(CategoriesResource, "/categories")