def getCommunicationTemplate(self):
     CACHE_COMMUNICATION_TEMPLATE = 'CACHE_COMMUNICATION_TEMPLATE'
     CommTemplateList = getCache(CACHE_COMMUNICATION_TEMPLATE)
     if CommTemplateList is None:
         CommTemplateList = CommunicationTemplates.objects.all()
         setCache(CACHE_COMMUNICATION_TEMPLATE, CommTemplateList)
     return CommTemplateList
 def getCommunicationTypes(self):
     CACHE_COMMUNICATION_TYPES = 'CACHE_COMMUNICATION_TYPES'
     CommTypeList = getCache(CACHE_COMMUNICATION_TYPES)
     if CommTypeList is None:
         CommTypeList = CommunicationType.objects.all()
         setCache(CACHE_COMMUNICATION_TYPES, CommTypeList)
     return CommTypeList
 def getCommunicationTemplate(self):
     CACHE_COMMUNICATION_TEMPLATE = 'CACHE_COMMUNICATION_TEMPLATE'
     CommTemplateList = getCache(CACHE_COMMUNICATION_TEMPLATE)
     if CommTemplateList is None:
         CommTemplateList = CommunicationTemplates.objects.all()
         setCache(CACHE_COMMUNICATION_TEMPLATE,CommTemplateList)
     return CommTemplateList
Example #4
0
def getSystemEntity():
	s_entity = -1
	try:
		s_entity = getCache(CACHE_KEY_SYSTEM_ENTITY)
		if s_entity is None or s_entity == -1:
			e_obj = Entity.objects.get(EntityName=SYSTEM_ENTITY)
			setCache(CACHE_KEY_SYSTEM_ENTITY,e_obj.id)
			s_entity = e_obj.id
		return s_entity
	except:
		return s_entity
Example #5
0
def getSystemGroup_NewUsers():
	s_entity = -1
	try:
		s_entity = getCache(CACHE_KEY_NEW_USERS_GROUP)
		if s_entity is None or s_entity == -1:
			e_obj = Group.objects.get(GroupName=SYSTEM_DAEMON_CREATE_USER_GROUP)
			setCache(CACHE_KEY_NEW_USERS_GROUP,e_obj.id)
			s_entity = e_obj.id
		return s_entity
	except:
		return s_entity
Example #6
0
def getSystemGroup_EmailAU():
	s_entity = -1
	try:
		s_entity = getCache(CACHE_KEY_SYSTEM_DAEMON_USERAU_USER_GROUP)
		if s_entity is None or s_entity == -1:
			e_obj = Group.objects.get(GroupName=SYSTEM_DAEMON_USERAU_USER_GROUP)
			setCache(CACHE_KEY_SYSTEM_DAEMON_USERAU_USER_GROUP,e_obj.id)
			s_entity = e_obj.id
		return s_entity
	except:
		return s_entity
Example #7
0
 def ListAllGroups(self):
   try:
     grouplist  = self.getGroupFromCache()
     if grouplist[0] != 1:
       grouplist =  Group.objects.all()
       setCache(self.CACHE_KEY_ALL_GROUPS,grouplist)
     else:
       grouplist = grouplist[1]
     return (1,grouplist)
   except Exception, ex:
     self.UserLogger.exception('ListAllGroups')
     return (-2,self.MakeExceptionMessage(str(ex)))
Example #8
0
def getSystemUser_DaemonCreateUser():
	s_entity = -1
	print 'DaemonCreateUser %d' % (s_entity)
	print  CACHE_KEY_SYSTEM_DAEMON_CREATE_USER , SYSTEM_DAEMON_CREATE_USER
	try:
		s_entity = getCache(CACHE_KEY_SYSTEM_DAEMON_CREATE_USER)
		if s_entity is None or s_entity == -1:
			e_obj = User.objects.get(UserEmail=SYSTEM_DAEMON_CREATE_USER)
			print 'DaemonCreateUser %d' % (e_obj.id)
			setCache(CACHE_KEY_SYSTEM_DAEMON_CREATE_USER,e_obj.id)
			s_entity = e_obj.id
		print 'DaemonCreateUser %d' % (s_entity)
		return s_entity
	except:
		UserLogger.exception(' Exception occured in getSystemUser_DaemonCreateUser')
		return s_entity
	def setCommunicationCache(self,commType):
		
		try:
			M= GetCommunicationFnx().getCommunicationByType(commType).order_by("Timestamp")
			M=M.reverse()
			P=Paginator(M,10)
			cache_name=commType+"Cache"
			print cache_name
			deleteCacheKey(cache_name)
			setCache(cache_name, P)
		except:
			
			error_msg = 'Error @ setCommunicationCache in Business Functions| Error fetching data from database'
			self.CommunicationLogger.exception('[%s] == Exception =='%('setCommunicationCache'))
			return (-5,error_msg)
		#print "done cache"
		return 1
