Subversion Repositories SmartDukaan

Rev

Rev 594 | Rev 785 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 594 Rev 766
Line 111... Line 111...
111
    user.state.account_status = AccountStatus.DELETED
111
    user.state.account_status = AccountStatus.DELETED
112
    session.commit()
112
    session.commit()
113
    return True
113
    return True
114
    
114
    
115
def get_user_state(user_id):
115
def get_user_state(user_id):
116
    return UserState.get_by(user_id=user_id)
116
    userstate = UserState.get_by(user_id=user_id)
-
 
117
    return userstate
117
 
118
 
118
def get_internal_info(user_id):
119
def get_internal_info(user_id):
119
    return InternalInfo.get_by(user_id=user_id)
120
    info = InternalInfo.get_by(user_id=user_id)
-
 
121
    return info
120
 
122
 
121
def authenticate_user(user_handle, password):
123
def authenticate_user(user_handle, password):
122
    user = User.get_by(email=user_handle)
124
    user = User.get_by(email=user_handle)
123
    if not user:
125
    if not user:
124
        raise AuthenticationException("This email address is not registered.", 102)
126
        raise AuthenticationException("This email address is not registered.", 102)
Line 138... Line 140...
138
    except:
140
    except:
139
        return False
141
        return False
140
 
142
 
141
def add_address_for_user(address, user_id, set_default):
143
def add_address_for_user(address, user_id, set_default):
142
    user = get_user_by_id(user_id)
144
    user = get_user_by_id(user_id)
-
 
145
 
143
    if not user:
146
    if not user:
144
        raise_user_exception(user_id)
147
        raise_user_exception(user_id)
145
    if not address:
148
    if not address:
146
        raise UserContextException(103,"Address cannot be null")
149
        raise UserContextException(103,"Address cannot be null")
147
    
150
    
Line 335... Line 338...
335
 
338
 
336
#===============================================================================
339
#===============================================================================
337
# raises the UserContextException
340
# raises the UserContextException
338
#===============================================================================
341
#===============================================================================
339
def raise_user_exception(user_id):
342
def raise_user_exception(user_id):
340
    raise UserContextException(101, "no such user in system %d" %(user_id))      
-
 
341
343
    raise UserContextException(101, "no such user in system %d" %(user_id))
-
 
344
 
-
 
345
def close_session():
-
 
346
    if session.is_active:
-
 
347
        print "session is active. closing it."
-
 
348
        session.close()      
-
 
349
342
350