Subversion Repositories SmartDukaan

Rev

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