Example #10
0
 def ListAllGroupTypes(self):
   try:
     grouptypelist = self.getGroupTypeFromCache()
     if grouptypelist[0] != 1:
       grouptypelist =  GroupType.objects.all()  
       setCache(self.CACHEKEY,grouptypelist)
     else:
       grouptypelist = grouptypelist[1]
     return (1,grouptypelist)
   except Exception, ex:
     frame = inspect.currentframe()
     args, _, _, values = inspect.getargvalues(frame)
     msg = ''
     for i in args:
       msg += "[%s : %s]" % (i,values[i])
     self.UserLogger.exception('%s : %s' % (inspect.getframeinfo(frame)[2],msg))
     return (-2,str(ex))
Example #11
0
 def getAllMenuObj(self):
   try:
     MenuList = self.getMenuListFromCache()
     if MenuList[0] is not 1:
       getDeletedState()
       MenuList = Menu.objects.exclude(State = getDeletedState())
       setCache(self.CACHEKEY,MenuList)
     else:
       MenuList = MenuList[1]
     return (1,MenuList)
   except Exception, ex:
     frame = inspect.currentframe()
     args, _, _, values = inspect.getargvalues(frame)
     msg = ''
     for i in args:
       msg += "[%s : %s]" % (i,values[i])
     self.UserLogger.exception('%s : %s' % (inspect.getframeinfo(frame)[2],msg))
     return (-2,str(ex)) 
Example #12
0
 def ListAllGroupTypes(self):
     try:
         grouptypelist = self.getGroupTypeFromCache()
         if grouptypelist[0] != 1:
             grouptypelist = GroupType.objects.all()
             setCache(self.CACHEKEY, grouptypelist)
         else:
             grouptypelist = grouptypelist[1]
         return (1, grouptypelist)
     except Exception, ex:
         frame = inspect.currentframe()
         args, _, _, values = inspect.getargvalues(frame)
         msg = ''
         for i in args:
             msg += "[%s : %s]" % (i, values[i])
         self.UserLogger.exception('%s : %s' %
                                   (inspect.getframeinfo(frame)[2], msg))
         return (-2, str(ex))
Example #13
0
 def getAllMenuObj(self):
     try:
         MenuList = self.getMenuListFromCache()
         if MenuList[0] is not 1:
             getDeletedState()
             MenuList = Menu.objects.exclude(State=getDeletedState())
             setCache(self.CACHEKEY, MenuList)
         else:
             MenuList = MenuList[1]
         return (1, MenuList)
     except Exception, ex:
         frame = inspect.currentframe()
         args, _, _, values = inspect.getargvalues(frame)
         msg = ''
         for i in args:
             msg += "[%s : %s]" % (i, values[i])
         self.UserLogger.exception('%s : %s' %
                                   (inspect.getframeinfo(frame)[2], msg))
         return (-2, str(ex))
Example #14
0
    def setCommunicationCache(self, commType):

        try:
            M = GetCommunicationFnx().getCommunicationByType(
                commType).order_by("Timestamp")
            M = M.reverse()
            P = Paginator(M, 10)
            cache_name = commType + "Cache"
            print cache_name
            deleteCacheKey(cache_name)
            setCache(cache_name, P)
        except:

            error_msg = 'Error @ setCommunicationCache in Business Functions| Error fetching data from database'
            self.CommunicationLogger.exception('[%s] == Exception ==' %
                                               ('setCommunicationCache'))
            return (-5, error_msg)
        #print "done cache"
        return 1
