Пример #1
0
def getAppList(req):
    """
	获取应用列表
	"""
    cr = webapi.SuccCallReturn()
    try:

        callback = webapi.GET(req, 'callback')
        cr.setCallBackJsonp(callback)
        begin, end = webapi.getDataPagingParams(req)
        rs = doQueryApp(req)

        total = rs.count()
        rs = rs.order_by('-create_time')[begin:end]

        result = []
        for r in rs:
            #app = core.Application.objects.get(id= r.id)
            appusers = core.AppUser.objects.filter(app_id=int(r.id))
            ids = []
            for appuser in appusers:
                ids.append(appuser.id)

            file_size = core.AppUserFile.objects.filter(
                user_id__in=ids).aggregate(Sum('file_size'))

            filesize = file_size.get('file_size__sum')
            if filesize == None:
                filesize = 0
            if filesize < 1048576:
                filesizestr = str(filesize / 1024) + 'K'
            if 1048576 < filesize < 1073741824:
                filesizestr = str(filesize / 1024) + 'M'
            if filesize > 1073741824:
                filesizestr = str(filesize / 1024) + 'G'

            result.append({
                'id':
                r.id,
                'name':
                r.name,
                'app_id':
                r.app_id,
                'create_time':
                lemon.utils.misc.maketimestamp(r.create_time),
                'status':
                r.status,
                'creator':
                r.creator.name,
                'file_size':
                filesizestr
            })

        cr.assign(result)
        cr.setPageCtrlValue('total', total)
    except:
        traceback.print_exc()
        cr = webapi.FailCallReturn(
            ErrorDefs.InternalException).setCallBackJsonp(callback)
    return cr.httpResponse()
Пример #2
0
def getAppServerList(req):
    """
	获取应用服务器列表
	"""
    cr = webapi.SuccCallReturn()
    try:
        callback = webapi.GET(req, 'callback')
        cr.setCallBackJsonp(callback)
        begin, end = webapi.getDataPagingParams(req)

        rs = doQueryAppServer(req)

        total = rs.count()
        rs = rs.order_by('-create_time')[begin:end]

        result = []
        for r in rs:
            result.append({
                'id':
                r.id,
                'name':
                r.name,
                'ip_addr':
                r.ip_addr,
                'app_name':
                r.app.name,
                'create_time':
                lemon.utils.misc.maketimestamp(r.create_time),
                'status':
                r.status
            })

        cr.assign(result)
        cr.setPageCtrlValue('total', total)
    except:
        traceback.print_exc()
        cr = webapi.FailCallReturn(
            ErrorDefs.InternalException).setCallBackJsonp(callback)
    return cr.httpResponse()
Пример #3
0
def getNoticeList(r):
    """
	获取通知消息列表
	"""
    cr = webapi.SuccCallReturn()
    callback = None
    try:
        start, end = webapi.getDataPagingParams(r)
        callback = webapi.GET(r, 'callback')
        cr.setCallBackJsonp(callback)

        rs = core.Notice.objects.all().order_by('-modify_time')[start:end]
        result = []
        for r in rs:
            result.append({
                'id':
                r.id,
                'title':
                r.title,
                'content':
                r.content,
                'create_time':
                lemon.utils.misc.maketimestamp(r.create_time),
                'issuer':
                r.issuer.name,
                'issuer_id':
                r.issuer.id,
                'alert':
                lemon.base.IntValOfBoolean(r.alert),
                'end_alert_time':
                lemon.utils.misc.maketimestamp(r.end_alert_time)
            })
        cr.assign(result)
        cr.setPageCtrlValue('total', core.Notice.objects.all().count())
    except:
        traceback.print_exc()
        cr = webapi.FailCallReturn(errors.ErrorDefs.InternalException)
    return cr.httpResponse()
Пример #4
0
@csrf_exempt
def getAdminLog(req):
	"""
	查询管理员平台操作日志
	"""
	cr = webapi.SuccCallReturn()
	callback = None
	try:
		callback = webapi.GET(req,'callback')
		cr.setCallBackJsonp(callback)
		case =  webapi.GET(req,'case')
		if case :
			case = json.loads(case)
		else:
			case ={}
		begin,end = webapi.getDataPagingParams(req)
		action_ids = case.get('action_ids')
		if not action_ids:
			return webapi.FailCallReturn(ErrorDefs.ParameterIllegal).httpResponse()
		rs = doQueryAdminUserActionLog(req)

		total = rs.count()
		rs = rs.order_by('-issue_time')[begin:end]

		result =[]
		for r in rs:
			result.append({
				'act_name':cloudfish.base.AdminUserActionType.nameValue(r.action),
				'user':r.user,
				'user_role': cloudfish.base.AdminUserType.nameValue(r.user_role),
				'issue_time': lemon.utils.misc.maketimestamp(r.issue_time),