def ChangeUserRole(SelfID, TheUserID, TheActivityID, NewRole):
	'''
	描述:修改用户的权限信息
	参数:自己的openid,待修改用户id,活动id,用户新角色
	返回:{result:success}/{result:fail,reason:xxx, code:xxx}
	权限的话,创建者不能变别的,别的也不能变创建者,只有创建者能把其他人设置成管理员或取消管理员
	'''
	Success = True
	Result = {}
	Reason = ""
	Code = Constants.UNDEFINED_NUMBER
	if Success:
		try:
			TheSelf = User.objects.get(OpenID = SelfID)
			TheUser = User.objects.get(OpenID = TheUserID)
			TheActivity = Activity.objects.get(ID = TheActivityID)
			TheSelfJoinInformation = JoinInformation.objects.get(UserId = TheSelf, ActivityId = TheActivity)
			TheUserJoinInformation = JoinInformation.objects.get(UserId = TheUser, ActivityId = TheActivity)
		except:
			Success = False
			Reason = "用户未参加该活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		if JudgeValid.JudgeActivityNormal(TheActivityID) != True: 
			Success = False
			Reason = "活动状态为异常或结束,不能操作!"
			Code = Constants.ERROR_CODE_INVALID_CHANGE
	if Success:
		try:
			SelfRole = TheSelfJoinInformation.Role
			if SelfRole != Constants.USER_ROLE_CREATOR:
				Success = False
				Reason = "只有创建者才能设置和取消管理员!"
				Code = Constants.ERROR_CODE_NOT_FOUND
		except:
			Success = False
			Reason = "请求参数不合法!"
			Code = Constants.ERROR_CODE_INVALID_PARAMETER
	if Success:
		try:
			OldRole = TheUserJoinInformation.Role
			if OldRole == Constants.USER_ROLE_CREATOR or NewRole == Constants.USER_ROLE_CREATOR:
				Success = False
				Reason = "不能变更该活动的创建者!"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
			TheUserJoinInformation.Role = NewRole
			TheUserJoinInformation.save()
		except:
			Success = False
			Reason = "请求参数不合法!"
			Code = Constants.ERROR_CODE_INVALID_PARAMETER
	if Success:
		Result["result"] = "success"
	else:
		Result["result"] = "fail"
		Result["reason"] = Reason
		Result["code"] = Code
	return Result
    def LoadDatabaseInfo(self):
        '''
		描述:从数据库里读取现有的信息用于搜索推荐
		参数:无
		返回:无
		'''
        Info = Activity.objects.all()
        Writer = self.Index.writer()
        for item in Info:
            if JudgeValid.JudgeActivityNormal(item.ID):
                Writer.add_document(path="/" + str(item.ID),
                                    content=item.Name + item.Tags)
        Writer.commit()
def ReportActivity(TheUserID, TheActivityID, TheReportReason):
	'''
	描述:举报函数	
	参数:用户id,活动id, 举报原因
	返回:成功{result: success},失败{result:fail,reason:xxx, code:xxx}
	'''
	Success = True
	Reason = ""
	Return = {}
	Code = Constants.UNDEFINED_NUMBER
	TheStatus = -1
	TheRole = -1
	if Success:
		try:
			TheUser = User.objects.get(OpenID = TheUserID)
			TheActivity = Activity.objects.get(ID = TheActivityID)
		except:
			Success = False
			Reason = "未找到用户或活动"
			Code = Constants.ERROR_CODE_NOT_FOUND
	#print(Success)	
	TheRole = Constants.USER_ROLE_COMMONER
	if Success:
		if JudgeValid.JudgeActivityNormal(TheActivityID) != True: 
			Success = False
			Reason = "活动状态为异常或结束,不能操作!"
			Code = Constants.ERROR_CODE_INVALID_CHANGE

	if Success:
		try:
			TheSubmitTime = GlobalFunctions.GetCurrentTime()
			try:
				TheReportInformation = ReportInformation.objects.get(UserId = TheUser, ActivityId = TheActivity)
				TheReportInformation.delete()
			except:
				donothing = 0
			TheReportInformation = ReportInformation.objects.create(UserId = TheUser, ActivityId = TheActivity, \
			SubmitTime = TheSubmitTime, Reason = TheReportReason)
			TheReportInformation.save()
		except:
			Success = False
			Reason = "添加举报记录失败"
			Code = Constants.ERROR_CODE_UNKNOWN
	#print(Return)
	if Success:
		Return["result"] = "success"
	else:
		Return["result"] = "fail"
		Return["reason"] = Reason
		Return["code"] = Code
	return Return
