Example #1
0
 def Insert(self,MenuName,MenuDesc,MenuUrl,MenuPid,MenuIcon,by,ip,RequestedOperation=SYSTEM_PERMISSION_INSERT):
   try:
     details = {
       'MenuName':MenuName,
       'MenuDesc':MenuDesc,
       'MenuUrl':MenuUrl,
       'MenuPid':MenuPid,
       'MenuIcon':MenuIcon,
       'RequestedOperation':RequestedOperation,
       'by':by,
       'ip':ip,
       }
     result = DBMenuInsert(details)
     if (result['result'] == 1):
       deleteCacheKey(self.CACHEKEY)
       return (1,'SUCESS. Menu has been sucessfully added to database.') 
     else:
       return (-1,decode(result))
   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 #2
0
 def Delete(self,MenuIDList,by,ip,RequestedOperation=SYSTEM_PERMISSION_DELETE):
   MenuIDStr = self.getStringFromList(self.getUniqueIntegersList(MenuIDList)[1])
   if MenuIDStr[0] != 1:
     return (-1,MenuIDStr[1])
   try:
     details = {
       'MenuIDStr':MenuIDStr[1],
       'RequestedOperation':RequestedOperation,
       'by':by,
       'ip':ip,
       }
     result = DBGroupMenuDelete(details)
     if (result['result'] == 1):
       from tx2.Users.BusinessFunctions.GroupFunctions import GroupFnx
       # get a list of groups, and delete cache for each
       GroupFnxObj = GroupFnx()
       GroupList = GroupFnxObj.ListAllGroups()
       if GroupList[0] == 1:
         for x in GroupList[1]:
           deleteCacheKey(self.getKey(x.id))
       return (1,'SUCESS. Group Menus has been sucessfully deleted from database.') 
     else:
       return (-1,decode(result))
   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 #3
0
 def Insert(self,MenuList,GroupID,PermissionList,extrainfo,by,ip,RequestedOperation=SYSTEM_PERMISSION_INSERT):
   MenuStr = self.getStringFromList((MenuList))
   if MenuStr[0] != 1:
     return (-1,MenuStr[1])
   PermissionStr = self.getStringFromList((PermissionList))
   if PermissionStr[0] != 1:
     return (-1,PermissionStr[1])
   ExtraInfo = self.getStringFromList((extrainfo))
   if ExtraInfo[0] != 1:
     return (-1,ExtraInfo[1])
   try:
     details = {
       'MenuStr':MenuStr[1],
       'GroupID':GroupID,
       'PermissionStr':PermissionStr[1],
       'extrainfo':ExtraInfo[1],
       'RequestedOperation':RequestedOperation,
       'by':by,
       'ip':ip,
       }
     result = DBGroupMenuInsert(details)
     if (result['result'] == 1):
       deleteCacheKey(self.getKey(GroupID))
       return (1,'SUCESS. Group Menus has been sucessfully added to database.') 
     else:
       return (-1,decode(result))
   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))
 def insertCommunicationTemplate(self, CommTypeName, CommTempName, CommTempDesc, CommTempFormat, paramList, by, ip, RequestedOperation=SYSTEM_PERMISSION_INSERT):
     CACHE_COMMUNICATION_TYPES = 'CACHE_COMMUNICATION_TEMPLATE'
     try:
         CommunicationTypeObj = CommunicationTypeFnx()
         CommunicationTypeID = CommunicationTypeObj.getCommunicationTypeIDbyName(CommTypeName)
         print "here"
         CommTempFormat= dumps(CommTempFormat).encode("zip").encode("base64").strip()
         paramList= dumps(paramList).encode("zip").encode("base64").strip()
         print "her1"
         details = {
                 'CommunicationType':CommunicationTypeID,    
                 'TemplateName': CommTempName,
                 'TemplateDisc':CommTempDesc,
                 'TemplateFormat':CommTempFormat,
                 'paramList':paramList,
                 'op':RequestedOperation,
                 'by':by,
                 'ip':ip,
             }
         print "till here"
         res = DBInsertCommunicationTemplate(details)
         deleteCacheKey(CACHE_COMMUNICATION_TYPES)
         return res
     except:
         error_msg = 'Error @ InsertCommunicationTemplate in Business Functions'
         self.CommunicationLogger.exception('[%s] == Exception =='%('InsertCommunicationTemplate'))
         return (-5,error_msg)
