def get(self): #self.check_input('activityId') nid = self.request.GET.get('nid') if nid is not None: nid = self.request.GET.get('nid') #program_list = Programe.selectByActivity(Activity.selectById(self.input['activityId'])) program_list = Programe.selectByActivity(Activity.selectById(nid)) activityId = nid else: testtt = Activity.selectById(self.request.COOKIES['activityId']) program_list = Programe.selectByActivity( Activity.selectById(self.request.COOKIES['activityId'])) activityId = self.request.COOKIES['activityId'] show_list = [] num = 0 for program in program_list: num = num + 1 show_list.append({ 'id': program.id, 'name': program.name, 'sequence': program.sequence, #'actor': program.actor }) n = len(show_list) for j in range(0, n - 1): for i in range(0, n - 1 - j): if show_list[i]['sequence'] > show_list[i + 1]['sequence']: show_list[i], show_list[i + 1] = show_list[i + 1], show_list[i] return { 'view': 25, 'list': show_list, 'activityId': activityId, 'num': num }
def get(self): #self.check_input('activityId', 'commentId') show_list2 = [] comment_list = Picture.objects.filter(activity=Activity.selectById( self.request.COOKIES['activityId']), status=1) #comment_list = Comment.objects.filter(time__lt=timezone.now().time.second).filter(id__gt=self.input['commentId']) for comment in comment_list: show_list2.append({'id': comment.id, 'picUrl': comment.pic_url}) show_list = [] pic_list = Comment.objects.filter(activity=Activity.selectById( self.request.COOKIES['activityId']), status=1) #pic_list = Comment.objects.filter(time__lt=timezone.now().time.second ).filter(id__gt=self.input['pictureId']) for pic in pic_list: show_list.append({ 'id': pic.id, 'content': pic.content, 'color': pic.color, 'bolt': pic.bolt, 'incline': pic.incline, 'underline': pic.underline }) #return render(APIView, 'a/barrage.html', {'commentLinenumber': "", 'list': show_list, 'list2': show_list2}) return { 'view': 24, 'commentLinenumber': self.request.COOKIES['commentLinenumber'], 'list': show_list2, 'list2': show_list }
def post(self): self.check_input('activityId') if self.check_input('comment'): Comment.insertComment(Activity.selectById(self.input['activityId']), self.input['openId'], self.input['color'], self.input['content'], self.input['bolt'], self.input['underline'], self.input['incline'], timezone.now(), Barrage.OK) elif self.check_input('picUrl'): Picture.insertComment(Activity.selectById(self.input['activityId']), self.input['openId'],self.input['picUrl'],timezone.now(), Barrage.OK)
def get(self): pic_list = Picture.objects.filter( time__lt=timezone.now() + timedelta(seconds=-3), status=1, activity=Activity.selectById(self.request.COOKIES['activityId'])) show_list = [] for pic in pic_list: show_list.append({'picUrl': pic.pic_url.name}) pic_list = Picture.objects.filter( time__lt=timezone.now() + timedelta(seconds=-3), status=1, activity=Activity.selectById( self.request.COOKIES['activityId'])).delete() return {'view': 32, 'result': show_list}
def post(self): if not self.request.user.is_authenticated(): raise ValidateError("Please login!") if 'create' in self.request.POST: self.check_input("name", "description", "first", "second", "speical", 'third') Lottery.insertLottery( Activity.selectById(self.request.COOKIES['activityId']), self.input['name'], self.input['description'], self.input['first'], self.input['second'], self.input['third'], self.input['speical'], 0) #obj = Lottery(name=self.input['name'], #activity=Activity.selectById(self.input['activityId']), #description=self.input['description'], #first=self.input['first'], #status=self.input['status'], #second=self.input['second'], #third=self.input['third'], #speical=self.input['speical'], #) #obj.save() #if not Lottery.objects.get(self.input['name']): #raise LogicError('lottery creat failed') #else: return {'view': 10} if 'return' in self.request.POST: return {'view': 10}
def get(self): #self.check_input('activityId') #activity = Activity.selectById(self.input['activityId']) nid = self.request.GET.get('nid') activity = Activity.selectById(nid) if activity: data = { 'name': activity.name, 'description': activity.description, 'startTime': activity.start_time, 'endTime': activity.end_time, 'place': activity.place, 'picUrl': activity.pic_url, 'bgPicUrl': activity.bg_pic_url, 'organizer': activity.organizer, 'status': activity.status } return { 'view': 51, 'name': activity.name, 'description': activity.description, 'startTime': activity.start_time.isoformat()[:-6], 'endTime': activity.end_time.isoformat()[:-6], 'place': activity.place, 'picUrl': activity.pic_url, 'bgPicUrl': activity.bg_pic_url, 'organizer': activity.organizer, 'status': activity.status, 'acitivityid': nid } else: raise InputError()
def get(self): try: top = Comment.objects.get(status=3, activity=Activity.selectById( self.request.COOKIES['activityId'])) show_list = [] show_list.append({ 'content': top.content, 'bolt': top.bolt, 'incline': top.incline, 'color': top.color, 'underline': top.underline }) return {'view': 33, 'result': show_list} except: return { 'view': 33, 'result': [{ 'content': '当前无置顶弹幕', 'color': '16777215', 'bolt': False, 'incline': False, 'underline': False }] }
def post(self): self.check_input('openId', 'activityId') openid = self.input['openId'] actid = self.input['activityId'] activityId = Activity.selectById(actid) if activityId is not None: ActivityUser.insertActivityUser(openid, activityId) else: raise InputError('the user attend no activity')
def post(self): self.check_input('activityId') old_top = Comment.objects.get(status=Barrage.TOP) old_top.status = Barrage.NOT_OK old_top.save() Comment.insertComment(Activity.selectById(self.input['activityId']), self.request.user.username, self.input['color'], self.input['content'], self.input['bolt'], self.input['underline'], self.input['incline'], timezone.now(), Barrage.TOP)
def post(self): if not self.request.user.is_authenticated(): raise ValidateError("Please login!") self.check_input('activityId', 'status') activity = Activity.selectById(self.input['activityId']) if activity: activity.status = self.input['status'] activity.save() else: raise LogicError('no such activity')
def get(self): if not self.request.user.is_authenticated(): raise ValidateError("Please Login First!") top = Comment.objects.get(activity=Activity.selectById(self.input['activityId'])).get(status=Barrage.TOP) top_comment = { 'content': top.content, 'color': top.color, 'bolt': top.bolt, 'incline': top.incline, 'underline': top.underline } return top_comment
def get(self): comment_list = Comment.objects.filter( time__lt=timezone.now() + timedelta(seconds=-3), status=1, activity=Activity.selectById(self.request.COOKIES['activityId'])) #comment_list = Comment.objects.filter(time__lt=timezone.now() + timedelta(seconds=-3)) result = [] for i in comment_list: result.append({ 'content': i.content, 'bolt': i.bolt, 'color': i.color, 'underline': i.underline, 'incline': i.incline }) Comment.objects.filter( time__lt=timezone.now() + timedelta(seconds=-3), status=1, activity=Activity.selectById( self.request.COOKIES['activityId'])).delete() return {'view': 31, 'result': result}
def post(self): self.check_input('openId','activityId','color','content','bolt','underline','incline') usr = ActivityUser.selectActivityUser(self.input['openId'],self.input['activityId']) if usr is None: raise LogicError("Not Joined yet!") #if usr.status != ActivityUser.SIGN: # raise LogicError("Not Signed yet!") Comment.insertComment(activity = Activity.selectById(self.input['activityId']), open_id = self.input['openId'], color = self.input['color'], content = self.input['content'], bolt = self.input['bolt'], underline = self.input['underline'], incline = self.input['incline'],time = timezone.now(), status = Barrage.OK) return {'view': 40}
def get(self): self.check_input('activityId') program_list = Programe.selectByActivity(Activity.selectById(self.input['activityId'])) if not program_list: raise InputError('no such activity') show_list = [] for program in program_list: show_list.append( { 'name': program.name, 'sequence': program.sequence, 'actors': program.actors } ) return {'view': 40, 'list': show_list}
def get(self): nid = self.request.GET.get('nid') programe = Programe.selectById(nid) num = str(int(programe.sequence) + 1) programe2 = Programe.objects.filter(activity=Activity.selectById( self.request.COOKIES['activityId']), sequence=num) if len(programe2) == 0: return {'view': 21} programe3 = programe2[0] if programe3: programe.updatePrograme(programe.id, programe.name, programe.description, programe.actors, programe3.sequence) programe.updatePrograme(programe3.id, programe3.name, programe3.description, programe3.actors, programe.sequence) return {'view': 21}
def post(self): if not self.request.user.is_authenticated(): raise ValidateError("Please Login First!") if 'create' in self.request.POST: self.check_input('name', 'description', 'actors') sequence = str(int(self.request.COOKIES['ProgrameNum']) + 1) Programe.insertPrograme( Activity.selectById(self.request.COOKIES['activityId']), self.input['name'], self.input['description'], sequence, self.input['actors']) '''if not Activity.objects.filter(self.input['name']): raise LogicError('fail creat pragram') else: return {'view': 6}''' return {'view': 6} if 'return' in self.request.POST: return {'view': 6}
def get(self): if not self.request.user.is_authenticated(): raise ValidateError("Please login!") #self.check_input('activityId') #lottery_list = Lottery.objects.filter(activity__id=self.input['activityId']) lottery_list = Lottery.selectByActivity( Activity.selectById(self.request.COOKIES['activityId'])) #if not lottery_list: #raise InputError('no such activity') list = [] for lottery in lottery_list: list.append({ 'name': lottery.name, 'status': lottery.status, 'id': lottery.id }) ##return list #return render(APIView, 'a/lottery.html', {'list': list}) return {'view': 19, 'list': list}
def get(self): activity = self.request.COOKIES['activityId'] result = Activity.selectById(activity) r = result.bg_pic_url.name[2:] return {'view': 30, 'r': r}
def post(self): if 'activity' in self.request.POST: return {'view': 6} if 'barrage' in self.request.POST: return {'view': 9} if 'lottery' in self.request.POST: return {'view': 10} if 'logout' in self.request.POST: return {'view': 8} if 'return' in self.request.POST: return {'view': 27} if 'commentLinenumber' in self.request.POST: self.check_input('commentLinenumber') #self.request.COOKIES['commentLinenumber'] = self.input['ActivityID'] #return self.input['commentLinenumber'] show_list2 = [] comment_list = Picture.objects.filter(activity=Activity.selectById( self.request.COOKIES['activityId']), status=1) #comment_list = Comment.objects.filter(time__lt=timezone.now().time.second).filter(id__gt=self.input['commentId']) for comment in comment_list: show_list2.append({ 'id': comment.id, 'picUrl': comment.pic_url }) show_list = [] pic_list = Comment.objects.filter(activity=Activity.selectById( self.request.COOKIES['activityId']), status=1) #pic_list = Comment.objects.filter(time__lt=timezone.now().time.second ).filter(id__gt=self.input['pictureId']) for pic in pic_list: show_list.append({ 'id': pic.id, 'content': pic.content, 'color': pic.color, 'bolt': pic.bolt, 'incline': pic.incline, 'underline': pic.underline }) #return render(APIView, 'a/barrage.html', {'commentLinenumber': "", 'list': show_list, 'list2': show_list2}) return { 'view': 24, 'commentLinenumber': self.input['ActivityID'], 'list': show_list2, 'list2': show_list } if 'settop' in self.request.POST: self.check_input('content', 'color', 'bolt', 'incline', 'underline') Comment.objects.filter(status=3).delete() Comment.insertComment( Activity.selectById(self.request.COOKIES['activityId']), self.request.user, self.input['content'], self.input['color'], self.input['bolt'], self.input['underline'], self.input['incline'], timezone.now(), 3) show_list2 = [] comment_list = Picture.objects.filter(activity=Activity.selectById( self.request.COOKIES['activityId']), status=1) #comment_list = Comment.objects.filter(time__lt=timezone.now().time.second).filter(id__gt=self.input['commentId']) for comment in comment_list: show_list2.append({ 'id': comment.id, 'picUrl': comment.pic_url }) show_list = [] pic_list = Comment.objects.filter(activity=Activity.selectById( self.request.COOKIES['activityId']), status=1) #pic_list = Comment.objects.filter(time__lt=timezone.now().time.second ).filter(id__gt=self.input['pictureId']) for pic in pic_list: show_list.append({ 'id': pic.id, 'content': pic.content, 'color': pic.color, 'bolt': pic.bolt, 'incline': pic.incline, 'underline': pic.underline }) #return render(APIView, 'a/barrage.html', {'commentLinenumber': "", 'list': show_list, 'list2': show_list2}) return { 'view': 24, 'commentLinenumber': self.request.COOKIES['commentLinenumber'], 'list': show_list2, 'list2': show_list }
def post(self): nid = self.request.GET.get('nid') if not self.request.user.is_authenticated(): raise ValidateError("Please login!") if 'edit' in self.request.POST: activity = Activity.selectById(nid) old_activity = activity if activity: if self.input['picUrl'] == "": picUrl = activity.pic_url else: picUrl = self.input['picUrl'][0] if self.input['bgPicUrl'] == "": bgPicUrl = activity.bg_pic_url else: bgPicUrl = self.input['bgPicUrl'][0] Activity.updateActivity(nid, self.request.user, self.input['description'], picUrl, self.input['startTime'], self.input['endTime'], bgPicUrl, activity.status, self.input['place'], self.input['name']) else: raise ValidateError('no such activity') # return 0 return {'view': 27} if 'return' in self.request.POST: return {'view': 27} if 'begin' in self.request.POST: Activity.updateActivity( nid, self.request.user, self.input['description'], self.input['picUrl'], self.input['startTime'], self.input['endTime'], self.input['bgPicUrl'], 1, self.input['place'], self.input['name']) activity = Activity.selectById(nid) if activity: data = { 'name': activity.name, 'description': activity.description, 'startTime': activity.start_time.timestamp(), 'endTime': activity.end_time.timestamp(), 'place': activity.place, 'picUrl': activity.pic_url, 'bgPicUrl': activity.bg_pic_url, 'organizer': activity.organizer, 'status': activity.status } return { 'view': 13, 'name': activity.name, 'description': activity.description, 'startTime': activity.start_time, 'endTime': activity.end_time, 'place': activity.place, 'picUrl': activity.pic_url, 'bgPicUrl': activity.bg_pic_url, 'organizer': activity.organizer, 'status': activity.status, 'acitivityid': nid } #return {'view': 18} if 'end' in self.request.POST: Activity.updateActivity( nid, self.request.user, self.input['description'], self.input['picUrl'], self.input['startTime'], self.input['endTime'], self.input['bgPicUrl'], 2, self.input['place'], self.input['name']) activity = Activity.selectById(nid) if activity: data = { 'name': activity.name, 'description': activity.description, 'startTime': activity.start_time.timestamp(), 'endTime': activity.end_time.timestamp(), 'place': activity.place, 'picUrl': activity.pic_url, 'bgPicUrl': activity.bg_pic_url, 'organizer': activity.organizer, 'status': activity.status } return { 'view': 13, 'name': activity.name, 'description': activity.description, 'startTime': activity.start_time, 'endTime': activity.end_time, 'place': activity.place, 'picUrl': activity.pic_url, 'bgPicUrl': activity.bg_pic_url, 'organizer': activity.organizer, 'status': activity.status, 'acitivityid': nid } #return {'view': 18} if 'detail' in self.request.POST: nid = self.get().get('nid') Activity.objects.filter(activityId=nid) return {'view': 25}
def post(self): self.check_input('openId') Picture.insertComment(Activity.selectById(self.input['activityId']), self.input['openId'], self.input['picUrl'], timezone.now(), Barrage.OK) return []