Exemplo n.º 4
0
def DeleteActivity(TheUserID, TheActivityID):
    '''
	描述:删除活动函数(事实是将活动设置为异常,不可见)
	参数:活动id
	返回:成功True 失败False
	'''
    Success = True
    Result = {}
    Reason = ""
    Code = Constants.UNDEFINED_NUMBER
    if Success:
        try:
            TheUser = User.objects.get(OpenID=TheUserID)
            TheActivity = Activity.objects.get(ID=TheActivityID)
            if JudgeValid.JudgeWhetherCreator(TheUserID,
                                              TheActivityID) != True:
                Success = False
                Reason = "没有权限,只有管理员才能删除活动!!"
                Code = Constants.ERROR_CODE_LACK_ACCESS
        except:
            Success = False
            Code = Constants.ERROR_CODE_NOT_FOUND
            Reason = "未找到该活动!"
    if Success:
        if JudgeValid.JudgeActivityNormal(TheActivityID) != True:
            Success = False
            Reason = "活动状态为异常或结束,不能操作!"
            Code = Constants.ERROR_CODE_INVALID_CHANGE
        if TheActivity.StatusCheck != Constants.ACTIVITY_STATUS_CHECK_BEFORE:
            Success = False
            Reason = "签到已经开始,不能删除活动!"
            Code = Constants.ERROR_CODE_INVALID_CHANGE
    if Success:
        TheActivity.StatusGlobal = Constants.ACTIVITY_STATUS_GLOBAL_EXCEPT
        TheActivity.save()

        TheSearcher = SearchAndRecommend.WhooshSearcher.Create()
        TheSearcher.DeleteOneInfo(TheActivityID)

    if Success == True:
        Result["result"] = "success"
    else:
        Result["result"] = "fail"
        Result["reason"] = Reason
        Result["code"] = Code
    return Result
Exemplo n.º 5
0
def ChangeActivityDetail(TheUserID, TheActivityID, Information):
    '''
	描述:修改活动详情
	参数:用户openid,活动id,待修改信息
	返回:{result:success}/{result:fail,reason:xxx, code:xxx}
	'''
    Success = True
    Return = {}
    Reason = ""
    Code = Constants.UNDEFINED_NUMBER
    #判断是否能找到这个活动
    if Success:
        try:
            TheUser = User.objects.get(OpenID=TheUserID)
            TheActivity = Activity.objects.get(ID=TheActivityID)
            if JudgeValid.JudgeWhetherManager(TheUserID,
                                              TheActivityID) != True:
                Success = False
                Reason = "没有修改权限,需要是管理员或者创建者!"
                Code = Constants.ERROR_CODE_LACK_ACCESS
        except:
            Success = False
            Reason = "没有修改权限"
            Code = Constants.ERROR_CODE_LACK_ACCESS
    if Success:
        if JudgeValid.JudgeActivityNormal(TheActivityID) != True:
            Success = False
            Reason = "活动状态为异常或结束,不能操作!"
            Code = Constants.ERROR_CODE_INVALID_CHANGE
    if Success:
        try:
            TheDescription = Information["description"]
            TheActivity.Description = TheDescription
            TheActivity.save()
        except:
            Success = False
            Reason = "参数不合法,修改失败!"
            Code = Constants.ERROR_CODE_INVALID_PARAMETER
    if Success == False:
        Return["result"] = "fail"
        Return["reason"] = Reason
        Return["code"] = Code
    else:
        Return["result"] = "success"
    return Return