Example #15
0
 def getGroupMenuObjectByGroupID(self,groupid):
   try:
     GroupMenuObjList = []
     GroupMenuList = self.getListFromCache(groupid)
     if GroupMenuList[0] != 1:
       GroupMenuList = GroupMenu.objects.filter(Group__id = groupid)
       for m in GroupMenuList:
         if m.Menu.State.StateName != SYSTEM_STATE_DELETED:
           GroupMenuObjList.append(m)
       setCache(self.getKey(groupid),GroupMenuObjList)
     else:
       GroupMenuObjList = GroupMenuList[1]
     return (1,GroupMenuObjList)
   except Exception, ex:
     frame = inspect.currentframe()
     args, _, _, values = inspect.getargvalues(frame)
     msg = ''
     for i in args:
       msg += "[%s : %s]" % (i,values[i])
     self.UserLogger.exception('%s : %s' % (inspect.getframeinfo(frame)[2],msg))
     return (-2,str(ex))
Example #16
0
 def CreateGroup(self,gname,gdesc,gtype,entity,by,ip,req_op=SYSTEM_PERMISSION_INSERT):
     eid = entity
     if entity == -1:
     	e_obj = Entity.objects.get(EntityName=SYSTEM_ENTITY)
     	setCache(CACHE_KEY_SYSTEM_ENTITY,e_obj.id)
     	eid = e_obj.id
     try:
         self.UserLogger.debug('inside CreateGroup')
         details = {
                    'ip':ip,
                    'by':by,
                    'RequestedOperation':req_op,
                    'GroupEntity':eid,
                    'GroupType':gtype,
                    'GroupName':gname,
                    'GroupDescription':gdesc,
                    }
         result = DBGroupInsert(details)
         self.UserLogger.debug('[%s] %s,%s'%('CreateGroup',str(details),str(result)))
         return (result)
     except:
         exception_log = ('[%s] %s,%s,%s,%s,%s,%s')%('CreateGroup',gname,gdesc,gtype,entity,by,ip)
         self.UserLogger.exception(exception_log)
         return (-1,'Exception Occoured at Business Functions while creating group')
Example #17
0
def UserContextProcessor(request):
    try:
      logindetails = GetLoginDetails(request)
      GroupMenuFnxObj = GroupMenuFnx()
      if( logindetails["userid"] != -1):
        # USER IS LOGGED IN, GET THE MENU LISTS AND PASS HERE
        # get the groupid
        AllUsersGid = getCache(ALL_LOGGED_IN_USERS_GROUP)
        if AllUsersGid == None or AllUsersGid == -1:
          GroupFnxObj = GroupFnx()
          gobj = GroupFnxObj.getGroupObjectByName(ALL_LOGGED_IN_USERS_GROUP)
          if (gobj[0] == 1):
            AllUsersGid = gobj[1].id
          else:
            return {'loggedin':False}
          setCache(ALL_LOGGED_IN_USERS_GROUP,AllUsersGid)
        #get the menulist
        AllUsersChildMenuList = GroupMenuFnxObj.getGroupMenuObjectByGroupID(AllUsersGid)[1]
        AllUsersParentMenuList = GroupMenuFnxObj.getParentGroupMenuObjectByGroupID(AllUsersGid)[1]
        GroupChildMenuList = GroupMenuFnxObj.getGroupMenuObjectByGroupID(int(logindetails['groupid']))[1]
        GroupParentMenuList = GroupMenuFnxObj.getParentGroupMenuObjectByGroupID(int(logindetails['groupid']))[1]
        return_dict =  {  
                  "userid":logindetails['userid'],
                  "groupid":logindetails['groupid'],
                  "loginid":logindetails['loginid'],
                  "fname":logindetails["fname"],
                  "loggedin":True,
                  "AllUsersChildMenuList":AllUsersChildMenuList,
                  "AllUsersParentMenuList":AllUsersParentMenuList,
                  "GroupChildMenuList":GroupChildMenuList,
                  "GroupParentMenuList":GroupParentMenuList,
              }
        #print return_dict
        return return_dict
      else:
        # USER IS NOT LOGGED IN, GET ANONYMOUS LISTS AND PASS HERE
        AnonymousUsersGid = getCache(ANONYMOUS_GROUP)
        if AnonymousUsersGid == None or AnonymousUsersGid == -1:
          GroupFnxObj = GroupFnx()
          gobj = GroupFnxObj.getGroupObjectByName(ANONYMOUS_GROUP)
          if (gobj[0] == 1):
            AnonymousUsersGid = gobj[1].id
          else:
            return {'loggedin':False}
          setCache(ANONYMOUS_GROUP,AnonymousUsersGid)
        #get the menulist
        AnonymousChildMenuList = GroupMenuFnxObj.getGroupMenuObjectByGroupID(AnonymousUsersGid)[1]
        AnonymousParentMenuList = GroupMenuFnxObj.getParentGroupMenuObjectByGroupID(AnonymousUsersGid)[1]
        return_dict =  {
                  "loggedin":False,
                  "AnonymousChildMenuList":AnonymousChildMenuList,
                  "AnonymousParentMenuList":AnonymousParentMenuList,
               }
        #print return_dict
        return return_dict
    except Exception, ex:
      frame = inspect.currentframe()
      args, _, _, values = inspect.getargvalues(frame)
      msg = ''
      for i in args:
        msg += "[%s : %s]" % (i,values[i])
      Logger_User.exception('%s : %s' % (inspect.getframeinfo(frame)[2],msg))
      return {'loggedin':False}
