def post_msg(request): form = NewPostForm(request.POST) if form.is_valid(): data = form.cleaned_data thread = get_object_or_404(Thread, pk=data["thread"]) reference = get_object_or_404(Message, pk=data["reference"]) msg = Message.objects.create(owner=request.user, thread=thread, text=data["message"], reference=reference) thread.msgs.add(msg) return HttpResponse("ok") return HttpResponse("Error: Invalid form")
def post_msg(request): form = NewPostForm(request.POST) if form.is_valid(): data = form.cleaned_data thread = get_object_or_404(Thread, pk=data['thread']) reference = get_object_or_404(Message, pk=data['reference']) msg = Message.objects.create(owner=request.user, thread=thread, text=escape(data['message']), reference=reference) thread.msgs.add(msg) ReplyEvent.throw(user=request.user, context=thread.referc, thread=thread) return HttpResponse("ok " + str(msg.id)) return HttpResponse("Error: Invalid form")
def post_msg(request): form = NewPostForm(request.POST) if form.is_valid(): data = form.cleaned_data thread = get_object_or_404(Thread, pk=data['thread']) reference = get_object_or_404(Message, pk=data['reference']) msg = Message.objects.create(owner=request.user, thread=thread, text=escape(data['message']), reference=reference) thread.msgs.add(msg) ReplyEvent.throw(user=request.user, context=thread.referc, thread=thread) Permission.objects.create(name="message_edit", user=request.user, object_id=msg.id) return HttpResponse("ok " + str(msg.id)) return HttpResponse("Error: Invalid form")
'set': Category.objects.filter(name='Project 402')[0], 'template': 'boards.tpl', 'extra_context': { 'tform': NewThreadForm() } }, name="general_boards"), url(r'^list/(?P<courseid>[^/]+)/(?P<docid>[^/]+)/(?P<pageid>[^/]+)$', login_required(list_thread), name="thread_list"), url(r'^view_thread/(?P<object_id>[^/]+)$', AR(login_required(object_detail)), { 'queryset': Thread.objects.all(), 'template_name': 'thread_view.tpl', 'extra_context': { 'mform': NewPostForm(), 'eform': EditPostForm() } }, name="thread_view"), url(r'^post_thread$', enforce_post(login_required(post_thread)), name="thread_post"), url(r'^post_msg$', enforce_post(login_required(post_msg)), name="message_post"), url(r'^edit$', enforce_post(chk_perm(login_required(edit_msg), 'message_edit')), name="message_edit"), url(r'^remove$', enforce_post(chk_perm(login_required(remove_msg), 'message_remove')),