Exemplo n.º 6
0
def UploadActivityQRCode(TheUserID, TheActivityID):
    '''
	描述:上传活动二维码
	参数:用户openid,活动id
	返回:结果,图片文件名(失败是None)
	'''
    Success = True
    Result = {}
    Reason = ""
    TheImageName = ""
    Code = Constants.UNDEFINED_NUMBER
    print(TheUserID, TheActivityID)
    if Success:
        try:
            TheUser = User.objects.get(OpenID=TheUserID)
            TheActivity = Activity.objects.get(ID=TheActivityID)
            if JudgeValid.JudgeWhetherManager(TheUserID,
                                              TheActivityID) != True:
                Success = False
                Reason = "没有权限,只有管理员才能设置活动二维码!!"
                Code = Constants.ERROR_CODE_LACK_ACCESS
        except:
            Success = False
            Code = Constants.ERROR_CODE_NOT_FOUND
            Reason = "未找到该活动!"
    print(Success)
    if Success:
        if JudgeValid.JudgeActivityNormal(TheActivityID) != True:
            Success = False
            Reason = "活动状态为异常或结束,不能操作!"
            Code = Constants.ERROR_CODE_INVALID_CHANGE
    if Success:
        TheNewCode = GlobalFunctions.GenerateActivityCode()
        TheActivity.Code = TheNewCode
        TheActivity.save()
        TheImageName = GlobalFunctions.GenerateQRCode(TheActivityID,
                                                      TheNewCode)
    if Success == True:
        Result["result"] = "success"
    else:
        Result["result"] = "fail"
        Result["reason"] = Reason
        Result["code"] = Code
        TheImageName = None
    return Result, TheImageName
def CheckInActivity(TheUserID, TheActivityID, TheCode, TheDistance):
	'''
	描述:用户签到
	参数:用户openid,活动id,二维码code, 距离
	返回:成功{result:success}
		 失败:{result:fail,reason:xxx,code:xxx}
	'''
	Return = {}
	Reason = ""
	Code = 0
	Success = True
	ThePass = -1
	ResultList = []
	if Success:
		try:
			TheActivity = Activity.objects.get(ID = TheActivityID)
			TheUser = User.objects.get(OpenID = TheUserID)

			if TheCode != None:
				if TheCode != TheActivity.Code:
					Success = False
					Reason = "二维码和活动不匹配!"
					Code = Constants.ERROR_CODE_INVALID_CHANGE
			elif TheDistance != None:
				if TheDistance > Constants.SUCCESS_THRESHOLD:
					Success = False
					Reason = "距离太远,签到失败!"
					Code = Constants.ERROR_CODE_INVALID_CHANGE
			else:
				Success = False
				Reason = "请求参数不合法!"
				Code = Constants.ERROR_CODE_INVALID_PARAMETER
		except:
			Success = False
			Reason = "未找到用户或活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		if JudgeValid.JudgeActivityNormal(TheActivityID) != True: 
			Success = False
			Reason = "活动状态为异常或结束,不能操作!"
			Code = Constants.ERROR_CODE_INVALID_CHANGE
	if Success:
		try:
			TheJoinActivity = JoinInformation.objects.get(ActivityId = TheActivity, UserId = TheUser)
			TheStatus = TheJoinActivity.Status
			TheRole = TheJoinActivity.Role
			if JudgeValid.JudgeUserStatusDoingActivity(TheStatus) != True:
				Success = False
				Reason = "该用户不是活动正式成员"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
			elif TheStatus == Constants.USER_STATUS_CHECKED:
				Success = False
				Reason = "该用户已经签到!"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
		except:
			Success = False
			Reason = "用户未参加该活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
		#判断状态是否可行
		if Success:
			if JudgeValid.JudgeActivityCanCheck(TheActivityID)!= True:
				Success = False
				Reason = "当前活动不在可以签到状态,可能签到未开始,已暂停或已经截止"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
	if Success:
		try:
			TheCheckTime = GlobalFunctions.GetCurrentTime()
			TheJoinActivity.CheckTime = TheCheckTime
			TheJoinActivity.Status = Constants.USER_STATUS_CHECKED
			TheJoinActivity.save()
		except:
			Success = False
			Reason = "签到失败!"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		Return["result"] = "success"
	else:
		Return["result"] = "fail"
		Return["reason"] = Reason
		Return["code"] = Code
	return Return
