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 post(self): self.check_input('openId') Picture.insertComment(Activity.selectById(self.input['activityId']), self.input['openId'], self.input['picUrl'], timezone.now(), Barrage.OK) return []
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 get(self): if not self.request.user.is_authenticated(): raise ValidateError("Please login!") nid = self.request.GET.get('nid') Activity.deleteActivity(nid) return {'view': 27}
def get(self): activity = self.request.COOKIES['activityId'] result = Activity.selectById(activity) r = result.bg_pic_url.name[2:] return {'view': 30, 'r': r}