Example #5
0
 def PostNews(self,
              Title,
              Content,
              tstamp,
              by,
              ip,
              RequestedOperation=SYSTEM_PERMISSION_INSERT,
              _AppLabel='Communication',
              _Model='messages',
              Record=-1,
              UsersReg=0):
     try:
         deleteCacheKey("NEWSCache")
         ctid = getContentTypesByAppNameAndModel(_AppLabel, _Model)
         if (ctid != -1):
             return self.InsertCommunication(Title, Content,
                                             KEY_NEWS_COMMUNICATION_TYPE,
                                             'Default', tstamp, -1, -1, by,
                                             ip)
         else:
             return -1
     except:
         error_msg = 'Error @ PostNews in Business Functions'
         self.CommunicationLogger.exception('[%s] == Exception ==' %
                                            ('PostNews'))
         return (-5, error_msg)
Example #6
0
 def CreateGroup(self,gname,gdesc,gtype,entity,by,ip,req_op=SYSTEM_PERMISSION_INSERT):
   eid = entity
   if entity == -1:
     eid = getSystemEntity()
   try:
     details = {
                          'ip':ip,
                          'by':by,
                          'RequestedOperation':req_op,
                          'GroupEntity':eid,
                          'GroupType':gtype,
                          'GroupName':gname,
                          'GroupDescription':gdesc,
                          }
     result = DBGroupInsert(details)
     if (result['result'] == 1):
       deleteCacheKey(self.CACHE_KEY_ALL_GROUPS)
       return (1,'SUCESS. Group has been sucessfully added to database.') 
     else:
       return (-1,decode(result))
   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 #7
0
 def CreateGroupType(self,
                     gname,
                     gdesc,
                     by,
                     ip,
                     req_op=SYSTEM_PERMISSION_INSERT):
     try:
         details = {
             'ip': ip,
             'by': by,
             'name': gname,
             'desc': gdesc,
             'req_op': req_op,
         }
         result = DBGroupTypeInsert(details)
         if (result['result'] == 1):
             deleteCacheKey(self.CACHEKEY)
             return (
                 1,
                 'SUCESS. GroupType has been sucessfully added to database.'
             )
         else:
             return (-1, decode(result))
     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))
	def PostNews(self,Title,Content,tstamp,by,ip,RequestedOperation=SYSTEM_PERMISSION_INSERT,_AppLabel='Communication',_Model='messages',Record=-1,UsersReg=0):
		try:
			deleteCacheKey("NEWSCache")
			ctid = getContentTypesByAppNameAndModel(_AppLabel,_Model)
			if(ctid!=-1):
				return self.InsertCommunication(Title, Content, KEY_NEWS_COMMUNICATION_TYPE, 'Default',tstamp, -1, -1, by, ip)
			else:
				return -1
		except:
			error_msg = 'Error @ PostNews in Business Functions'
			self.CommunicationLogger.exception('[%s] == Exception =='%('PostNews'))
			return (-5,error_msg)