def RemoveUser(TheManagerID, TheUserID, TheActivityID):
	'''
	描述:将用户踢出活动
	参数:管理员openid,用户openid,活动id
	返回:成功{result:success}
		 失败:{result:fail,reason:xxx,code:xxx}
	'''
	Return = {}
	Reason = ""
	Code = 0
	Success = True
	ThePass = -1
	ResultList = []
	if Success:
		try:
			TheActivity = Activity.objects.get(ID = TheActivityID)
			TheUser = User.objects.get(OpenID = TheUserID)
		except:
			Success = False
			Reason = "未找到用户或活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		if JudgeValid.JudgeActivityNormal(TheActivityID) != True: 
			Success = False
			Reason = "活动状态为异常或结束,不能操作!"
			Code = Constants.ERROR_CODE_INVALID_CHANGE
	if Success:
		try:
			TheJoinActivity = JoinInformation.objects.get(ActivityId = TheActivity, UserId = TheUser)
			TheStatus = TheJoinActivity.Status
			TheRole = TheJoinActivity.Role
			if JudgeValid.JudgeUserStatusDoingActivity(TheStatus) != True:
				Success = False
				Reason = "该用户不是活动正式成员"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
		except:
			Success = False
			Reason = "用户未参加该活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		if TheRole == Constants.USER_ROLE_CREATOR:
			Success = False
			Reason = "不能将创建者踢出活动!"
			Code = Constants.ERROR_CODE_INVALID_CHANGE
		elif TheRole == Constants.USER_ROLE_MANAGER:
			if JudgeValid.JudgeWhetherCreator(TheManagerID, TheActivityID) != True:
				Success = False
				Reason = "权限不足,只有创建者能把管理员踢出活动!"
				Code = Constants.ERROR_CODE_LACK_ACCESS
		else:
			if JudgeValid.JudgeWhetherManager(TheManagerID, TheActivityID) != True:
				Success = False
				Reason = "权限不足,需要是管理员或创建者!"
				Code = Constants.ERROR_CODE_LACK_ACCESS

	if Success:
		try:
			TheJoinActivity.Role = Constants.USER_ROLE_COMMONER
			TheJoinActivity.Status = Constants.USER_STATUS_REFUSED
			TheActivity.CurrentUser = TheActivity.CurrentUser - 1
			TheJoinActivity.save()
			TheActivity.save()
		except:
			Success = False
			Reason = "踢出活动失败!"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		Return["result"] = "success"
	else:
		Return["result"] = "fail"
		Return["reason"] = Reason
		Return["code"] = Code
	return Return
def AuditUser(TheManagerID, TheUserID, TheActivityID, WhetherPass):
	'''
	描述:审核用户
	参数:管理员openid,用户openid,活动id,是否通过(0或1)
	返回:成功{result:success}
		 失败:{result:fail,reason:xxx,code:xxx}
	'''
	Return = {}
	Reason = ""
	Code = 0
	Success = True
	ThePass = -1
	ResultList = []
	if Success:
		try:
			if JudgeValid.JudgeWhetherManager(TheManagerID, TheActivityID) != True:
				Success = False
				Reason = "权限不足,需要是管理员或创建者!"
				Code = Constants.ERROR_CODE_LACK_ACCESS
			TheActivity = Activity.objects.get(ID = TheActivityID)
			TheUser = User.objects.get(OpenID = TheUserID)
		except:
			Success = False
			Reason = "未找到用户或活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		if JudgeValid.JudgeActivityNormal(TheActivityID) != True: 
			Success = False
			Reason = "活动状态为异常或结束,不能操作!"
			Code = Constants.ERROR_CODE_INVALID_CHANGE
	if Success:
		try:
			TheJoinActivity = JoinInformation.objects.get(ActivityId = TheActivity, UserId = TheUser)
			TheStatus = TheJoinActivity.Status
			if TheStatus != Constants.USER_STATUS_WAITVALIDATE:
				Success = False
				Reason = "该用户不是待审核状态"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
		except:
			Success = False
			Reason = "用户未参加该活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		try:
			ThePass = int(WhetherPass)
			if ThePass != 0 and ThePass != 1:
				Success = False
				Reason = "参数不合法!"
				Code = Constants.ERROR_CODE_INVALID_PARAMETER
		except:
			Success = False
			Reason = "参数不合法!"
			Code = Constants.ERROR_CODE_INVALID_PARAMETER
	if Success:
		try:
			if ThePass == 0:
				TheJoinActivity.Status = Constants.USER_STATUS_REFUSED
				TheJoinActivity.save()
			else:
				if TheActivity.MaxUser != Constants.UNDEFINED_NUMBER and TheActivity.CurrentUser >= TheActivity.MaxUser:
					Success = False
					Reason = "当前人数已满,不能审核通过!"
					Code = Constants.ERROR_CODE_INVALID_CHANGE
				else:
					CurrentTime = GlobalFunctions.GetCurrentTime()
					TheJoinActivity.Status = Constants.USER_STATUS_JOINED
					TheJoinActivity.JoinTime = CurrentTime
					TheJoinActivity.JoinReason = "无"
					TheActivity.CurrentUser = TheActivity.CurrentUser + 1
					TheActivity.save()
					TheJoinActivity.save()
		except:
			Success = False
			Reason = "审核失败!"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		Return["result"] = "success"
	else:
		Return["result"] = "fail"
		Return["reason"] = Reason
		Return["code"] = Code
	return Return
