Ejemplo n.º 1
0
 def post(self,request):
     
     form = Register_Form(request.POST)
     if not form.is_valid():
         return render(request,"dreamer/form.html",{"form":form,"post_url":reverse("dreamer:add"),"title":u"添加报名者资料"})
     register = form.save()
     return HttpResponseRedirect(reverse("dreamer:detail")+"?id="+str(register.id))
Ejemplo n.º 2
0
    def post(self, request):
        msg = Register()
        tmp = Register_Form(request.POST)
        if request.META.has_key('HTTP_X_FORWARDED_FOR'):  
            msg.ip = request.META['HTTP_X_FORWARDED_FOR']
        else:
            msg.ip = request.META['REMOTE_ADDR'] 
        msg.status = True
        now = datetime.date.today()
        if tmp.is_valid():
            msg.name = tmp.cleaned_data['name']
            msg.gender = tmp.cleaned_data['gender']
            msg.stu_ID = tmp.cleaned_data['stu_ID']
            msg.college = tmp.cleaned_data['college']
            msg.mobile = tmp.cleaned_data['mobile']
            msg.dept1 = tmp.cleaned_data['dept1']
            msg.dept2 = tmp.cleaned_data['dept2']
            msg.self_intro = tmp.cleaned_data['self_intro']
            same_SID = Register.objects.filter(stu_ID = msg.stu_ID, status=True).count()
            if same_SID > 0:
                print "1"
                return render(request, 'dreamer/failed.html')
            else:
                if Register.objects.filter(sign_up_date=now).filter(ip=msg.ip).count()>=50:  
                    tip="您当前IP已于同一天成功报名五十次,请等候第二天或换另一台电脑再进行报名"	
                    return render(request, 'dreamer/failed.html',{'tip':tip})
                else:
                    msg.save()
                    return render(request, 'dreamer/succeed.html', {'form': msg})
        else:

            return render(request, 'dreamer/failed.html')
Ejemplo n.º 3
0
 def post(self,request):
     id=request.GET.get("id")
     register = get_object_or_404(Register,pk=id)
     form = Register_Form(request.POST,instance=register)
     if not form.is_valid():
         return render(request,"dreamer/form.html",{"form":form,"post_url":reverse("dreamer:modify")+"?id="+id,"title":u"修改报名者资料"})
     register = form.save()
     return HttpResponseRedirect(reverse("dreamer:detail")+"?id="+str(register.id))
Ejemplo n.º 4
0
	def post(self, request):
		msg = Register()
		tmp = Register_Form(request.POST)
		if request.META.has_key('HTTP_X_FORWARDED_FOR'):  
			msg.ip = request.META['HTTP_X_FORWARDED_FOR']
		else:
			msg.ip = request.META['REMOTE_ADDR'] 
		msg.status = True
		now = datetime.date.today()
		if tmp.is_valid():
			msg.name = tmp.cleaned_data['name']
			msg.gender = tmp.cleaned_data['gender']
			msg.stu_ID = tmp.cleaned_data['stu_ID']
			msg.college = tmp.cleaned_data['college']
			msg.mobile = tmp.cleaned_data['mobile']
			msg.dept1 = tmp.cleaned_data['dept1']
			msg.dept2 = tmp.cleaned_data['dept2']
			msg.self_intro = tmp.cleaned_data['self_intro']
			same_SID = Register.objects.filter(stu_ID = msg.stu_ID, status=True).count()

			if same_SID > 0:
				return render(request, 'dreamer/failed.html')
			else:
				if Register.objects.filter(sign_up_date=now).filter(ip=msg.ip).count()>5:  
					return HttpResponse("您当前IP已于同一天成功报名五次,请等候第二天或换另一台电脑再进行报名.")
				else:
					msg.save()
					reply = msg
					if(reply.gender=='male'):
						reply.gender = '男';
					else:
						reply.gender = '女';

					if(reply.dept1=='jsb'):
						reply.dept1 = '技术部';
					elif(reply.dept1=='sjb'):
						reply.dept1 = '设计部';
					elif(reply.dept1=='cbb'):
						reply.dept1 = '采编部';
					elif(reply.dept1=='xzb'):
						reply.dept1 = '行政部';
					else:
						reply.dept1 = '运营部';

					if(reply.dept2=='jsb'):
						reply.dept2 = '技术部';
					elif(reply.dept2=='sjb'):
						reply.dept2 = '设计部';
					elif(reply.dept2=='cbb'):
						reply.dept2 = '采编部';
					elif(reply.dept1=='xzb'):
						reply.dept1 = '行政部';
					else:
						reply.dept2 = '运营部';
					return render(request, 'succeed.html', {'form': msg})
		else:
			return HttpResponse('failed.html')
Ejemplo n.º 5
0
    def post(self, request):

        form = Register_Form(request.POST)
        if not form.is_valid():
            return render(
                request, "dreamer/form.html", {
                    "form": form,
                    "post_url": reverse("dreamer:add"),
                    "title": u"添加报名者资料"
                })
        register = form.save()
        return HttpResponseRedirect(
            reverse("dreamer:detail") + "?id=" + str(register.id))
Ejemplo n.º 6
0
 def post(self, request):
     id = request.GET.get("id")
     register = get_object_or_404(Register, pk=id)
     form = Register_Form(request.POST, instance=register)
     if not form.is_valid():
         return render(
             request, "dreamer/form.html", {
                 "form": form,
                 "post_url": reverse("dreamer:modify") + "?id=" + id,
                 "title": u"修改报名者资料"
             })
     register = form.save()
     return HttpResponseRedirect(
         reverse("dreamer:detail") + "?id=" + str(register.id))
Ejemplo n.º 7
0
 def post(self, request):
     if Register.objects.filter(stu_ID=request.session['szu_no']).exists():
         messages = u"您已经成功报名过,不能重复报名,如需更改信息,请联系学子天地工作人员"
         return spec_json(status='errors', messages=messages)
     form = Register_Form(request.POST)
     if not form.is_valid():
         messages = form.errors.values()
         return spec_json(status='errors', messages=messages)
     register = form.save(commit=False)
     register.name = request.session['szu_name']
     register.gender = request.session['szu_sex']
     register.college = request.session['szu_org_name']
     register.stu_ID = request.session['szu_no']
     register.grade = request.session['szu_no'][:4]
     register.save()
     return render_json({"status": "success", "name": register.name})
Ejemplo n.º 8
0
 def post(self, request):
     if Register.objects.filter(stu_ID=request.session['szu_no']).exists():
         messages = u"您已经成功报名过,不能重复报名,如需更改信息,请联系学子天地工作人员"
         return spec_json(status='errors', messages=messages)
     form = Register_Form(request.POST)
     if not form.is_valid():
         messages = form.errors.values()
         return spec_json(status='errors', messages=messages)
     register = form.save(commit=False)
     register.name=request.session['szu_name']
     register.gender=transfer_sex(request.session['szu_sex'])
     register.college=request.session['szu_org_name']
     register.stu_ID=request.session['szu_no']
     register.grade=request.session['szu_no'][:4]
     register.save()
     return render_json({"status":"success","name":register.name})