Example #1
0
def add(request):

    if request.method == 'POST':
        type_id = int(request.POST['type_id'])
        ticket = Ticket()
        ticket.type_id = type_id
        ticket.detail = json.dumps(make_detail(request, type_id))
        ticket.create_time = datetime.datetime.now()
        ticket.save()
        return redirect('/ticket/')

    return render(request, 'ticket/add.html', {'ticket_types': Ticket.TYPES})
Example #2
0
def application(request):
    if request.method=='POST':
    
        if request.POST['Submit']=='add1':
    
            ticket = Ticket()
            ticket.type_id = '备机申请'
            ticket.hostname_id = request.POST['host']
            ticket.ip_list = request.POST['ip_list']
            ticket.idc_id = request.POST['idc']
            ticket.disk = request.POST['disk']
            ticket.memory = request.POST['mem']
            ticket.os = request.POST['os']
            ticket.comment = request.POST['use']
            ticket.Expectation_time = request.POST['date']
            ticket.raid_id = request.POST['raid']
            ticket.create_time= datetime.datetime.now()
            ticket.user_id = request.session['user'].id
            ticket.detail = request.POST['textarea']
            ticket.ticket_status_id = '1'
            ticket.save()
            return redirect('/index/application')
    
        if request.POST['Submit']=='add2':

            ticket = Ticket()
            ticket.type_id = '服务器报修'
            ticket.ticket_status_id = '1'
            ticket.hostname_id = request.POST['host'] 
            ticket.ip_list = request.POST['ip']
            ticket.idc_id = request.POST['idc']
            ticket.rack_id = request.POST['location1']
            ticket.sn_id = request.POST['sn']
            ticket.variety = request.POST['variety']
            ticket.Expectation_time = request.POST['date']
            ticket.create_time = datetime.datetime.now()
            ticket.host_status = request.POST['host_status'] 
            ticket.user_id = request.session['user'].id
            ticket.detail = request.POST['textarea']
            ticket.save()
            return redirect('/index/application')
              
        if request.POST['Submit'] == 'add3':
         
            ticket = Ticket()
            ticket.type_id = '服务器更换机房'
            ticket.ticket_status_id = '1'
            ticket.hostname_id = request.POST['host']
            ticket.ip_list = request.POST['ip']
            ticket.idc_id = request.POST['old_idc']
            ticket.owner_id = request.POST['old_owner']
            ticket.new_owner = request.POST['now_owner']
            ticket.new_idc = request.POST['now_idc']
            ticket.Expectation_time = request.POST['date']
            ticket.create_time = datetime.datetime.now()
            ticket.user_id = request.session['user'].id
            ticket.os = request.POST['os']
            ticket.detail = request.POST['textarea']
            ticket.save()
            return redirect('/index/application')


        if request.POST['Submit'] == 'add4':

            ticket = Ticket()
            ticket.type_id = '配件升级'
            ticket.ticket_status_id = '1'
            ticket.hostname_id = request.POST['host']
            ticket.ip_list = request.POST['ip']
            ticket.os = request.POST['os']
            ticket.owner_id = request.POST['owner']
            ticket.resource_lists = request.POST['resource']
            ticket.rack_id = request.POST['location1']
            ticket.idc_id = request.POST['idc']
            ticket.Expectation_time = request.POST['date']
            ticket.create_time = datetime.datetime.now()
            ticket.user_id = request.session['user'].id
            ticket.detail = request.POST['textarea']
            ticket.save()
            return render_to_response('/index/application')

        if request.POST['Submit'] == 'add5':

            ticket = Ticket()
            ticket.type_id = '系统重装'
            ticket.hostname_id = request.POST['host']
            ticket.ip_list = request.POST['ip']
            ticket.idc_id = request.POST['idc']
            ticket.owner_id = request.POST['owner']
            ticket.ip_rac_id = request.POST['ra_ip']
            ticket.raid_id = request.POST['raid']
            ticket.Expectation_time = request.POST['date']
            ticket.create_time = datetime.datetime.now()
            ticket.user_id = request.session['user'].id
            ticket.detail = request.POST['textarea']
            ticket.ticket_status_id = '1'
            ticket.save()
            return redirect('/index/application')

        if request.POST['Submit'] == 'add6':
            
            ticket = Ticket()
            ticket.type_id = '监控更改'
            ticket.hostname_id = request.POST['host']
            ticket.ip_list = request.POST['ip']
            ticket.monitor = request.POST['monitor']
            ticket.owner_id = request.POST['owner']
            ticket.new_oner = request.POST['business']
            ticket.monitor_list = request.POST['list']
            ticket.Expectation_time = request.POST['date']
            ticket.idc_id = request.POST['idc']
            ticket.create_time = datetime.datetime.now()
            ticket.user_id = request.session['user'].id
            ticket.ticket_status_id = '1'
            ticket.detail = request.POST['textarea']
            ticket.save()
            return redirect('/index/application')
    return render_to_response('application.html',{'user' : request.session['user']})