def QuitActivity(TheUserID, TheActivityID):
	'''
	描述:退出报名函数	
	参数:用户id,活动id,是否是管理员,报名原因(没有就是None)
	返回:成功{result: success},失败{result:fail,reason:xxx, code:xxx}
	'''
	Success = True
	Reason = ""
	Return = {}
	Code = Constants.UNDEFINED_NUMBER
	TheStatus = -1
	TheRole = -1
	if Success:
		try:
			TheUser = User.objects.get(OpenID = TheUserID)
			TheActivity = Activity.objects.get(ID = TheActivityID)
		except:
			Success = False
			Reason = "未找到用户或活动"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		if JudgeValid.JudgeActivityNormal(TheActivityID) != True: 
			Success = False
			Reason = "活动状态为异常或结束,不能操作!"
			Code = Constants.ERROR_CODE_INVALID_CHANGE
	if Success:
		try:
			Info = JoinInformation.objects.get(UserId = TheUser, ActivityId = TheActivity)
			#print(Info)
		except:
			Success = False
			Reason = "用户未加入活动!"
			Code = Constants.ERROR_CODE_NOT_FOUND
	if Success:
		try:
			TheStatus = Info.Status
			TheRole = Info.Role
			if TheRole == Constants.USER_ROLE_CREATOR:
				Success = False
				Reason = "创建者不能退出活动!"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
			if JudgeValid.JudgeUserStatusCanQuit(TheStatus) != True:
				Success = False
				Reason = "只有待审核用户和正式参与者可以退出活动!"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
		except:
			Success = False
			Reason = "退出活动失败"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		try:
			Info.delete()
			if TheStatus != Constants.USER_STATUS_WAITVALIDATE:
				TheActivity.CurrentUser = TheActivity.CurrentUser - 1
				TheActivity.save()
		except:
			Success = False
			Reason = "退出活动失败"
			Code = Constants.ERROR_CODE_UNKNOWN
	if Success:
		Return["result"] = "success"
	else:
		Return["result"] = "fail"
		Return["reason"] = Reason
		Return["code"] = Code
	return Return
def JoinActivity(TheUserID, TheActivityID, TheJoinReason):
	'''
	描述:报名函数	
	参数:用户id,活动id,报名原因(没有就是None)
	返回:成功{result: success},失败{result:fail,reason:xxx, code:xxx}
	'''
	Success = True
	Reason = ""
	Return = {}
	Code = Constants.UNDEFINED_NUMBER
	TheStatus = -1
	TheRole = -1
	if Success:
		try:
			TheUser = User.objects.get(OpenID = TheUserID)
			TheActivity = Activity.objects.get(ID = TheActivityID)
		except:
			Success = False
			Reason = "未找到用户或活动"
			Code = Constants.ERROR_CODE_NOT_FOUND
	#print(Success)	
	TheRole = Constants.USER_ROLE_COMMONER
	if Success:
		if JudgeValid.JudgeActivityNormal(TheActivityID) != True: 
			Success = False
			Reason = "活动状态为异常或结束,不能操作!"
			Code = Constants.ERROR_CODE_INVALID_CHANGE
	#判断是否已经加入
	if Success:
		if JudgeValid.JudgeUserJoinedActivity(TheUserID, TheActivityID) == True:
			Success = False
			Reason = "已经加入了"
			Code = Constants.ERROR_CODE_INVALID_CHANGE

	if Success:
        #判断人数是否可行
		if TheActivity.MaxUser != Constants.UNDEFINED_NUMBER and TheActivity.CurrentUser >= TheActivity.MaxUser:
			Success = False
			Reason = "活动人数已满"
			Code = Constants.ERROR_CODE_INVALID_CHANGE

		#判断状态是否可行
		if Success:
			if JudgeValid.JudgeActivityCanJoin(TheActivityID) != True:
				Success = False
				Reason = "当前活动不在可以报名状态,可能报名未开始,已暂停或已经截止"
				Code = Constants.ERROR_CODE_INVALID_CHANGE
		#判断高级选项
		if Success:
			TheStatus = JudgeValid.JudgeWhetherCanJoinAdvanced(TheUserID, TheActivityID)
			if TheStatus == Constants.UNDEFINED_NUMBER:
				Success = False
				Reason = "不符合报名条件"
				Code = Constants.ERROR_CODE_REJECT
			elif TheStatus != Constants.USER_STATUS_WAITVALIDATE:
				#直接加入,不需要条件
				TheJoinReason = None
			else:
				#待审核没有reason不行
				if TheJoinReason == None or len(TheJoinReason) == 0:
					Success = False
					Reason = "未输入报名原因!"
					Code = Constants.ERROR_CODE_NO_REASON
		#加入
		#print(TheStatus, Success)
		if Success:
			Return = AddUserActivity(TheUserID, TheActivityID, TheStatus, TheRole, TheJoinReason)
		else:
			Return["result"] = "fail"
			Return["reason"] = Reason
			Return["code"] = Code
	#print(Return)
	return Return