Example #9
0
 def Update(self,
            MenuId,
            MenuName,
            MenuDesc,
            MenuUrl,
            MenuPid,
            MenuIcon,
            by,
            ip,
            LogDesc,
            RequestedOperation=SYSTEM_PERMISSION_UPDATE):
     MenuObj = ''
     try:
         MenuObj = Menu.objects.get(id=MenuId)
     except ObjectDoesNotExist:
         return (-1, 'Menu does not exist.')
     PreviousState = str(MenuObj)
     #TODO store based on comparisons
     try:
         details = {
             'MenuId': MenuId,
             'MenuName': MenuName,
             'MenuDesc': MenuDesc,
             'MenuUrl': MenuUrl,
             'MenuPid': MenuPid,
             'MenuIcon': MenuIcon,
             'RequestedOperation': RequestedOperation,
             'LogDesc': LogDesc,
             'LogPreviousState': PreviousState,
             'by': by,
             'ip': ip,
         }
         result = DBMenuUpdate(details)
         if (result['result'] == 1):
             deleteCacheKey(self.CACHEKEY)
             return (
                 1,
                 'SUCESS. Menu has been sucessfully updated in database.')
         else:
             return (-1, decode(result))
     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))
	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 #11
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
 def insertCommunicationTemplate(
         self,
         CommTypeName,
         CommTempName,
         CommTempDesc,
         CommTempFormat,
         paramList,
         by,
         ip,
         RequestedOperation=SYSTEM_PERMISSION_INSERT):
     CACHE_COMMUNICATION_TYPES = 'CACHE_COMMUNICATION_TEMPLATE'
     try:
         CommunicationTypeObj = CommunicationTypeFnx()
         CommunicationTypeID = CommunicationTypeObj.getCommunicationTypeIDbyName(
             CommTypeName)
         print "here"
         CommTempFormat = dumps(CommTempFormat).encode("zip").encode(
             "base64").strip()
         paramList = dumps(paramList).encode("zip").encode("base64").strip()
         print "her1"
         details = {
             'CommunicationType': CommunicationTypeID,
             'TemplateName': CommTempName,
             'TemplateDisc': CommTempDesc,
             'TemplateFormat': CommTempFormat,
             'paramList': paramList,
             'op': RequestedOperation,
             'by': by,
             'ip': ip,
         }
         print "till here"
         res = DBInsertCommunicationTemplate(details)
         deleteCacheKey(CACHE_COMMUNICATION_TYPES)
         return res
     except:
         error_msg = 'Error @ InsertCommunicationTemplate in Business Functions'
         self.CommunicationLogger.exception('[%s] == Exception ==' %
                                            ('InsertCommunicationTemplate'))
         return (-5, error_msg)
 def InsertCommunicationType(self,
                             CommTypeName,
                             CommTypeDesc,
                             by,
                             ip,
                             RequestedOperation=SYSTEM_PERMISSION_INSERT):
     CACHE_COMMUNICATION_TYPES = 'CACHE_COMMUNICATION_TYPES'
     try:
         details = {
             'CommTypeName': CommTypeName,
             'CommTypeDesc': CommTypeDesc,
             'op': RequestedOperation,
             'by': by,
             'ip': ip,
         }
         res = DBInsertCommunicationType(details)
         deleteCacheKey(CACHE_COMMUNICATION_TYPES)
         return res
     except:
         error_msg = 'Error @ InsertCommunicationType in Business Functions'
         self.CommunicationLogger.exception('[%s] == Exception ==' %
                                            ('InsertCommunicationType'))
         return (-5, error_msg)
Example #14
0
 def CreateGroupType(self,gname,gdesc,by,ip,req_op=SYSTEM_PERMISSION_INSERT):
   try:
     details = {
       'ip':ip,
       'by':by,
       'name':gname,
       'desc':gdesc,
       'req_op':req_op,
       }
     result = DBGroupTypeInsert(details)
     if (result['result'] == 1):
       deleteCacheKey(self.CACHEKEY)
       return (1,'SUCESS. GroupType has been sucessfully added to database.') 
     else:
       return (-1,decode(result))
   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 #15
0
  def Update(self,MenuId,MenuName,MenuDesc,MenuUrl,MenuPid,MenuIcon,by,ip,LogDesc,RequestedOperation=SYSTEM_PERMISSION_UPDATE):
    MenuObj = ''
    try:
      MenuObj = Menu.objects.get(id=MenuId)
    except ObjectDoesNotExist:
      return (-1,'Menu does not exist.')
    PreviousState = str(MenuObj)
    #TODO store based on comparisons
    try:
      details = {
		   		'MenuId':MenuId,
		   		'MenuName':MenuName,
		   		'MenuDesc':MenuDesc,
		   		'MenuUrl':MenuUrl,
		   		'MenuPid':MenuPid,
		   		'MenuIcon':MenuIcon,
		   		'RequestedOperation':RequestedOperation,
		   		'LogDesc':LogDesc,
		   		'LogPreviousState':PreviousState,
          'by':by,
		   		'ip':ip,
        }
      result = DBMenuUpdate(details)
      if (result['result'] == 1):
        deleteCacheKey(self.CACHEKEY)
        return (1,'SUCESS. Menu has been sucessfully updated in database.') 
      else:
        return (-1,decode(result))
    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 Insert(self,
            MenuName,
            MenuDesc,
            MenuUrl,
            MenuPid,
            MenuIcon,
            by,
            ip,
            RequestedOperation=SYSTEM_PERMISSION_INSERT):
     try:
         details = {
             'MenuName': MenuName,
             'MenuDesc': MenuDesc,
             'MenuUrl': MenuUrl,
             'MenuPid': MenuPid,
             'MenuIcon': MenuIcon,
             'RequestedOperation': RequestedOperation,
             'by': by,
             'ip': ip,
         }
         result = DBMenuInsert(details)
         if (result['result'] == 1):
             deleteCacheKey(self.CACHEKEY)
             return (1,
                     'SUCESS. Menu has been sucessfully added to database.')
         else:
             return (-1, decode(result))
     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))