Subversion Repositories SmartDukaan

Rev

Rev 513 | Rev 557 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
130 ashish 1
'''
2
Created on 28-Apr-2010
3
 
4
@author: ashish
5
'''
6
from shop2020.utils.Utils import log_entry
7
from shop2020.model.v1.user.impl.DataAccessors import add_social_handle,\
8
    delete_user, update_password, set_user_as_logged_out, set_user_as_logged_in,\
9
    remove_address_for_user, add_address_for_user, add_ip_address_for_user,\
10
    user_exists, authenticate_user, get_context, get_internal_info,\
11
    get_primary_info, get_state, get_context_by_email_or_handle,\
404 rajveer 12
    get_context_by_session_id, get_context_by_id, create_context, update_context,\
515 rajveer 13
    initialize, set_default_address
130 ashish 14
from shop2020.model.v1.user.impl.Converters import to_t_user_context,\
15
    to_t_internal_info, to_t_primary_info, to_t_user_state
16
 
17
class UserContextServiceHandler:
18
 
404 rajveer 19
 
20
    def __init__(self):
21
        initialize()
22
 
130 ashish 23
    """
24
    User session context service handler
25
    """
26
    def createContext(self, context, updateExisting):
27
        """
28
        Parameters:
29
         - context
30
         - updateExisting
31
        """
32
        log_entry(self, "create or update context")
33
        if not updateExisting:
34
            id = create_context(context)
35
        else:
36
            id = update_context(context)
37
 
38
        return to_t_user_context(get_context_by_id(id))
39
        pass
40
 
41
    def getContextFromId(self, userId, isSessionId):
42
        """
43
        Parameters:
44
         - userId
45
         - isSessionId
46
        """
47
        log_entry(self, "get context from id")
48
        if isSessionId:
49
            return to_t_user_context(get_context_by_session_id(userId))
50
        else:
51
            return to_t_user_context(get_context_by_id(userId))
52
        pass
53
 
54
    def getContextFromEmailOrHandle(self, emailorhandle, isEmail):
55
        """
56
        Parameters:
57
         - emailorhandle
58
         - isEmail
59
        """
60
        log_entry(self, "get context from email or handle")
61
        return to_t_user_context(get_context_by_email_or_handle(emailorhandle, isEmail))
62
        pass
63
 
64
    def getState(self, userId, isSessionId):
65
        """
66
        Parameters:
67
         - userId
68
         - isSessionId
69
        """
70
        log_entry(self, "get State")
71
        return to_t_user_state(get_state(userId, isSessionId))
72
        pass
73
 
74
    def getPrimaryInfo(self, userId, isSessionId):
75
        """
76
        Parameters:
77
         - userId
78
         - isSessionId
79
        """
80
        log_entry(self, "get primary info")
81
        return to_t_primary_info(get_primary_info(userId, isSessionId))
82
        pass
83
 
84
    def getInternalInfo(self, userId, isSessionId):
85
        """
86
        Parameters:
87
         - userId
88
         - isSessionId
89
        """
90
        log_entry(self, "get internal info")
91
        return to_t_internal_info(get_internal_info(userId, isSessionId))
92
        pass
93
 
94
    def getContext(self, email, password):
95
        """
96
        Parameters:
97
         - email
98
         - password
99
        """
100
        log_entry(self, "get context")
101
        return to_t_user_context(get_context(email, password))
102
        pass
103
 
104
    def authenticateUser(self, handle, password, isEmail):
105
        """
106
        Parameters:
107
         - handle
108
         - password
109
         - isEmail
110
        """
111
        log_entry(self, "authenticate user")
112
        return authenticate_user(handle, password)
113
        pass
114
 
115
    def userExists(self, email):
116
        """
117
        Parameters:
118
         - email
119
        """
120
        log_entry(self, "user exists")
121
        return user_exists(email)
122
        pass
123
 
124
    def addIpAdressForUser(self, ip, timestamp, userId):
125
        """
126
        Parameters:
127
         - ip
128
         - timestamp
129
         - userId
130
        """
131
        log_entry(self, "add ipaddress for user")
132
        return add_ip_address_for_user(ip, timestamp, userId)
133
        pass
134
 
513 rajveer 135
    def addAddressForUser(self, address, userid, timestamp, setDefault):
130 ashish 136
        """
137
        Parameters:
138
         - address
139
         - userid
140
         - timestamp
513 rajveer 141
         - setDefault
130 ashish 142
        """
143
        log_entry(self, "add address for user")
513 rajveer 144
        return add_address_for_user(address, userid, timestamp, setDefault)
130 ashish 145
        pass
146
 
147
    def removeAddressForUser(self, userid, addressId):
148
        """
149
        Parameters:
150
         - userid
151
         - addressId
152
        """
153
        log_entry(self, "removing address")
154
        return remove_address_for_user(userid, addressId)
155
        pass
156
 
157
    def setUserAsLoggedIn(self, userId, timestamp):
158
        """
159
        Parameters:
160
         - userId
161
         - timestamp
162
        """
163
        log_entry(self, "set_user_as_logged_in")
164
        return set_user_as_logged_in(userId, timestamp)
165
        pass
166
 
167
    def setUserAsLoggedOut(self, userid, timestamp):
168
        """
169
        Parameters:
170
         - userid
171
         - timestamp
172
        """
173
        log_entry(self, "set user as logged out")
174
        return set_user_as_logged_out(userid, timestamp)
175
        pass
176
 
513 rajveer 177
    def setDefaultAddress(self, userid, addressId):
178
        """
179
        Parameters:
180
         - userid
181
         - addressId
182
        """
183
        return set_default_address(userid, addressId)
184
        pass
185
 
186
 
130 ashish 187
    def updatePassword(self, userid, password):
188
        """
189
        Parameters:
190
         - userid
191
         - password
192
        """
193
        log_entry(self, "updating password")
194
        return update_password(userid, password)
195
        pass
196
 
197
    def deleteUser(self, userid, isSessionId):
198
        """
199
        Parameters:
200
         - userid
201
         - isSessionId
202
        """
203
        log_entry(self, "Deleting user")
204
        return delete_user(userid, isSessionId)
205
 
206
    def sendEmailVerification(self, userid):
207
        """
208
        Parameters:
209
         - userid
210
        """
211
        pass
212
 
213
    def sendSMSVerification(self, userid):
214
        """
215
        Parameters:
216
         - userid
217
        """
218
        pass
219
 
220
    def confirmEmailVerification(self, userid):
221
        """
222
        Parameters:
223
         - userid
224
        """
225
        pass
226
 
227
    def confirmSMSVerification(self, userid):
228
        """
229
        Parameters:
230
         - userid
231
        """
232
        pass
233
 
234
    def addSocialhandle(self, userid, socialService, handle):
235
        """
236
        Parameters:
237
         - userid
238
         - socialService
239
         - handle
240
        """
241
        log_entry(self, "adding social handle")
242
        return add_social_handle(userid, socialService, handle)
243
 
244
 
245
    def sendNewPasswordById(self, userid):
246
        """
247
        Parameters:
248
         - userid
249
        """
250
        pass
251
 
252
    def sendNewPasswordByHandle(self, emailOrHandle, isEmail):
253
        """
254
        Parameters:
255
         - emailOrHandle
256
         - isEmail
257
        """
258
        pass