Beispiel #1
0
def update(request,board_id):
	email = request.session['email']
	userid = request.GET['id']
	if email != userid:
		return HttpResponseRedirect(reverse('board:lists'))
	else:	
		boards = Boards.objects.get(board_id=board_id)
		if request.method == 'POST':	
			form = WriteForm(request.POST,instance=boards)
			if form.is_valid():
				form.save()
				return HttpResponseRedirect(reverse('board:view',args=(board_id,)))
			else:
				print form.errors
		else:
			return render(request,'board/update.html',{"bd":boards})
Beispiel #2
0
def write(request):
	if request.method == 'POST':
		form = WriteForm(request.POST)
		if form.is_valid():
			email = request.session['email']
			info = Info.objects.get(email=email)
			nform = form.save(commit=False)
			nform.user_id = email
			nform.user_name = info.last_name
			nform.hits = 0
			nform.save()
			return HttpResponseRedirect(reverse('board:lists'))
		else:
			print form.errors
	else:
		return render(request,'board/write.html')