Пример #1
0
def _new_topic_message(request, referral_id, topic_id, object_id, redirect_to=None):

    client_id = object_id
    object = get_object_or_404(
        Client, pk=object_id, person__organization=request.user.get_profile().org_active)
    referral = Referral.objects.get(
        pk=referral_id, service__organization=request.user.get_profile().org_active)

    if not _access_check_referral_write(request, referral):
        return render_to_response('403.html', {'object': _("Oops! You don't have access for this service!"), }, context_instance=RequestContext(request))

    messagetopic = MessageTopic.objects.get(pk=topic_id)
    if request.POST.get('message'):
        from datetime import datetime
        message = Message()
        message.sender = request.user
        message.sent_at = datetime.now
        message.body = request.POST['message']
        message.topic = messagetopic
        message.save()

        from django.shortcuts import redirect
        return redirect(redirect_to or "/client/%s/referral/%s/messages/topic/%s" % (client_id, referral_id, topic_id))
    else:
        return HttpResponseRedirect(redirect_to or '/client/%s/referral/%s/messages/topic/%s' % (object.id, referral.id, topic_id))
Пример #2
0
def _chat_message(request, object_id, messagetopic_id):
    """
    This method is used to allow a user to chat. It is requested using AJAX
    and is used to insert a new message in the current topic.
    """
    messagetopic = MessageTopic.objects.get(pk=messagetopic_id)
    message = Message()
    message.sender = request.user

    message.body = request.POST['messagebody']
    message.topic = messagetopic
    message.save()

    from django.http import HttpResponse
    return HttpResponse("ok")
Пример #3
0
def _chat_message(request, object_id, messagetopic_id):
    """
    This method is used to allow a user to chat. It is requested using AJAX
    and is used to insert a new message in the current topic.
    """
    messagetopic = MessageTopic.objects.get(pk=messagetopic_id)
    message = Message()
    message.sender = request.user

    message.body = request.POST['messagebody']
    message.topic = messagetopic
    message.save()

    from django.http import HttpResponse
    return HttpResponse("ok")
Пример #4
0
def _new_topic_message(request,
                       referral_id,
                       topic_id,
                       object_id,
                       redirect_to=None):

    client_id = object_id
    object = get_object_or_404(
        Client,
        pk=object_id,
        person__organization=request.user.get_profile().org_active)
    referral = Referral.objects.get(
        pk=referral_id,
        service__organization=request.user.get_profile().org_active)

    if not _access_check_referral_write(request, referral):
        return render_to_response(
            '403.html', {
                'object': _("Oops! You don't have access for this service!"),
            },
            context_instance=RequestContext(request))

    messagetopic = MessageTopic.objects.get(pk=topic_id)
    if request.POST.get('message'):
        from datetime import datetime
        message = Message()
        message.sender = request.user
        message.sent_at = datetime.now
        message.body = request.POST['message']
        message.topic = messagetopic
        message.save()

        from django.shortcuts import redirect
        return redirect(redirect_to
                        or "/client/%s/referral/%s/messages/topic/%s" %
                        (client_id, referral_id, topic_id))
    else:
        return HttpResponseRedirect(
            redirect_to or '/client/%s/referral/%s/messages/topic/%s' %
            (object.id, referral.id, topic_id))