Exemplo n.º 12
0
def ChangeActivity(TheUserID, Information):
    '''
	描述:修改活动信息
	参数:用户openid,待修改信息
	返回:{result:success}/{result:fail,reason:xxx, code:xxx}
	'''
    Success = True
    Return = {}
    Reason = ""
    Code = Constants.UNDEFINED_NUMBER
    ChangeDictionary = {}
    #判断是否能找到这个活动
    if Success:
        try:
            TheUser = User.objects.get(OpenID=TheUserID)
            TheActivity = Activity.objects.get(ID=Information["id"])
            if JudgeValid.JudgeWhetherManager(TheUserID,
                                              Information["id"]) != True:
                Success = False
                Reason = "没有修改权限,需要是管理员或者创建者!"
                Code = Constants.ERROR_CODE_LACK_ACCESS
        except:
            Success = False
            Reason = "没有修改权限"
            Code = Constants.ERROR_CODE_LACK_ACCESS
    if Success:
        if JudgeValid.JudgeActivityNormal(Information["id"]) != True:
            Success = False
            Reason = "活动状态为异常或结束,不能操作!"
            Code = Constants.ERROR_CODE_INVALID_CHANGE
    #读取修改数据
    WhetherJudgeTime = False
    if Success:
        try:
            if "name" in Information:
                ChangeDictionary["name"] = Information["name"]
            else:
                ChangeDictionary["name"] = TheActivity.Name
            if "place" in Information:
                ChangeDictionary["place"] = Information["place"]
            else:
                ChangeDictionary["place"] = TheActivity.Place
            if "start" in Information:
                WhetherJudgeTime = True
                ChangeDictionary["start"] = int(
                    GlobalFunctions.TimeStringToTimeStamp(
                        Information["start"]))
            else:
                ChangeDictionary["start"] = TheActivity.StartTime
            if "end" in Information:
                WhetherJudgeTime = True
                ChangeDictionary["end"] = int(
                    GlobalFunctions.TimeStringToTimeStamp(Information["end"]))
            else:
                ChangeDictionary["end"] = TheActivity.EndTime
            if "signupBeginAt" in Information:
                WhetherJudgeTime = True
                ChangeDictionary["signupBeginAt"] = int(
                    GlobalFunctions.TimeStringToTimeStamp(
                        Information["signupBeginAt"]))
            else:
                ChangeDictionary["signupBeginAt"] = TheActivity.SignUpStartTime
            if "signupStopAt" in Information:
                WhetherJudgeTime = True
                ChangeDictionary["signupStopAt"] = int(
                    GlobalFunctions.TimeStringToTimeStamp(
                        Information["signupStopAt"]))
            else:
                ChangeDictionary["signupStopAt"] = TheActivity.SignUpEndTime
            if "minUser" in Information:
                ChangeDictionary["minUser"] = int(Information["minUser"])
            else:
                ChangeDictionary["minUser"] = TheActivity.MinUser
            if "maxUser" in Information:
                ChangeDictionary["maxUser"] = int(Information["maxUser"])
            else:
                ChangeDictionary["maxUser"] = TheActivity.MaxUser
            if "type" in Information:
                ChangeDictionary["type"] = Information["type"]
            else:
                ChangeDictionary["type"] = TheActivity.Type
            if "statusGlobal" in Information:
                ChangeDictionary["statusGlobal"] = Information["statusGlobal"]
            else:
                ChangeDictionary["statusGlobal"] = TheActivity.StatusGlobal
            if "statusJoin" in Information:
                ChangeDictionary["statusJoin"] = Information["statusJoin"]
            else:
                ChangeDictionary["statusJoin"] = TheActivity.StatusJoin
            if "statusCheck" in Information:
                ChangeDictionary["statusCheck"] = Information["statusCheck"]
            else:
                ChangeDictionary["statusCheck"] = TheActivity.StatusCheck
            if "canBeSearched" in Information:
                ChangeDictionary["canBeSearched"] = bool(
                    Information["canBeSearched"])
            else:
                ChangeDictionary["canBeSearched"] = TheActivity.CanBeSearched
            if "imageUrl" in Information:
                ChangeDictionary["imageUrl"] = Information["imageUrl"]
            else:
                ChangeDictionary["imageUrl"] = TheActivity.ImageURL
            if "position" in Information:
                ChangeDictionary["position"] = Information["position"]
            else:
                ChangeDictionary["position"] = TheActivity.GPSPlace

            if "tags" in Information:
                if JudgeValid.JudgeTagListValid(Information["tags"]) != True:
                    Success = False
                    Reason = "参数不合法,标签不能带有英文逗号!"
                    Code = Constants.ERROR_CODE_INVALID_PARAMETER
                ChangeDictionary["tags"] = GlobalFunctions.MergeTags(
                    Information["tags"])
            else:
                ChangeDictionary["tags"] = TheActivity.Tags
            #如果rules不存在就changedictionary为空,要判断
            if "rules" in Information:
                if "ruleType" in Information["rules"]:
                    ChangeDictionary["ruleType"] = Information["rules"][
                        "ruleType"]
                else:
                    ChangeDictionary["ruleType"] = TheActivity.GlobalRule
                ChangeDictionary["rules"] = Information["rules"]
            else:
                ChangeDictionary["rules"] = []
                ChangeDictionary["ruleType"] = TheActivity.GlobalRule
            ChangeDictionary["curTime"] = GlobalFunctions.GetCurrentTime()
            ChangeDictionary["curUser"] = TheActivity.CurrentUser

        except:
            Success = False
            Reason = "待修改数据格式不合法"
            Code = Constants.ERROR_CODE_INVALID_PARAMETER
    #print(Success)
    #判断活动type修改后是否有效
    if Success:
        try:
            JudgeResult = JudgeValid.JudgeTypeChangeValid(
                TheActivity.Type, ChangeDictionary["type"],
                TheActivity.StatusGlobal)
            if JudgeResult["result"] != "success":
                Success = False
                Reason = JudgeResult["reason"]
                Code = JudgeResult["code"]
        except:
            Success = False
            Reason = "待修改数据格式不合法"
            Code = Constants.ERROR_CODE_INVALID_PARAMETER
    #判断时间,人数等修改后是否有效
    if Success and WhetherJudgeTime:
        try:
            JudgeResult = JudgeValid.JudgeParameterValid(ChangeDictionary["curTime"], ChangeDictionary["start"], ChangeDictionary["end"], \
            ChangeDictionary["signupBeginAt"], ChangeDictionary["signupStopAt"], ChangeDictionary["curUser"], ChangeDictionary["minUser"], \
            ChangeDictionary["maxUser"])
            if JudgeResult["result"] != "success":
                Success = False
                Reason = JudgeResult["reason"]
                Code = Constants.ERROR_CODE_INVALID_CHANGE
        except:
            Success = False
            Reason = "待修改数据格式不合法"
            Code = Constants.ERROR_CODE_INVALID_PARAMETER
    if Success and ChangeDictionary["maxUser"] != Constants.UNDEFINED_NUMBER:
        try:
            if ChangeDictionary["minUser"] > ChangeDictionary["maxUser"]:
                Success = False
                Reason = "最小人数不能大于最大人数!"
                Code = Constants.ERROR_CODE_INVALID_CHANGE
            if ChangeDictionary["curUser"] > ChangeDictionary["maxUser"]:
                Success = False
                Reason = "当前人数不能大于最大人数!"
                Code = Constants.ERROR_CODE_INVALID_CHANGE
        except:
            Success = False
            Reason = "待修改数据格式不合法"
            Code = Constants.ERROR_CODE_INVALID_PARAMETER
    #判断状态等改后是否有效
    if Success:
        try:
            JudgeResult = JudgeValid.JudgeActivityStatusChangeValid(
                TheActivity.StatusGlobal, ChangeDictionary["statusGlobal"])
            if JudgeResult["result"] != "success":
                Success = False
                Reason = JudgeResult["reason"]
                Code = Constants.ERROR_CODE_INVALID_CHANGE
            if JudgeValid.JudgeActivityStatusJoinValid(
                    ChangeDictionary["statusJoin"]) != True:
                Success = False
                Reason = "待修改的活动加入状态不合法"
                Code = Constants.ERROR_CODE_INVALID_PARAMETER
            if JudgeValid.JudgeActivityStatusCheckValid(
                    ChangeDictionary["statusCheck"]) != True:
                Success = False
                Reason = "待修改的活动签到状态不合法"
                Code = Constants.ERROR_CODE_INVALID_PARAMETER
            if JudgeValid.JudgeRuleTypeValid(
                    ChangeDictionary["ruleType"]) != True:
                Success = False
                Reason = "待修改的活动规则类型不合法!"
                Code = Constants.ERROR_CODE_INVALID_PARAMETER
        except:
            Success = False
            Reason = "待修改数据格式不合法"
            Code = Constants.ERROR_CODE_INVALID_PARAMETER
    #判断高级规则等改后是否有效
    if Success:
        try:
            if ChangeDictionary["rules"] != []:
                JudgeResult = JudgeValid.JudgeAdvancedRuleValid(
                    ChangeDictionary["rules"])
                if JudgeResult["result"] != "success":
                    Success = False
                    Reason = JudgeResult["reason"]
                    Code = Constants.ERROR_CODE_INVALID_CHANGE
        except:
            Success = False
            Reason = "待修改数据格式不合法"
            Code = Constants.ERROR_CODE_INVALID_PARAMETER
    #修改
    #print(Success)
    if Success:
        try:
            TheActivity.Name = ChangeDictionary["name"]
            TheActivity.Place = ChangeDictionary["place"]
            TheActivity.StartTime = ChangeDictionary["start"]
            TheActivity.EndTime = ChangeDictionary["end"]
            TheActivity.SignUpStartTime = ChangeDictionary["signupBeginAt"]
            TheActivity.SignUpEndTime = ChangeDictionary["signupStopAt"]
            TheActivity.MinUser = ChangeDictionary["minUser"]
            TheActivity.MaxUser = ChangeDictionary["maxUser"]
            TheActivity.Type = ChangeDictionary["type"]
            TheActivity.StatusGlobal = ChangeDictionary["statusGlobal"]
            TheActivity.StatusJoin = ChangeDictionary["statusJoin"]
            TheActivity.StatusCheck = ChangeDictionary["statusCheck"]
            TheActivity.CanBeSearched = ChangeDictionary["canBeSearched"]
            TheActivity.GlobalRule = ChangeDictionary["ruleType"]
            TheActivity.Tags = ChangeDictionary["tags"]
            TheActivity.ImageURL = ChangeDictionary["imageUrl"]
            TheActivity.GPSPlace = ChangeDictionary["position"]
            TheActivity.save()

            TheSearcher = SearchAndRecommend.WhooshSearcher.Create()
            TheSearcher.UpdateOneInfo(
                Information["id"], TheActivity.Name + ',' + TheActivity.Tags)
        except:
            Success = False
            Reason = "修改数据失败"
            Code = Constants.ERROR_CODE_UNKNOWN

    if Success:
        try:
            #print(ChangeDictionary["rules"], Information["id"])
            if ChangeDictionary["rules"] != []:
                #修改高级报名规则
                if ChangeAdvancedRules(Information["id"],
                                       ChangeDictionary["rules"]) != True:
                    Success = False
                    Reason = "修改数据失败"
                    Code = Constants.ERROR_CODE_UNKNOWN
        except:
            Success = False
            Reason = "修改数据失败"
            Code = Constants.ERROR_CODE_UNKNOWN

    if Success == False:
        Return["result"] = "fail"
        Return["reason"] = Reason
        Return["code"] = Code
    else:
        Return["result"] = "success"
    return Return