def ShowAllMembersAdmin(TheUserID, TheActivityID):
	'''
	描述:查询活动所有成员---管理员
	参数: 用户id,活动id
	返回:第一个是一个字典,里面就一个字典数组participantList,每个字典有人员的Openid,权限,状态,报名和签到时间,失败为空
		 第二个是原因和错误码,如果成功就是空,否则有reason和code
	'''
	Result = {}
	ErrorInfo = {}
	Reason = ""
	Code = 0
	Success = True
	ResultList = []
	if Success:
		try:
			if JudgeValid.JudgeWhetherManager(TheUserID, TheActivityID) != True:
				Success = False
				Reason = "权限不足,需要是管理员或创建者!"
				Code = Constants.ERROR_CODE_LACK_ACCESS
			TheActivity = Activity.objects.get(ID = TheActivityID)
			TheJoinActivityList = JoinInformation.objects.filter(ActivityId = TheActivity)
		except:
			Success = False
			Reason = "未找到活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	
	if Success:
		try:
			for item in TheJoinActivityList:
				TheResult = {}
				TheResult["openId"] = item.UserId.OpenID
				TheResult["name"] = item.UserId.Name
				TheResult["avatarUrl"] = GlobalFunctions.GetTrueAvatarUrlUser(item.UserId.AvatarURL)
				TheResult["selfStatus"] = item.Status
				TheResult["selfRole"] = item.Role
				TheResult["point"] = item.UserId.Point
				TheResult["submitTime"] = GlobalFunctions.TimeStampToTimeString(item.SubmitTime)
				if item.JoinTime != Constants.UNDEFINED_NUMBER:
					TheResult["joinTime"] = GlobalFunctions.TimeStampToTimeString(item.JoinTime)
				if item.CheckTime != Constants.UNDEFINED_NUMBER:
					TheResult["checkTime"] = GlobalFunctions.TimeStampToTimeString(item.CheckTime)
				if JudgeValid.JudgeUserStatusJoined(item.Status) == True:
					ResultList.append(TheResult)
		except:
			Success = False
			Reason = "查询活动成员失败!"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		Result["participantList"] = ResultList
		ErrorInfo = {}
	else:
		Result = {}
		ErrorInfo["reason"] = Reason
		ErrorInfo["code"] = Code
	return Result, ErrorInfo
def ShowSelfActivity(TheUserID):
	'''
	描述:查询自己参与过的所有活动和历史记录
	参数: 自己的OpenID
	返回:第一个是一个字典,里面就一个字典数组activityList,字典每个字典有活动具体信息和自己的情况,失败为空
		 第二个是失败状态信息,成功是空,失败有reason和code
	'''
	Result = {}
	Success = True
	ResultList = []
	ErrorInfo = {}
	Reason = ""
	Code = 0
	if Success:
		try:
			TheUser = User.objects.get(OpenID = TheUserID)
			TheJoinActivityList = JoinInformation.objects.filter(UserId = TheUser)
			TheJoinActivityList = TheJoinActivityList.reverse()
		except:
			Success = False
			Reason = "未找到用户!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		try:
			i = len(TheJoinActivityList) - 1
			while i >= 0:
				item = TheJoinActivityList[i]
				TheResult = {}
				TheResult = ActivityManager.QueryActivity(item.ActivityId.ID)
				if TheResult == {}:
					continue
				TheResult["id"] = item.ActivityId.ID
				TheResult["selfStatus"] = item.Status
				TheResult["selfRole"] = item.Role
				TheResult["submitTime"] = GlobalFunctions.TimeStampToTimeString(item.SubmitTime)
				if item.JoinTime != Constants.UNDEFINED_NUMBER:
					TheResult["joinTime"] = GlobalFunctions.TimeStampToTimeString(item.JoinTime)
				if item.CheckTime != Constants.UNDEFINED_NUMBER:
					TheResult["checkTime"] = GlobalFunctions.TimeStampToTimeString(item.CheckTime)
				ResultList.append(TheResult)
				i -= 1
		except:
			Success = False
			Reason = "查询历史记录失败!"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		Result["activityList"] = ResultList
		ErrorInfo = {}
	else:
		Result = {}
		ErrorInfo["reason"] = Reason
		ErrorInfo["code"] = Code
	return Result, ErrorInfo