Example #18
0
def UserContextProcessor(request):
    try:
        logindetails = GetLoginDetails(request)
        GroupMenuFnxObj = GroupMenuFnx()
        if (logindetails["userid"] != -1):
            # USER IS LOGGED IN, GET THE MENU LISTS AND PASS HERE
            # get the groupid
            AllUsersGid = getCache(ALL_LOGGED_IN_USERS_GROUP)
            if AllUsersGid == None or AllUsersGid == -1:
                GroupFnxObj = GroupFnx()
                gobj = GroupFnxObj.getGroupObjectByName(
                    ALL_LOGGED_IN_USERS_GROUP)
                if (gobj[0] == 1):
                    AllUsersGid = gobj[1].id
                else:
                    return {'loggedin': False}
                setCache(ALL_LOGGED_IN_USERS_GROUP, AllUsersGid)
            #get the menulist
            AllUsersChildMenuList = GroupMenuFnxObj.getGroupMenuObjectByGroupID(
                AllUsersGid)[1]
            AllUsersParentMenuList = GroupMenuFnxObj.getParentGroupMenuObjectByGroupID(
                AllUsersGid)[1]
            GroupChildMenuList = GroupMenuFnxObj.getGroupMenuObjectByGroupID(
                int(logindetails['groupid']))[1]
            GroupParentMenuList = GroupMenuFnxObj.getParentGroupMenuObjectByGroupID(
                int(logindetails['groupid']))[1]
            return_dict = {
                "userid": logindetails['userid'],
                "groupid": logindetails['groupid'],
                "loginid": logindetails['loginid'],
                "fname": logindetails["fname"],
                "loggedin": True,
                "AllUsersChildMenuList": AllUsersChildMenuList,
                "AllUsersParentMenuList": AllUsersParentMenuList,
                "GroupChildMenuList": GroupChildMenuList,
                "GroupParentMenuList": GroupParentMenuList,
            }
            #print return_dict
            return return_dict
        else:
            # USER IS NOT LOGGED IN, GET ANONYMOUS LISTS AND PASS HERE
            AnonymousUsersGid = getCache(ANONYMOUS_GROUP)
            if AnonymousUsersGid == None or AnonymousUsersGid == -1:
                GroupFnxObj = GroupFnx()
                gobj = GroupFnxObj.getGroupObjectByName(ANONYMOUS_GROUP)
                if (gobj[0] == 1):
                    AnonymousUsersGid = gobj[1].id
                else:
                    return {'loggedin': False}
                setCache(ANONYMOUS_GROUP, AnonymousUsersGid)
            #get the menulist
            AnonymousChildMenuList = GroupMenuFnxObj.getGroupMenuObjectByGroupID(
                AnonymousUsersGid)[1]
            AnonymousParentMenuList = GroupMenuFnxObj.getParentGroupMenuObjectByGroupID(
                AnonymousUsersGid)[1]
            return_dict = {
                "loggedin": False,
                "AnonymousChildMenuList": AnonymousChildMenuList,
                "AnonymousParentMenuList": AnonymousParentMenuList,
            }
            #print return_dict
            return return_dict
    except Exception, ex:
        frame = inspect.currentframe()
        args, _, _, values = inspect.getargvalues(frame)
        msg = ''
        for i in args:
            msg += "[%s : %s]" % (i, values[i])
        Logger_User.exception('%s : %s' %
                              (inspect.getframeinfo(frame)[2], msg))
        return {'loggedin': False}