def addUpdateLog(request,name,objectId,comment,olddict,newdict,category,status): try: changedata = getChangeInfo(olddict,newdict) sys_comment = '<p class=currdata>%s</p><p class=olddata>%s</p>'%(changedata['new'],changedata['old']) user = request.META.get('ADFS_FULLNAME','') log = ChangeLog(category=category,object_id=objectId,name=name,operation='update',comment=comment,sys_comment=sys_comment,user=user,status=status) log.save() return True except Exception : print traceback.format_exc() return False
def addLog(request,name,comment,oldCategObj,newCategObj,category,operation,status): try: object_id = oldCategObj.id if category =='group': if operation == 'add': sys_comment = "<p class=currdata>Added Group '%s'</p>"%oldCategObj.name elif operation == 'delete': sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getGroupInfo(oldCategObj)) elif category == 'resourcetype': if operation == 'add': sys_comment = "<p class=currdata>Added ResourceType '%s'</p>" %oldCategObj.name elif operation == 'delete': sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getResourceTypeInfo(oldCategObj)) elif category =='region': if operation == 'add': sys_comment = "<p class=currdata>Added Region '%s'</p>"%oldCategObj.name elif operation == 'delete': sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getRegionInfo(oldCategObj)) elif category =='zone': if operation == 'add': sys_comment = "<p class=currdata>Added Zone '%s'</p>"%oldCategObj.name elif operation == 'delete': sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getZoneInfo(oldCategObj)) elif category =='project': if operation == 'add': sys_comment = "<p class=currdata>Added Project '%s'</p>" %oldCategObj.name elif operation == 'delete': sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getProjectInfo(oldCategObj)) elif category =='topallocation': if operation == 'add': sys_comment = "<p class=currdata>Added TopLevelAllocation '%s'</p>" %oldCategObj.name elif operation == 'delete': sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getTopAllocationInfo(oldCategObj)) elif category =='projectallocation': if operation == 'add': sys_comment = "<p class=currdata>Added ProjectAllocation '%s'</p>" %oldCategObj.name elif operation == 'delete': sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getProjectAllocationInfo(oldCategObj)) elif category =='groupallocation': if operation == 'add': sys_comment = "<p class=currdata>Added GroupAllocation '%s'</p>" %oldCategObj.name elif operation == 'delete': sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getGroupAllocationInfo(oldCategObj)) user = request.META.get('ADFS_FULLNAME','') log = ChangeLog(category=category,object_id=object_id,name=name,operation=operation,comment=comment,sys_comment=sys_comment,user=user,status=status) log.save() return True except Exception : print traceback.format_exc() return False
def addEgroupLog(request,egroup,category,operation,comment,status): try: if category =='egroup': if operation == 'update': sys_comment = "<p class=currdata>'%s'</p>"%comment elif operation == 'deleteCERN': sys_comment = '<p class=olddata>Egroup %s Deleted in CERN Egroup</p>'%egroup elif operation =='deleteCLOUDMAN': sys_comment = '<p class=olddata>Egroup %s Deleted in CLOUDMAN</p>'%egroup elif operation == 'emptyEgroup': sys_comment = "<p class=currdata>'%s'</p>"%comment user='******' if request : user = request.META.get('ADFS_FULLNAME','') log = ChangeLog(category=category,object_id=1,user=user,name=egroup,operation=operation,comment=comment,sys_comment=sys_comment,status=status) log.save() return True except Exception: print traceback.format_exc() return False