Exemple #3
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 {}
Exemple #5
0
def ShowOneActivity(TheActivityID):
	'''
	描述:给定活动id,查询活动具体信息
	参数:用户id和活动id
	返回:一个字典,里面有活动各种信息,错误信息
	成功:错误信息空
	失败:返回字典空,错误信息存在
	'''
	Success = True
	Result = {}
	ErrorInfo = {}
	Reason = ""
	Code = 0
	if Success:
		try:
			TheActivity = Activity.objects.get(ID = TheActivityID)
		except:
			Success = False
			Reason = "未找到该活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND

	if Success:
		Result = ActivityManager.QueryActivity(TheActivityID)
		if Result == {}:
			Success = False
			Reason = "查询活动失败!"
			Code = Constants.ERROR_CODE_UNKNOWN

	if Success:
		if 1:
			Result["position"] = TheActivity.GPSPlace
			TheJoinActivityList = JoinInformation.objects.filter(ActivityId = TheActivity)
			Result["participants"] = []
			NumberNeedAudit = 0
			for item in TheJoinActivityList:
				TheUserInfo = {}
				TheId = item.UserId.OpenID
				TheStatus = item.Status
				TheUserInfo["openId"] = TheId
				TheUserInfo["name"] = item.UserId.Name
				TheUserInfo["avatarUrl"] = GlobalFunctions.GetTrueAvatarUrlUser(item.UserId.AvatarURL)
				TheUserInfo["userStatus"] = TheStatus
				TheUserInfo["userRole"] = item.Role
				TheUserInfo["point"] = item.UserId.Point
				if JudgeValid.JudgeUserStatusJoined(TheStatus):
					Result["participants"].append(TheUserInfo)
				if item.Role == Constants.USER_ROLE_CREATOR:
					Result["creator"] = TheId
				if item.Status == Constants.USER_STATUS_WAITVALIDATE:
					NumberNeedAudit += 1
			Result["needAuditCount"] = NumberNeedAudit
		else:
			Success = False
			Reason = "查询活动失败!"
			Code = Constants.ERROR_CODE_UNKNOWN

	if Success:
		try:
			TheReportActivityList = ReportInformation.objects.filter(ActivityId = TheActivity)
			Result["reporters"] = []
			for item in TheReportActivityList:
				TheUserInfo = {}
				TheUserInfo["openId"] = item.UserId.OpenID
				TheUserInfo["name"] = item.UserId.Name
				TheUserInfo["avatarUrl"] = GlobalFunctions.GetTrueAvatarUrlUser(item.UserId.AvatarURL)
				TheUserInfo["submitMsg"] = item.Reason
				TheUserInfo["submitTime"] = GlobalFunctions.TimeStampToTimeString(item.SubmitTime)
				Result["reporters"].append(TheUserInfo)
			Result["reportCount"] = len(Result["reporters"])
		except:
			Success = False
			Reason = "查询活动失败!"
			Code = Constants.ERROR_CODE_UNKNOWN

	if Success:
		try:	
			Result["rules"] = {}
			Result["rules"] = ActivityManager.ShowAllAdvancedRules(TheActivityID)
			Result["rules"]["ruleType"] = TheActivity.GlobalRule
		except:
			Success = False
			Reason = "查询活动失败!"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		return Result, {}
	else:
		ErrorInfo["reason"] = Reason
		ErrorInfo["code"] = Code
		return {}, ErrorInfo
Exemple #6
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
def ShowAllAuditMembers(TheUserID, TheActivityID):
	'''
	描述:查询活动所有待审核成员---管理员
	参数: 用户id,活动id
	返回:
	第一个是一个字典,失败为空,成功格式如下
	{
  	"members": [
    {
      "openId": "xxxxxxx",
      "name": "李大爷",
      "submitTime": "2019-11-01 08:00:00",
      "submitMsg": "我是管理员的爸爸,不让我参加?"
    }
  	]
	}
	第二个是错误信息,成功空字典,否则有reason和code
	'''
	Result = {}
	ErrorInfo = {}
	Reason = ""
	Code = 0
	Success = True
	ResultList = []
	if Success:
		try:
			if JudgeValid.JudgeWhetherManager(TheUserID, TheActivityID) != True:
				Success = False
				Reason = "权限不足,需要是管理员或创建者!"
				Code = Constants.ERROR_CODE_LACK_ACCESS
			TheActivity = Activity.objects.get(ID = TheActivityID)
			TheJoinActivityList = JoinInformation.objects.filter(ActivityId = TheActivity)
			if TheActivity.CanBeSearched != True:
				Success = False
				Reason = "未找到活动!"
				Code = Constants.ERROR_CODE_NOT_FOUND
		except:
			Success = False
			Reason = "未找到活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	
	if Success:
		try:
			for item in TheJoinActivityList:
				TheResult = {}
				if item.Status == Constants.USER_STATUS_WAITVALIDATE:
					TheResult["openId"] = item.UserId.OpenID
					TheResult["name"] = item.UserId.Name
					TheResult["avatarUrl"] = GlobalFunctions.GetTrueAvatarUrlUser(item.UserId.AvatarURL)
					TheResult["submitTime"] = GlobalFunctions.TimeStampToTimeString(item.SubmitTime)
					TheResult["point"] = item.UserId.Point
					TheResult["submitMsg"] = item.JoinReason
					ResultList.append(TheResult)
		except:
			Success = False
			Reason = "查询待审核成员失败!"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		Result["users"] = ResultList
		ErrorInfo = {}
	else:
		Result = {}
		ErrorInfo["reason"] = Reason
		ErrorInfo["code"] = Code
	return Result, ErrorInfo