Пример #1
0
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
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)