Example #1
0
def QueryActivity(TheActivityID):
    '''
	描述:给定活动id,查询活动基本信息
	参数:活动id
	返回:一个字典,里面有活动各种信息
	如果没有就返回空字典
	'''
    Success = True
    Result = {}
    if Success:
        try:
            Info = Activity.objects.get(ID=TheActivityID)
            Result["name"] = Info.Name
            Result["place"] = Info.Place
            Result["createTime"] = GlobalFunctions.TimeStampToTimeString(
                int(Info.CreateTime))
            Result["start"] = GlobalFunctions.TimeStampToTimeString(
                int(Info.StartTime))
            Result["end"] = GlobalFunctions.TimeStampToTimeString(
                int(Info.EndTime))
            Result["signupBeginAt"] = GlobalFunctions.TimeStampToTimeString(
                int(Info.SignUpStartTime))
            Result["signupStopAt"] = GlobalFunctions.TimeStampToTimeString(
                int(Info.SignUpEndTime))
            Result["minUser"] = int(Info.MinUser)
            Result["maxUser"] = int(Info.MaxUser)
            Result["curUser"] = int(Info.CurrentUser)
            Result["type"] = Info.Type
            Result["statusGlobal"] = int(Info.StatusGlobal)
            Result["statusJoin"] = int(Info.StatusJoin)
            Result["statusCheck"] = int(Info.StatusCheck)
            Result["tags"] = GlobalFunctions.SplitTags(Info.Tags)
            Result["imageUrl"] = GlobalFunctions.GetTrueAvatarUrlActivity(
                Info.ImageURL)
        except:
            Success = False
    if Success == False:
        Result = {}
    return Result
 def GetOneActivityInfo(self, TheID):
     TheResult = {}
     Success = True
     try:
         TheActivity = Activity.objects.get(ID=TheID)
         TheResult["id"] = TheID
         TheResult["name"] = TheActivity.Name
         TheResult["place"] = TheActivity.Place
         TheResult["createTime"] = GlobalFunctions.TimeStampToTimeString(
             int(TheActivity.CreateTime))
         TheResult["start"] = GlobalFunctions.TimeStampToTimeString(
             int(TheActivity.StartTime))
         TheResult["end"] = GlobalFunctions.TimeStampToTimeString(
             int(TheActivity.EndTime))
         TheResult["signupBeginAt"] = GlobalFunctions.TimeStampToTimeString(
             int(TheActivity.SignUpStartTime))
         TheResult["signupStopAt"] = GlobalFunctions.TimeStampToTimeString(
             int(TheActivity.SignUpEndTime))
         TheResult["minUser"] = int(TheActivity.MinUser)
         TheResult["maxUser"] = int(TheActivity.MaxUser)
         TheResult["curUser"] = int(TheActivity.CurrentUser)
         TheResult["type"] = TheActivity.Type
         TheResult["statusGlobal"] = int(TheActivity.StatusGlobal)
         TheResult["statusJoin"] = int(TheActivity.StatusJoin)
         TheResult["statusCheck"] = int(TheActivity.StatusCheck)
         TheResult["imageUrl"] = GlobalFunctions.GetTrueAvatarUrlActivity(
             TheActivity.ImageURL)
         TheResult["tags"] = GlobalFunctions.SplitTags(TheActivity.Tags)
         #print(TheResult)
         if JudgeValid.JudgeActivityCanBeSearched(TheID) != True:
             Success = False
     except:
         Success = False
     if Success:
         return TheResult
     else:
         return {}
Example #3
0
def ShowAllActivity(TheLastID, TheMostNumber):
	'''
	描述:查询所有活动
	参数: 最后一个id,最多显示的数目
	返回:第一个是一个字典,里面就一个字典数组activityList,字典每个字典有活动具体信息,失败为空
		 第二个是失败状态信息,成功是空,失败有reason和code	'''
	#查询
	Success = True
	if Success:
		try:
			Info = Activity.objects.all()
		except:
			Success = False
	#处理数据并且返回
	Return = {}
	ErrorInfo = {}
	Result = []
	#print(TheLastID, TheMostNumber)
	if Success:
		try:
			CurrentNumber = 0
			i = len(Info) - 1
			while i >= 0:
				item = Info[i]
				if TheLastID != Constants.UNDEFINED_NUMBER:
					if item.ID >= TheLastID:
						i -= 1
						continue
				TheResult = {}
				TheResult["id"] = item.ID
				TheResult["name"] = item.Name
				TheResult["place"] = item.Place
				TheResult["createTime"] = GlobalFunctions.TimeStampToTimeString(int(item.CreateTime))
				TheResult["start"] = GlobalFunctions.TimeStampToTimeString(int(item.StartTime))
				TheResult["end"] = GlobalFunctions.TimeStampToTimeString(int(item.EndTime))
				TheResult["signupBeginAt"] = GlobalFunctions.TimeStampToTimeString(int(item.SignUpStartTime))
				TheResult["signupStopAt"] = GlobalFunctions.TimeStampToTimeString(int(item.SignUpEndTime))
				TheResult["minUser"] = int(item.MinUser)
				TheResult["maxUser"] = int(item.MaxUser)
				TheResult["curUser"] = int(item.CurrentUser)
				TheResult["type"] = item.Type
				TheResult["statusGlobal"] = int(item.StatusGlobal)
				TheResult["statusJoin"] = int(item.StatusJoin)
				TheResult["statusCheck"] = int(item.StatusCheck)
				TheResult["tags"] = GlobalFunctions.SplitTags(item.Tags)
				TheResult["imageUrl"] = GlobalFunctions.GetTrueAvatarUrlActivity(item.ImageURL)
				TheReportActivityList = ReportInformation.objects.filter(ActivityId = item)
				TheResult["reportCount"] = len(TheReportActivityList)
				Result.append(TheResult)
				CurrentNumber = CurrentNumber + 1
				if TheMostNumber != Constants.UNDEFINED_NUMBER and CurrentNumber >= TheMostNumber:
					break
				i -= 1
		except:
			Success = False
	if Success == True:
		Return["activityList"] = Result
		ErrorInfo = {}
	else:
		Return = {}
		ErrorInfo["reason"] = "查询活动失败!"
		ErrorInfo["code"] = Constants.ERROR_CODE_UNKNOWN
	return Return, ErrorInfo