Ejemplo n.º 1
0
def createNewMessage(request):
    if request.method == 'POST':
        form = NewMessageForm(request.POST)
        if form.is_valid():
            message_frequency = request.POST['message_frequency']
            message_form = form.save(commit = False)
            
            print message_form.id;
            
            if (message_frequency == "once"):
                # Bug loggin
                message_form.active = False
                receipient_id = request.POST['receipient_name']
                message = request.POST['message_content']                
                sendMessageNow(message, receipient_id)
            else:
            
                message_form.active = True  # making the message active should change later
            
            message_form.save()            
            return HttpResponseRedirect("/hospitalUser/")
    else:
        form = NewMessageForm()
    
    return render_to_response('hospitalUser/createNewMessage.html',{'newMessageForm': form})
Ejemplo n.º 2
0
def createNewMessage(request):
    if request.method == 'POST':
        form = NewMessageForm(request.POST)
        if form.is_valid():
            message_frequency = request.POST['message_frequency']
            message_form = form.save(commit = False)
            
            if (message_frequency == "once"):
                message_form.active = False
                sendMessage()
                request.POST['active']
            elif (message_frequency == "specify"):
                message_form.active = True
            else:
                #Message would start sending the following day and frequency would be added there of
                message_form.active = True
                message_form.start_at_date = message_form.start_at_date + datetime.timedelta(days=1)
                       
            message_form.save()
            return HttpResponseRedirect("/project/")
    else:
        form = NewMessageForm()
    
    return render_to_response('createNewMessage.html',{'newMessageForm': form})