示例#1
0
文件: views.py 项目: jkimuli/noc
def edit_page(request,ticket_id):
    #get existing ticket from database
    
    ticket = get_object_or_404(Ticket,pk=ticket_id)
    
    if request.method == 'POST':
        form = TicketForm(instance = ticket,data=request.POST)
        
        if form.is_valid():
            
            
            ticket = form.save(commit=False)
            
            if request.POST['status'] == '1':
                ticket.close_time = datetime.now()
                
                ticket.save()
                
            
            return HttpResponseRedirect('/')
            
    else:
        form = TicketForm(instance=ticket)
        
    variables = RequestContext(request,{
        'form':form,
        'add':False
    })
    
    return render_to_response('save_ticket.html',variables)
示例#2
0
文件: views.py 项目: jkimuli/noc
def save_page(request):
    if request.method == 'POST':
        form = TicketForm(data=request.POST)
        
        if form.is_valid():
            ticket = form.save(commit=False)

	    
            
            ticket.assigned_by = request.user
            
            ticket.save()
            
            return HttpResponseRedirect('/')
                
                
        
    
    else:
        form = TicketForm()
        
    variables = RequestContext(request,{
        'form' : form,
        'add':True
    })
        
    return render_to_response('save_ticket.html',variables)