Skip to content

Commit

Permalink
new addresses me retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 18, 2016
1 parent 50ba640 commit 7828d71
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/budy/controllers/api/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,12 @@ class AccountApiController(root.RootApiController):
def me(self):
account = budy.BudyAccount.from_session(map = True)
return account

@appier.route("/api/accounts/me/addresses", "GET", json = True)
@appier.ensure(token = "user")
def addresses_me(self):
account = budy.BudyAccount.from_session(
eager = ("addresses",),
map = True
)
return account["addresses"]
7 changes: 7 additions & 0 deletions src/budy/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class BudyAccount(appier_extras.admin.Account):

name = appier.field()

addresses = appier.field(
type = appier.references(
"Address",
name = "id"
)
)

@classmethod
def _build(cls, model, map):
id = model.get("id", None)
Expand Down
8 changes: 7 additions & 1 deletion src/budy/models/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,16 @@ class Address(base.BudyBase):

state = appier.field()

country = appier.field()
country = appier.field(
meta = "country"
)

phone_number = appier.field()

vat_number = appier.field()

neighborhood = appier.field()

@classmethod
def list_names(cls):
return ["id", "first_name", "last_name", "address", "country"]

0 comments on commit 7828d71

Please sign in to comment.