예제 #1
0
def editar_discussao_tema(request, graph, id):
	context = RequestContext(request)
	resolve = connect(request, graph)
	context['acao'] = "Editar discussão"

	discussion = Discussion.discussion.get(id=id)

	if request.method == 'POST':
		form = NewDiscussionTheme(request.POST, instance=discussion)
		if form.is_valid():
			form.save()

			return HttpResponseRedirect(reverse('ver_discussao', args=[discussion.id, discussion.slug]))
	else:
		context['form'] = NewDiscussionTheme(instance=discussion)

		return render_to_response('nova_discussao_tema.html', context)
예제 #2
0
def nova_discussao_tema(request, graph):
	context = RequestContext(request)
	resolve = connect(request, graph)

	author = request.user

	if request.method == 'POST':
		form = NewDiscussionTheme(request.POST)

		if form.is_valid():
			title = form.cleaned_data['title']
			description = form.cleaned_data['description']
			theme = form.cleaned_data['theme']

			discussion = create_theme_discussion(author, title, theme, None, description, True)

			return HttpResponseRedirect(reverse('ver_discussao_tema', args=[discussion.id, discussion.slug]))
	else:
		context['form'] = NewDiscussionTheme()

		return render_to_response('nova_discussao_tema.html', context)