Subversion Repositories SmartDukaan

Rev

Rev 404 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

'''
Created on 28-Apr-2010

@author: ashish
'''
from shop2020.utils.Utils import log_entry
from shop2020.model.v1.user.impl.DataAccessors import add_social_handle,\
    delete_user, update_password, set_user_as_logged_out, set_user_as_logged_in,\
    remove_address_for_user, add_address_for_user, add_ip_address_for_user,\
    user_exists, authenticate_user, get_context, get_internal_info,\
    get_primary_info, get_state, get_context_by_email_or_handle,\
    get_context_by_session_id, get_context_by_id, create_context, update_context
from shop2020.model.v1.user.impl.Converters import to_t_user_context,\
    to_t_internal_info, to_t_primary_info, to_t_user_state

class UserContextServiceHandler:
    
    """
    User session context service handler
    """
    def createContext(self, context, updateExisting):
        """
        Parameters:
         - context
         - updateExisting
        """
        log_entry(self, "create or update context")
        if not updateExisting:
            id = create_context(context)
        else:
            id = update_context(context)
        
        return to_t_user_context(get_context_by_id(id))
        pass
    
    def getContextFromId(self, userId, isSessionId):
        """
        Parameters:
         - userId
         - isSessionId
        """
        log_entry(self, "get context from id")
        if isSessionId:
            return to_t_user_context(get_context_by_session_id(userId))
        else:
            return to_t_user_context(get_context_by_id(userId))
        pass
    
    def getContextFromEmailOrHandle(self, emailorhandle, isEmail):
        """
        Parameters:
         - emailorhandle
         - isEmail
        """
        log_entry(self, "get context from email or handle")
        return to_t_user_context(get_context_by_email_or_handle(emailorhandle, isEmail))
        pass
    
    def getState(self, userId, isSessionId):
        """
        Parameters:
         - userId
         - isSessionId
        """
        log_entry(self, "get State")
        return to_t_user_state(get_state(userId, isSessionId))
        pass
    
    def getPrimaryInfo(self, userId, isSessionId):
        """
        Parameters:
         - userId
         - isSessionId
        """
        log_entry(self, "get primary info")
        return to_t_primary_info(get_primary_info(userId, isSessionId))
        pass
    
    def getInternalInfo(self, userId, isSessionId):
        """
        Parameters:
         - userId
         - isSessionId
        """
        log_entry(self, "get internal info")
        return to_t_internal_info(get_internal_info(userId, isSessionId))
        pass
    
    def getContext(self, email, password):
        """
        Parameters:
         - email
         - password
        """
        log_entry(self, "get context")
        return to_t_user_context(get_context(email, password))
        pass
    
    def authenticateUser(self, handle, password, isEmail):
        """
        Parameters:
         - handle
         - password
         - isEmail
        """
        log_entry(self, "authenticate user")
        return authenticate_user(handle, password)
        pass
    
    def userExists(self, email):
        """
        Parameters:
         - email
        """
        log_entry(self, "user exists")
        return user_exists(email)
        pass
    
    def addIpAdressForUser(self, ip, timestamp, userId):
        """
        Parameters:
         - ip
         - timestamp
         - userId
        """
        log_entry(self, "add ipaddress for user")
        return add_ip_address_for_user(ip, timestamp, userId)
        pass
    
    def addAddressForUser(self, address, userid, timestamp):
        """
        Parameters:
         - address
         - userid
         - timestamp
        """
        log_entry(self, "add address for user")
        return add_address_for_user(address, userid, timestamp)
        pass
    
    def removeAddressForUser(self, userid, addressId):
        """
        Parameters:
         - userid
         - addressId
        """
        log_entry(self, "removing address")
        return remove_address_for_user(userid, addressId)
        pass
    
    def setUserAsLoggedIn(self, userId, timestamp):
        """
        Parameters:
         - userId
         - timestamp
        """
        log_entry(self, "set_user_as_logged_in")
        return set_user_as_logged_in(userId, timestamp)
        pass
    
    def setUserAsLoggedOut(self, userid, timestamp):
        """
        Parameters:
         - userid
         - timestamp
        """
        log_entry(self, "set user as logged out")
        return set_user_as_logged_out(userid, timestamp)
        pass
    
    def updatePassword(self, userid, password):
        """
        Parameters:
         - userid
         - password
        """
        log_entry(self, "updating password")
        return update_password(userid, password)
        pass
    
    def deleteUser(self, userid, isSessionId):
        """
        Parameters:
         - userid
         - isSessionId
        """
        log_entry(self, "Deleting user")
        return delete_user(userid, isSessionId)
    
    def sendEmailVerification(self, userid):
        """
        Parameters:
         - userid
        """
        pass
    
    def sendSMSVerification(self, userid):
        """
        Parameters:
         - userid
        """
        pass
    
    def confirmEmailVerification(self, userid):
        """
        Parameters:
         - userid
        """
        pass
    
    def confirmSMSVerification(self, userid):
        """
        Parameters:
         - userid
        """
        pass
    
    def addSocialhandle(self, userid, socialService, handle):
        """
        Parameters:
         - userid
         - socialService
         - handle
        """
        log_entry(self, "adding social handle")
        return add_social_handle(userid, socialService, handle)

    
    def sendNewPasswordById(self, userid):
        """
        Parameters:
         - userid
        """
        pass
    
    def sendNewPasswordByHandle(self, emailOrHandle, isEmail):
        """
        Parameters:
         - emailOrHandle
         - isEmail
        """
        pass