예제 #1
0
def GiveAnd(request):
    
    if  request.POST:
        i = request.POST['id']
        ans = request.POST['answer']
        obj = forum.objects.get(id=i)
        obj.answer=ans
        obj.save()
        return rd('/forum')
    if  request.GET:
        i = request.GET['id']
        return render(request,'getanswer.html',{'id':i})
    return rd('/forum')
예제 #2
0
파일: views.py 프로젝트: pinkdawn/xmwq.net
def init(req):
    cats = [['网动鹭岛','最火热的鹭岛网球动态'], ['约球会友','喊上朋友,一起来运动吧!'], ['网坛新闻','网坛大事']]
    i = 0
    for c,d in cats:
        _temp = category(title = c, desc = d, order=i)        
        _temp.save()
        i += 1
    return rd('/')
예제 #3
0
def post(rq):
	print(len(rq.POST))
	if len(rq.POST) != 0:
		if ('u' in rq.POST) and ('p' in rq.POST) and ((rq.POST['u'] != "team9071") or (rq.POST['p'] != '@9071')):
			return rd(rq,"index.html",err)
		elif ('title' in rq.POST) and ('date' in rq.POST) and ('content' in rq.POST):
			num = 0
			plist = []
			nlist = []
			path = False
			for p,d,f in os.walk('.\\upload\\'):
				if not path:
					path = True
					plist = d
			for n in plist:
				nlist.append(int(n))
			nlist.sort()
			nu = (0 if len(nlist) is 0 else nlist[len(nlist)-1])
			num = int(nu) + 1
			if not os.path.exists(os.path.join(bpath,'upload\\'+str(num)+'\\')):
				os.makedirs(os.path.join(bpath,'upload\\'+str(num)+'\\'))
			f = open('.\\upload\\'+str(num)+'\\text.txt','w',encoding="utf8")
			img = None
			ipath = ''
			tpath = '已将文本保存于    .\\upload\\'+str(num)+'\\text.txt'
			if rq.POST['imgb64'] != '':
				#print(rq.POST['imgb64'].split("base64,"))
				img = b.b64decode(rq.POST['imgb64'].split("base64,")[1])
				im = open('.\\upload\\'+str(num)+"\\image."+rq.POST['ext'],"wb")
				ipath = "已将图片保存于    " + '.\\upload\\' + str(num) + "\\image." + rq.POST['ext']
				#print("Image saved as " + '.\\upload\\' + str(num) + "\\image." + rq.POST['ext'])
				im.write(img)
				im.close()
			c = []
			c.append("title:"+rq.POST['title']+'\n')
			c.append("date:"+rq.POST['date']+'\n')
			c.append("content:"+rq.POST['content']+'\n')
			f.writelines(c)
			pm = {
				"ipath":ipath,
				"tpath":tpath,
			}
			return rd(rq,"success.html",pm)
		else:
			return rd(rq,"submit.html")
	return rd(rq,"index.html")
예제 #4
0
def render(request, template_name, context=None, content_type=None, status=None, using=None):
    """Override render function to add information to context for base.html"""

    if context is None:
        context = {}
    context['debug'] = settings.DEBUG
    context['now'] = datetime.now()
    context['app_version'] = settings.APP_VERSION
    context['contact_email'] = settings.CONTACT_EMAIL
    context['contact_dev_github'] = settings.CONTACT_DEV_GITHUB
    context['contact_facebook'] = settings.CONTACT_FACEBOOK

    return rd(request, template_name, context, content_type, status, using)
예제 #5
0
def get_question(request):
    question_list = Q.objects.order_by('-pub_date')
    if request.method == 'POST':
        form = QF(request.POST)
        if form.is_valid():
            currQ = Q(question_text=request.POST['question_text'],
                      pub_date=timer.now())
            currQ.save()
    else:
        form = QF()

    return rd(request, 'polls/index.html', {
        'form': form,
        'question_list': question_list
    })
예제 #6
0
def CreateQuestion(request):
    if request.POST:
        q = request.POST['question']
        forum.objects.create(question = q)
        return rd('/forum')
    return render(request,'askquestion.html')