def ticket(request): step = 2 if request.FILES.getlist('attachment') else 1 files = [] if request.POST.get('debug') == 'on': debug = True with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 mntpt, direc, dump = debug_get_settings() debug_run(direc) files.append(File(open(dump, 'rb'), name=os.path.basename(dump))) else: debug = False with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 data = { 'title': request.POST.get('subject'), 'body': request.POST.get('desc'), 'version': get_sw_version().split('-', 1)[-1], 'category': request.POST.get('category'), 'debug': debug, } if get_sw_name().lower() == 'freenas': data.update({ 'user': request.POST.get('username'), 'password': request.POST.get('password'), 'type': request.POST.get('type'), }) else: serial = subprocess.Popen( ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'], stdout=subprocess.PIPE ).communicate()[0].split('\n')[0].upper() license, reason = utils.get_license() if license: company = license.customer_name else: company = 'Unknown' data.update({ 'phone': request.POST.get('phone'), 'name': request.POST.get('name'), 'company': company, 'email': request.POST.get('email'), 'criticality': request.POST.get('criticality'), 'environment': request.POST.get('environment'), 'serial': serial, }) success, msg, tid = utils.new_ticket(data) with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 data = {'message': msg, 'error': not success} if not success: pass else: files.extend(request.FILES.getlist('attachment')) for f in files: success, attachmsg = utils.ticket_attach({ 'user': request.POST.get('username'), 'password': request.POST.get('password'), 'ticketnum': tid, }, f) data = ( '<html><body><textarea>%s</textarea></boby></html>' % ( json.dumps(data), ) ) return HttpResponse(data)
def debug(self, job): # FIXME: move the implementation from freenasUI mntpt, direc, dump = debug_get_settings() debug_run(direc) return dump
def ticket(request): step = 2 if request.FILES.getlist('attachment') else 1 files = [] if request.POST.get('debug') == 'on': debug = True with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 mntpt, direc, dump = debug_get_settings() debug_run(direc) files.append(File(open(dump, 'rb'), name=os.path.basename(dump))) else: debug = False with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 data = { 'title': request.POST.get('subject'), 'body': request.POST.get('desc'), 'version': get_sw_version().split('-', 1)[-1], 'category': request.POST.get('category'), 'debug': debug, } if get_sw_name().lower() == 'freenas': data.update({ 'user': request.POST.get('username'), 'password': request.POST.get('password'), 'type': request.POST.get('type'), }) else: serial = subprocess.Popen( ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'], stdout=subprocess.PIPE).communicate()[0].split('\n')[0].upper() license, reason = utils.get_license() if license: company = license.customer_name else: company = 'Unknown' data.update({ 'phone': request.POST.get('phone'), 'name': request.POST.get('name'), 'company': company, 'email': request.POST.get('email'), 'criticality': request.POST.get('criticality'), 'environment': request.POST.get('environment'), 'serial': serial, }) success, msg, tid = utils.new_ticket(data) with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 data = {'message': msg, 'error': not success} if not success: pass else: files.extend(request.FILES.getlist('attachment')) for f in files: success, attachmsg = utils.ticket_attach( { 'user': request.POST.get('username'), 'password': request.POST.get('password'), 'ticketnum': tid, }, f) data = ('<html><body><textarea>%s</textarea></boby></html>' % (json.dumps(data), )) return HttpResponse(data)
def ticket(request): step = 2 if request.FILES.getlist("attachment") else 1 files = [] if request.POST.get("debug") == "on": debug = True with open(TICKET_PROGRESS, "w") as f: f.write(json.dumps({"indeterminate": True, "step": step})) step += 1 mntpt, direc, dump = debug_get_settings() debug_run(direc) files.append(File(open(dump, "rb"), name=os.path.basename(dump))) else: debug = False with open(TICKET_PROGRESS, "w") as f: f.write(json.dumps({"indeterminate": True, "step": step})) step += 1 data = { "title": request.POST.get("subject"), "body": request.POST.get("desc"), "version": get_sw_version().split("-", 1)[-1], "category": request.POST.get("category"), "debug": debug, } if get_sw_name().lower() == "freenas": data.update( { "user": request.POST.get("username"), "password": request.POST.get("password"), "type": request.POST.get("type"), } ) else: serial = ( subprocess.Popen(["/usr/local/sbin/dmidecode", "-s", "system-serial-number"], stdout=subprocess.PIPE) .communicate()[0] .split("\n")[0] .upper() ) license, reason = utils.get_license() if license: company = license.customer_name else: company = "Unknown" data.update( { "phone": request.POST.get("phone"), "name": request.POST.get("name"), "company": company, "email": request.POST.get("email"), "criticality": request.POST.get("criticality"), "environment": request.POST.get("environment"), "serial": serial, } ) success, msg, tid = utils.new_ticket(data) with open(TICKET_PROGRESS, "w") as f: f.write(json.dumps({"indeterminate": True, "step": step})) step += 1 data = {"message": msg, "error": not success} if not success: pass else: files.extend(request.FILES.getlist("attachment")) for f in files: success, attachmsg = utils.ticket_attach( {"user": request.POST.get("username"), "password": request.POST.get("password"), "ticketnum": tid}, f ) data = "<html><body><textarea>%s</textarea></boby></html>" % (json.dumps(data),) return HttpResponse(data)
def ticket(request): if request.method == 'POST': step = 2 if request.FILES.getlist('attachment') else 1 files = [] if request.POST.get('debug') == 'on': with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 mntpt, direc, dump = debug_get_settings() debug_run(direc) files.append(File(open(dump, 'rb'), name=os.path.basename(dump))) with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 success, msg, tid = utils.new_ticket({ 'user': request.POST.get('username'), 'password': request.POST.get('password'), 'type': request.POST.get('type'), 'title': request.POST.get('subject'), 'body': request.POST.get('desc'), 'version': get_sw_login_version(), }) with open(TICKET_PROGRESS, 'w') as f: f.write(json.dumps({'indeterminate': True, 'step': step})) step += 1 if not success: response = render(request, 'support/ticket.html', { 'error_message': msg, 'initial': json.dumps(request.POST.dict()), }) else: files.extend(request.FILES.getlist('attachment')) for f in files: success, attachmsg = utils.ticket_attach( { 'user': request.POST.get('username'), 'password': request.POST.get('password'), 'ticketnum': tid, }, f) response = render(request, 'support/ticket_response.html', { 'success': success, 'message': msg, }) if not request.is_ajax(): response.content = ( '<html><body><textarea>%s</textarea></boby></html>' % (response.content, )) return response return render(request, 'support/ticket.html')