Exemple #1
0
def _occurrence_chat(request,
                     object_id,
                     scheduleoccurrence_id,
                     template_name="messages/messages_chat.html"):
    client_id = object_id
    object = get_object_or_404(
        Client,
        pk=object_id,
        person__organization=request.user.get_profile().org_active)
    scheduleoccurrence = ScheduleOccurrence.objects.get(
        pk=scheduleoccurrence_id)

    if scheduleoccurrence.messagetopic_set.count() == 0:
        messagetopic = MessageTopic()
        messagetopic.subject = "Chat - "
        messagetopic.referral = scheduleoccurrence.event.referral
        messagetopic.event = scheduleoccurrence
        messagetopic.save()
    else:
        messagetopic = scheduleoccurrence.messagetopic_set.all()[0]

    messagetopic.online_users.add(request.user)

    return render_to_response(template_name, {
        'messagetopic': messagetopic,
        'scheduleoccurrence_id': scheduleoccurrence_id,
        'client_id': client_id,
        'object': object,
        'referral': scheduleoccurrence.event.referral,
    },
                              context_instance=RequestContext(request))
def _occurrence_chat(request, object_id, scheduleoccurrence_id, template_name="messages/messages_chat.html"):
    client_id = object_id
    object = get_object_or_404(
        Client, pk=object_id, person__organization=request.user.get_profile().org_active)
    scheduleoccurrence = ScheduleOccurrence.objects.get(
        pk=scheduleoccurrence_id)

    if scheduleoccurrence.messagetopic_set.count() == 0:
        messagetopic = MessageTopic()
        messagetopic.subject = "Chat - "
        messagetopic.referral = scheduleoccurrence.event.referral
        messagetopic.event = scheduleoccurrence
        messagetopic.save()
    else:
        messagetopic = scheduleoccurrence.messagetopic_set.all()[0]

    messagetopic.online_users.add(request.user)

    return render_to_response(template_name, {
        'messagetopic': messagetopic,
        'scheduleoccurrence_id': scheduleoccurrence_id,
        'client_id': client_id,
        'object': object,
        'referral': scheduleoccurrence.event.referral,
    }, context_instance=RequestContext(request))