示例#1
0
文件: views.py 项目: Bouska/proj402
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")
示例#2
0
文件: views.py 项目: haxelion/proj402
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")
示例#3
0
文件: views.py 项目: UrLab/proj402
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")
示例#4
0
文件: urls.py 项目: UrLab/proj402
         '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')),