Subversion Repositories SmartDukaan

Rev

Rev 130 | Rev 513 | 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,\
13
    initialize
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
 
135
    def addAddressForUser(self, address, userid, timestamp):
136
        """
137
        Parameters:
138
         - address
139
         - userid
140
         - timestamp
141
        """
142
        log_entry(self, "add address for user")
143
        return add_address_for_user(address, userid, timestamp)
144
        pass
145
 
146
    def removeAddressForUser(self, userid, addressId):
147
        """
148
        Parameters:
149
         - userid
150
         - addressId
151
        """
152
        log_entry(self, "removing address")
153
        return remove_address_for_user(userid, addressId)
154
        pass
155
 
156
    def setUserAsLoggedIn(self, userId, timestamp):
157
        """
158
        Parameters:
159
         - userId
160
         - timestamp
161
        """
162
        log_entry(self, "set_user_as_logged_in")
163
        return set_user_as_logged_in(userId, timestamp)
164
        pass
165
 
166
    def setUserAsLoggedOut(self, userid, timestamp):
167
        """
168
        Parameters:
169
         - userid
170
         - timestamp
171
        """
172
        log_entry(self, "set user as logged out")
173
        return set_user_as_logged_out(userid, timestamp)
174
        pass
175
 
176
    def updatePassword(self, userid, password):
177
        """
178
        Parameters:
179
         - userid
180
         - password
181
        """
182
        log_entry(self, "updating password")
183
        return update_password(userid, password)
184
        pass
185
 
186
    def deleteUser(self, userid, isSessionId):
187
        """
188
        Parameters:
189
         - userid
190
         - isSessionId
191
        """
192
        log_entry(self, "Deleting user")
193
        return delete_user(userid, isSessionId)
194
 
195
    def sendEmailVerification(self, userid):
196
        """
197
        Parameters:
198
         - userid
199
        """
200
        pass
201
 
202
    def sendSMSVerification(self, userid):
203
        """
204
        Parameters:
205
         - userid
206
        """
207
        pass
208
 
209
    def confirmEmailVerification(self, userid):
210
        """
211
        Parameters:
212
         - userid
213
        """
214
        pass
215
 
216
    def confirmSMSVerification(self, userid):
217
        """
218
        Parameters:
219
         - userid
220
        """
221
        pass
222
 
223
    def addSocialhandle(self, userid, socialService, handle):
224
        """
225
        Parameters:
226
         - userid
227
         - socialService
228
         - handle
229
        """
230
        log_entry(self, "adding social handle")
231
        return add_social_handle(userid, socialService, handle)
232
 
233
 
234
    def sendNewPasswordById(self, userid):
235
        """
236
        Parameters:
237
         - userid
238
        """
239
        pass
240
 
241
    def sendNewPasswordByHandle(self, emailOrHandle, isEmail):
242
        """
243
        Parameters:
244
         - emailOrHandle
245
         - isEmail
246
        """
247
        pass