def get_lunbo_img(request): count = request.GET.get('count') count = int(count) if count else 3 lists = LunBo.objects.all()[:count] if lists: return parse_info({'list': serializer(lists)}) return parse_info({})
def get_event_score_view(request, event_id): res = [] try: event = Events.objects.get(id=event_id) queryset = event.authority_set.all().order_by('single') except Exception as e: raise Http404("event_id:{} 错误".format(event_id)) type = request.GET.get('type') kwargs = {} if type: kwargs['eventType_id'] = type queryset = queryset.filter(**kwargs) for i in queryset: res.append({ 'user_info': serializer(i.username, exclude_attr=('password', 'is_email_check', 'reg_date')), 'event_info': serializer(i.events, datetime_format='string'), 'score': { 'eventType': i.eventType.type, 'single': i.single, 'turn': i.turn, 'recent': i.recent, 'award': i.award } }) return parse_info(res, safe=False)
def get_event_filter_view(request): res = dict() all_province = EventProvince.objects.all() all_type = EventType.objects.filter(event_type=request.GET.get('etype', 0)) res['all_year'] = [ str(i) for i in reversed(range(2010, datetime.now().year + 1)) if Events.objects.filter(event_date__year=i).exists() ] res['all_province'] = serializer(all_province) res['all_type'] = serializer(all_type) return parse_info(res)
def post(self, request, body=None, *args, **kwargs): if not self.wrap_check_token_result(): return self.render_to_response({'msg': self.message}) if ApplyUser.objects.filter(apply_user=self.user).exists(): return parse_info({'msg': '已报名'}) for i in request.POST.keys(): kwargs[i] = request.POST[i] apply_types = (kwargs['types'].split(',')) apply_ = ApplyUser.create(user=self.user, apply_types=apply_types, **kwargs) if apply_: return self.render_to_response( serializer(apply_, exclude_attr=('password', 'id', 'reg_date'), datetime_format='string')) return self.render_to_response({'msg': '赛事或者类型id错误'})
def get_event_type_view(request, event_id): res = dict() try: event = Events.objects.get(id=event_id) queryset = EventTypeDetail.objects.filter(event=event) except Exception as e: raise Http404("event_id:{} 错误".format(event_id)) all_type = [] for i in queryset: all_type.append({ 'id': i.id, 'type_name': i.type.type, 'type_lines': i.lines, 'type_price': i.price }) res['type'] = all_type res['can_apply_count'] = int(event.eventsdetail.apply_count) - len( event.applyuser_set.filter(is_check=1)) res['base_price'] = event.eventsdetail.base_price return parse_info(res)
def get_event_apply_user_view(request, event_id): res = dict() try: event = Events.objects.get(id=event_id) queryset = event.applyuser_set.filter(is_check=0) except Exception as e: raise Http404("event_id:{} 错误".format(event_id)) apply_list = [] for i in queryset: apply_list.append({ 'user_obj': { 'id': i.apply_user.id, 'username': i.apply_user.userprofile.username, 'sex': i.apply_user.userprofile.sex or '', }, 'apply_types': [i.apply_type.type.type for i in i.applyusertypes_set.all()], 'apply_time': i.create_time }) res['list'] = apply_list return parse_info(res, safe=True)
def get(self, request, *args, **kwargs): """ Handles GET requests and instantiates a blank version of the form. """ return parse_info({'msg': 'token'})
def get_project_view(request): return parse_info({'info': serializer(Project.objects.all()[:1])})
def get_ssz_view(request): return parse_info({'info': serializer(SSZModel.objects.all()[:1])})
def get_join_our(request): info = JoinOur.objects.all()[:1] if info: return parse_info({'info': info[0].info}) return parse_info({})