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 new_message_topic(request, referral_id, object_id, template_name="messages/messages_referral.html"): client_id = object_id referral = Referral.objects.get(pk=referral_id, service__organization=request.user.get_profile().org_active) object = get_object_or_404(Client, pk=object_id, person__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)) if not request.POST: return render_to_response('messages/messages_newtopic.html', locals(), context_instance=RequestContext(request)) else: messagetopic = MessageTopic() messagetopic.referral = referral messagetopic.subject = request.POST['topic'] if request.POST.get('topic'): messagetopic.save() messages.success(request, _('Message topic created successfully')) return HttpResponseRedirect('/client/%s/referral/%s/messages/topic/%s' % (client_id, referral.id, messagetopic.id)) else: return HttpResponseRedirect('/client/%s/referral/%s/messages/' % (object.id, referral.id))
def new_message_topic(request, referral_id, object_id, template_name="messages/messages_referral.html"): client_id = object_id referral = Referral.objects.get( pk=referral_id, service__organization=request.user.get_profile().org_active) object = get_object_or_404( Client, pk=object_id, person__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)) if not request.POST: return render_to_response('messages/messages_newtopic.html', locals(), context_instance=RequestContext(request)) else: messagetopic = MessageTopic() messagetopic.referral = referral messagetopic.subject = request.POST['topic'] if request.POST.get('topic'): messagetopic.save() messages.success(request, _('Message topic created successfully')) return HttpResponseRedirect( '/client/%s/referral/%s/messages/topic/%s' % (client_id, referral.id, messagetopic.id)) else: return HttpResponseRedirect('/client/%s/referral/%s/messages/' % (object.id, referral.id))