def create_message(request): if request.method == 'POST': form = MemoMessageForm(request.POST) if form.is_valid(): msg = form.save(commit=False) msg.content_timestamp = datetime.now() msg.save() return HttpResponseRedirect(reverse('memo_message_list_all')) else: return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request)) else: form = MemoMessageForm() return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request))
def create_message(request): if request.method == 'POST': form = MemoMessageForm(request.POST) if form.is_valid(): msg = form.save(commit=False) msg.content_timestamp = datetime.now() msg.save() return HttpResponseRedirect(reverse('memo_message_list_all')) else: return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request)) else: form = MemoMessageForm() return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request))
def create_message(request): if request.method == 'POST': form = MemoMessageForm(request.POST) if form.is_valid(): msg = form.save(commit=False) # Set time manually this way in case we switch back to a versioned message # model in the future msg.content_timestamp = datetime.now() msg.save() return HttpResponseRedirect(reverse('memo_message_list_all')) else: return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request)) else: form = MemoMessageForm() return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request))
def create_message(request): if request.method == 'POST': form = MemoMessageForm(request.POST) if form.is_valid(): msg = form.save(commit=False) # Set time manually this way in case we switch back to a versioned message # model in the future msg.content_timestamp = datetime.now() msg.save() return HttpResponseRedirect(reverse('memo_message_list_all')) else: return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request)) else: form = MemoMessageForm() return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request))
def create_message(request): if request.method == 'POST': form = MemoMessageForm(request.POST) if form.is_valid(): msg = form.save(commit=False) # Since revisions are now saved to db, this timestamp # can't just be auto set since we want to preserve from creation time msg.content_timestamp = datetime.now() msg.save() return HttpResponseRedirect(reverse('memo_message_list_all')) else: return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request)) else: form = MemoMessageForm() return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request))
def create_message(request): if request.method == 'POST': form = MemoMessageForm(request.POST) if form.is_valid(): msg = form.save(commit=False) # Since revisions are now saved to db, this timestamp # can't just be auto set since we want to preserve from creation time msg.content_timestamp = datetime.now() msg.save() return HttpResponseRedirect(reverse('memo_message_list_all')) else: return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request)) else: form = MemoMessageForm() return render_to_response('geocamMemo/message_form.html', dict(form=form), context_instance=RequestContext(request))
def edit_message(request, message_id): message = MemoMessage.objects.get(pk=message_id) if message.author.username != request.user.username and not request.user.is_superuser: return HttpResponseRedirect( reverse('memo_message_list_all')) # you get the boot! if request.method == 'POST': message.content = request.POST['content'] form = MemoMessageForm(request.POST) if form.is_valid(): message.save() return HttpResponseRedirect(reverse('memo_message_list_all')) else: return render_to_response('geocamMemo/edit_message_form.html', dict(form=form, message=message), context_instance=RequestContext(request)) else: form = MemoMessageForm(instance=message) return render_to_response('geocamMemo/edit_message_form.html', dict(form=form, message=message), context_instance=RequestContext(request))
def edit_message(request, message_id): message = MemoMessage.objects.get(pk=message_id) if message.author.username != request.user.username and not request.user.is_superuser: return HttpResponseRedirect(reverse('memo_message_list_all')) # you get the boot! if request.method == 'POST': message.content = request.POST['content'] form = MemoMessageForm(request.POST) if form.is_valid(): message.save() return HttpResponseRedirect(reverse('memo_message_list_all')) else: return render_to_response('geocamMemo/edit_message_form.html', dict(form=form, message=message), context_instance=RequestContext(request)) else: form = MemoMessageForm(instance=message) return render_to_response('geocamMemo/edit_message_form.html', dict(form=form, message=message), context_instance=RequestContext(request))\