Skip to content

Commit

Permalink
new order support
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 18, 2016
1 parent e32b67e commit c73c185
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/budy/controllers/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from . import color
from . import country
from . import media
from . import order
from . import product
from . import root
from . import subscription
Expand All @@ -54,6 +55,7 @@
from .color import ColorApiController
from .country import CountryApiController
from .media import MediaApiController
from .order import OrderApiController
from .product import ProductApiController
from .root import RootApiController
from .subscription import SubscriptionApiController
70 changes: 70 additions & 0 deletions src/budy/controllers/api/order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Hive Budy
# Copyright (c) 2008-2016 Hive Solutions Lda.
#
# This file is part of Hive Budy.
#
# Hive Budy is free software: you can redistribute it and/or modify
# it under the terms of the Apache License as published by the Apache
# Foundation, either version 2.0 of the License, or (at your option) any
# later version.
#
# Hive Budy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Apache License for more details.
#
# You should have received a copy of the Apache License along with
# Hive Budy. If not, see <http://www.apache.org/licenses/>.

__author__ = "João Magalhães <joamag@hive.pt>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2016 Hive Solutions Lda."
""" The copyright for the module """

__license__ = "Apache License, Version 2.0"
""" The license for the module """

import appier

import budy

from . import root

class OrderApiController(root.RootApiController):

@appier.route("/api/orders", "GET", json = True)
@appier.ensure(token = "admin")
def list(self):
object = appier.get_object(alias = True, find = True)
products = budy.Order.find(
eager = ("lines", "lines.product"),
map = True,
**object
)
return products

@appier.route("/api/orders/<str:key>", "GET", json = True)
def show(self, key):
order = budy.Order.get(key = key)
order.refresh_s(
currency = self.currency,
country = self.country
)
order = order.reload(
eager = ("lines", "lines.product"),
map = True
)
return order

0 comments on commit c73c185

Please sign in to comment.