| Line 1... |
Line 1... |
| 1 |
from shop2020.thriftpy.model.v1.user.ttypes import Address as TAddress,\
|
1 |
from shop2020.thriftpy.model.v1.user.ttypes import Address as TAddress,\
|
| 2 |
UserContext as TUserContext, Phone as TPhone, SocialHandles as TSocialHandles,\
|
2 |
Phone as TPhone, SocialHandles as TSocialHandles,\
|
| 3 |
UserState as TUserState, UserPrimaryInfo as TUserPrimaryInfo
|
3 |
UserState as TUserState, User as TUser, Cart as TCart, LineItem as TLineItem, Sex as TSex
|
| 4 |
from shop2020.model.v1.user.impl.Dataservice import Address
|
- |
|
| 5 |
from shop2020.utils.Utils import to_java_date
|
4 |
from shop2020.utils.Utils import to_java_date
|
| 6 |
|
5 |
|
| 7 |
def to_t_address(address):
|
6 |
def to_t_address(address):
|
| 8 |
t_address = TAddress()
|
7 |
t_address = TAddress()
|
| 9 |
t_address.id = address.id
|
8 |
t_address.id = address.id
|
| Line 17... |
Line 16... |
| 17 |
t_address.enabled = address.enabled
|
16 |
t_address.enabled = address.enabled
|
| 18 |
t_address.type = address.type
|
17 |
t_address.type = address.type
|
| 19 |
t_address.addedOn = to_java_date(address.added_on)
|
18 |
t_address.addedOn = to_java_date(address.added_on)
|
| 20 |
t_address.name = address.name
|
19 |
t_address.name = address.name
|
| 21 |
t_address.phone = address.phone
|
20 |
t_address.phone = address.phone
|
| 22 |
return t_address
|
21 |
return t_address
|
| 23 |
|
- |
|
| 24 |
|
- |
|
| 25 |
def to_t_user_context(user_context):
|
- |
|
| 26 |
t_user_context = TUserContext()
|
- |
|
| 27 |
t_user_context.id = user_context.id
|
- |
|
| 28 |
t_user_context.sessionid = user_context.session_id
|
- |
|
| 29 |
t_user_context.primaryInfo = to_t_primary_info(user_context.primary_info)
|
- |
|
| 30 |
t_user_context.internalInfo = to_t_internal_info(user_context.internal_info)
|
- |
|
| 31 |
t_user_context.userState = to_t_user_state(user_context.state)
|
- |
|
| 32 |
return t_user_context
|
- |
|
| 33 |
|
- |
|
| 34 |
|
22 |
|
| 35 |
def to_t_primary_info(primary_info):
|
23 |
def to_t_user(user):
|
| 36 |
t_primary_info = TUserPrimaryInfo()
|
24 |
t_user = TUser()
|
| 37 |
t_primary_info.userId = primary_info.user.id
|
25 |
t_user.userId = user.id
|
| 38 |
t_primary_info.title = primary_info.title
|
- |
|
| 39 |
t_primary_info.firstName = primary_info.first_name
|
- |
|
| 40 |
t_primary_info.middleName = primary_info.middle_name
|
- |
|
| 41 |
t_primary_info.lastName = primary_info.last_name
|
26 |
t_user.name = user.name
|
| 42 |
t_primary_info.dateOfBirth = to_java_date(primary_info.date_of_birth)
|
- |
|
| 43 |
t_primary_info.pictureUrl = primary_info.picture_id
|
- |
|
| 44 |
t_primary_info.email = primary_info.email
|
27 |
t_user.email = user.email
|
| 45 |
t_primary_info.userHandle = primary_info.user_handle
|
28 |
t_user.sex = user.sex
|
| - |
|
29 |
|
| 46 |
t_primary_info.socialHandles = to_t_social_handle(primary_info.social_handles)
|
30 |
t_user.socialHandles = to_t_social_handle(user.social_handles)
|
| 47 |
t_primary_info.shipmentOption = primary_info.shipment_option
|
- |
|
| 48 |
t_primary_info.occupation = primary_info.occupation
|
31 |
t_user.communicationEmail = user.communication_email
|
| 49 |
t_primary_info.hintQuestion = primary_info.hint_question
|
32 |
t_user.defaultAddressId = user.default_address_id
|
| 50 |
t_primary_info.hintAnswer = primary_info.hint_answer
|
33 |
t_user.isAnonymous = user.is_anonymous
|
| 51 |
t_primary_info.communicationEmail = primary_info.communication_email
|
34 |
t_user.activeCartId = user.active_cart_id
|
| 52 |
t_primary_info.defaultAddressId = primary_info.default_address_id
|
35 |
t_user.dateOfBirth = to_java_date(user.date_of_birth)
|
| 53 |
|
- |
|
| 54 |
#put all addresses
|
36 |
#put all addresses
|
| 55 |
if primary_info.addresses:
|
37 |
if user.addresses:
|
| 56 |
t_primary_info.addresses = list()
|
38 |
t_user.addresses = list()
|
| 57 |
for address in primary_info.addresses:
|
39 |
for address in user.addresses:
|
| 58 |
t_primary_info.addresses.append(to_t_address(address))
|
40 |
t_user.addresses.append(to_t_address(address))
|
| 59 |
return t_primary_info
|
41 |
return t_user
|
| 60 |
|
- |
|
| 61 |
pass
|
- |
|
| 62 |
|
42 |
|
| 63 |
def to_t_internal_info(internal_info):
|
43 |
def to_t_internal_info(internal_info):
|
| 64 |
pass
|
44 |
pass
|
| 65 |
|
45 |
|
| 66 |
def to_t_user_state(user_state):
|
46 |
def to_t_user_state(user_state):
|
| 67 |
t_user_state = TUserState()
|
47 |
t_user_state = TUserState()
|
| 68 |
t_user_state.userId = user_state.user.id
|
48 |
t_user_state.userId = user_state.user.id
|
| 69 |
t_user_state.isEmailVerified = user_state.is_email_verified
|
- |
|
| 70 |
t_user_state.lastLogin = to_java_date(user_state.last_login_timestamp)
|
49 |
t_user_state.lastLogin = to_java_date(user_state.last_login)
|
| 71 |
t_user_state.lastLogout = to_java_date(user_state.last_logout)
|
50 |
t_user_state.lastLogout = to_java_date(user_state.last_logout)
|
| 72 |
t_user_state.emailVerificationSentOn = to_java_date(user_state.email_verification_sent_on)
|
51 |
t_user_state.emailVerificationSentOn = to_java_date(user_state.email_verification_sent_on)
|
| 73 |
t_user_state.smsVerificationSentOn = to_java_date(user_state.sms_verification_sent_on)
|
52 |
t_user_state.smsVerificationSentOn = to_java_date(user_state.sms_verification_sent_on)
|
| - |
|
53 |
t_user_state.isEmailVerified = user_state.is_email_verified
|
| 74 |
t_user_state.isSMSVerified = user_state.is_sms_verified
|
54 |
t_user_state.isSMSVerified = user_state.is_sms_verified
|
| 75 |
t_user_state.activeSince = to_java_date(user_state.active_since)
|
55 |
t_user_state.activeSince = to_java_date(user_state.active_since)
|
| 76 |
t_user_state.isLoggedIn = user_state.is_logged_in
|
- |
|
| 77 |
t_user_state.shoppingCartHandle = user_state.current_shopping_cart
|
- |
|
| 78 |
t_user_state.status = user_state.account_status
|
56 |
t_user_state.status = user_state.account_status
|
| 79 |
return t_user_state
|
57 |
return t_user_state
|
| 80 |
|
58 |
|
| 81 |
def to_t_phone(phone):
|
59 |
def to_t_phone(phone):
|
| 82 |
t_phone = TPhone()
|
60 |
t_phone = TPhone()
|
| Line 94... |
Line 72... |
| 94 |
t_socialHandle.facebook = social_handle.handle
|
72 |
t_socialHandle.facebook = social_handle.handle
|
| 95 |
if social_handle.service.name == "OpenSocial":
|
73 |
if social_handle.service.name == "OpenSocial":
|
| 96 |
t_socialHandle.opensocial = social_handle.handle
|
74 |
t_socialHandle.opensocial = social_handle.handle
|
| 97 |
if social_handle.service.name == "Twitter":
|
75 |
if social_handle.service.name == "Twitter":
|
| 98 |
t_socialHandle.twitter = social_handle.handle
|
76 |
t_socialHandle.twitter = social_handle.handle
|
| 99 |
return t_socialHandle
|
- |
|
| 100 |
|
77 |
return t_socialHandle
|
| - |
|
78 |
|
| - |
|
79 |
def to_t_cart(cart):
|
| - |
|
80 |
t_cart = TCart()
|
| - |
|
81 |
if cart:
|
| - |
|
82 |
t_cart.id = cart.id
|
| - |
|
83 |
t_cart.status = cart.cart_status
|
| - |
|
84 |
lines = []
|
| - |
|
85 |
if cart.lines:
|
| - |
|
86 |
for line in cart.lines:
|
| - |
|
87 |
lines.append(to_t_line(line))
|
| - |
|
88 |
t_cart.lines = lines
|
| - |
|
89 |
t_cart.createdOn = to_java_date(cart.created_on)
|
| - |
|
90 |
t_cart.updatedOn = to_java_date(cart.updated_on)
|
| - |
|
91 |
t_cart.userId = cart.user_id
|
| - |
|
92 |
t_cart.addressId = cart.address_id
|
| - |
|
93 |
t_cart.committedOn = to_java_date(cart.committed_on)
|
| - |
|
94 |
return t_cart
|
| - |
|
95 |
|
| - |
|
96 |
def to_t_line(line_item):
|
| - |
|
97 |
t_line_item = TLineItem()
|
| - |
|
98 |
if line_item:
|
| - |
|
99 |
t_line_item.id = line_item.id
|
| - |
|
100 |
t_line_item.itemId = line_item.item_id
|
| - |
|
101 |
t_line_item.quantity = line_item.quantity
|
| - |
|
102 |
t_line_item.createdOn = to_java_date(line_item.created_on)
|
| - |
|
103 |
t_line_item.updatedOn = to_java_date(line_item.updated_on)
|
| - |
|
104 |
t_line_item.lineStatus = line_item.line_status
|
| - |
|
105 |
return t_line_item
|
| - |
|
106 |
|
| - |
|
107 |
|
| 101 |
|
108 |
|