summaryrefslogtreecommitdiff
path: root/indoteknik_api/models/res_users.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2022-12-27 17:25:32 +0700
committerIT Fixcomart <it@fixcomart.co.id>2022-12-27 17:25:32 +0700
commit2f4860787fc09d07cf538bb73f897c9b897b025e (patch)
tree63f437b3fe3fed63a9d92cb667f8fb9c340681e7 /indoteknik_api/models/res_users.py
parentf4119b3e936af798138f57df5a4b8294536255a1 (diff)
Update verify user token and get user address api
Diffstat (limited to 'indoteknik_api/models/res_users.py')
-rw-r--r--indoteknik_api/models/res_users.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py
index 608ec4df..2cab29bd 100644
--- a/indoteknik_api/models/res_users.py
+++ b/indoteknik_api/models/res_users.py
@@ -16,3 +16,36 @@ class ResUsers(models.Model):
return data
+ def api_address_response(self, user):
+ data = {
+ 'id': user.id,
+ 'name': user.name,
+ 'mobile': user.mobile,
+ 'street': user.street,
+ 'street2': user.street2,
+ 'city': None,
+ 'district': None,
+ 'sub_district': None,
+ 'zip': user.zip
+ }
+
+ if user.kota_id:
+ data['city'] = {
+ 'id': user.kota_id.id,
+ 'name': user.kota_id.name
+ } or None
+
+ if user.kecamatan_id:
+ data['district'] = {
+ 'id': user.kecamatan_id.id,
+ 'name': user.kecamatan_id.name
+ }
+
+ if user.kelurahan_id:
+ data['sub_district'] = {
+ 'id': user.kelurahan_id.id,
+ 'name': user.kelurahan_id.name
+ }
+
+ return data
+