Example #1
0
def export_inscription_data(request, atype):
	if atype == "sheet":
		return excel.make_response_from_a_table(

			Inscription, "xlsx", file_name="inscriptions"
			)
	elif atype =="custom":
		query_sets = Inscription.objects.all()
		column_names = ["nom", "prenom", "date_inscription", "date_naissance", "lieu_naissance", 
		"niveau", "frequence", "sexe", "nationalite", "telephone", "email", 
		"representant_parent_un", "nom_parent_un", "prenom_parent_un", 
		"date_naissance_parent_un", "lieu_naissance_parent_un", 
		"code_postal_naissance_parent_un", "nationalite_parent_un",
		"adresse_domicile_parent_un", "ville_parent_un", "telephone_domicile_parent_un", 
		"telephone_personnel_parent_un", "telephone_professionnel_parent_un", "email_parent_un",
		"profession_parent_un",

		"representant_parent_deux", "nom_jeune_fille_parent_deux", "nom_marial_parent_deux", "prenom_parent_deux", 
		"date_naissance_parent_deux", "lieu_naissance_parent_deux", "code_postal_naissance_parent_deux", 
		"nationalite_parent_deux", "telephone_domicile_parent_deux", "telephone_personnel_parent_deux",
		 "telephone_professionnel_parent_deux", "email_parent_deux", "profession_parent_deux",
		"adresse_domicile_parent_deux","situation_familiale", "matricule"

	]
		return excel.make_response_from_query_sets(

				query_sets,
				column_names,
				"xlsx",
				file_name="inscriptions"
			)
	else:
		return HttpResponseBadRequest(
			"Bad request. S'il vous plait mettez l'un des choses dans le suffix de votre URL : sheet ou custom "
			)
Example #2
0
def export_data(modeladmin, request, queryset):
    return excel.make_response_from_query_sets(
        queryset,
        modeladmin.list_display,
        'xls',
        file_name="errores"
    )
Example #3
0
def export_technology_data(request):
    file_name = '技术文件表_'
    techs = TechnologyFile.objects.all()

    file_name += datetime.now().strftime("%Y-%m-%d")

    column_names = [
        'id',
        'title',
        'file_type',
        'type_display',
        'profess_id',
        'profess_name',
    ]
    colnames = [
        '编号',
        '标题',
        '文件类型id',
        '类型名称',
        '专业id',
        '专业名称',
    ]
    return excel.make_response_from_query_sets(
        techs,
        column_names,
        'xls',
        file_name=file_name,
        colnames=colnames,
        ignore_rows=[0] if len(techs) else [1])
Example #4
0
 def get(self, request, *args, **kwargs):
     query_sets = Location.objects.all()
     column_names = ['name', 'address', 'latitude', 'longitude']
     return excel.make_response_from_query_sets(query_sets,
                                                column_names,
                                                'xls',
                                                file_name="download")
Example #5
0
def download(request, account_id):
	facebook_account = FacebookAccount.objects.get(account_id=account_id)
	facebook_adSource = adSource.objects.get(name=facebook_account.account_name)
	google = Source.objects.get(name='Google')
	addUp(google, facebook_adSource)
	query_sets = Source.objects.filter()
	column_names = ['name', 'clicks', 'impressions', 'CTR', 'CPC', 'CPM', 'cost']
	return excel.make_response_from_query_sets(query_sets, column_names, 'xls')
Example #6
0
def export_data(request):
    queryset = models.Exceltest.objects.all()
    columns = ['id', 'nom', 'prenom', 'age']
    return excel.make_response_from_query_sets(queryset,
                                               columns,
                                               'xls',
                                               file_name="import_" +
                                               str(datetime.now()) + "")
def export_data(request, atype, queryset, fields):
    if atype == "sheet":
        return excel.make_response_from_a_table(ScoreSheet, 'xls', file_name="sheet")
    elif atype == "book":
        return excel.make_response_from_tables([ScoreSheet], 'xls', file_name="book")
    elif atype == "custom":
        return excel.make_response_from_query_sets(queryset, fields, 'xls', file_name='custom')
    else:
        return HttpResponseBadRequest("bad request, choose one")
Example #8
0
def export_users(request):
    users = Users.objects.all()
    column_names = [
        'dt_add', 'id_user', 'id_invite', 'name', 'phone', 'dt_birth'
    ]
    return excel.make_response_from_query_sets(users,
                                               column_names,
                                               'xls',
                                               file_name="custom")
Example #9
0
def export_data(request, atype):
    if atype == "sheet":
        return excel.make_response_from_a_table(Question, 'xls')
    elif atype == "book":
        return excel.make_response_from_tables([Question, Choice], 'xls')
    elif atype == "custom":
        question = Question.objects.get(slug='ide')
        query_sets = Choice.objects.filter(question=question)
        column_names = ['choice_text', 'id', 'votes']
        return excel.make_response_from_query_sets(query_sets, column_names, 'xls')
Example #10
0
def export_data(request):
    # return excel.make_response_from_a_table(Cliente, 'xls', file_name="clientes")
    query_sets = Cliente.objects.all()
    column_names = ['nit', 'razon_social', 'telefono', 'correo', 'ciudad', 'direccion', 'activo_inactivo']
    return excel.make_response_from_query_sets(
        query_sets,
        column_names,
        'xls',
        file_name="clientes"
    )
def export_data(request):
    data = DwfMeasureData.objects.all()
    column_names = [
        'dataCounter', 'Z', 'R', 'C', 'freq', 'channel', 'time', 'timeMin'
    ]

    return excel.make_response_from_query_sets(data,
                                               column_names,
                                               'xlsx',
                                               file_name="test")
Example #12
0
def export_safety_data(request):
    file_name = '安全文件表_'
    safetys = SafetyFile.objects.all()

    file_name += datetime.now().strftime("%Y-%m-%d")

    column_names = ['id', 'title', 'file_type', 'type_display']
    colnames = ['编号', '标题', '文件类型id', '类型名称']
    return excel.make_response_from_query_sets(safetys, column_names, 'xls', file_name=file_name, colnames=colnames,
        ignore_rows=[0] if len(safetys) else [1])
Example #13
0
def download(request, account_id):
    facebook_account = FacebookAccount.objects.get(account_id=account_id)
    facebook_adSource = adSource.objects.get(
        name=facebook_account.account_name)
    google = Source.objects.get(name='Google')
    addUp(google, facebook_adSource)
    query_sets = Source.objects.filter()
    column_names = [
        'name', 'clicks', 'impressions', 'CTR', 'CPC', 'CPM', 'cost'
    ]
    return excel.make_response_from_query_sets(query_sets, column_names, 'xls')
Example #14
0
def export_data(request):
    user = auth.get_user(request)
    query_sets = Book.objects.filter(user=user)
    column_names = [
        'fullname', 'birthdate', 'address', 'phone', 'email', 'comment'
    ]
    return excel.make_response_from_query_sets(query_sets,
                                               column_names,
                                               'csv',
                                               file_name='adbook_' +
                                               user.username)
Example #15
0
def export_schedule_data(request):
    file_name = '进度表_'
    queryset = Schedule.objects.all()

    file_name += datetime.now().strftime("%Y-%m-%d")

    column_names = ['id', 'job_name', 'profess_id', 'profess_name', 'unit', 'location', 'done_count', 'design_total',
                    'last_week_plan', 'last_week_actual', 'now_week_plan', 'now_week_actual', 'now_week']
    colnames = ['进度编号', '作业名称', '专业id', '专业名称', '单位', '施工地点', '开累完成量', '设计总量', '上周计划完成量', '上周实际完成量', '本周计划完成量', '完成总周数',
                '当前周目']
    return excel.make_response_from_query_sets(queryset, column_names, 'xls', file_name=file_name, colnames=colnames,
                                               sheet_name='进度数据', ignore_rows=[0] if len(queryset) else [1])
Example #16
0
 def get(self, request):
     search = request.GET.get('search')
     if search:
         search = request.GET.get('search').strip()
         users = UserProfile.objects.filter(Q(username__icontains=search) | Q(staff_no__icontains=search)
                                            | Q(department__icontains=search) | Q(bg_telephone__icontains=search)
                                            | Q(mobile__icontains=search) | Q(email__icontains=search,
                                            is_superuser=0)).order_by('-is_staff', 'staff_no')
     else:
         users = UserProfile.objects.filter(is_superuser=0).order_by('-is_staff', 'staff_no')
     columns_names = ['id', 'username', 'staff_no', 'department', 'bg_telephone', 'mobile', 'email', 'is_staff']
     return excel.make_response_from_query_sets(users, columns_names, 'xls', file_name='人员列表')
Example #17
0
def export_data(request):
    query_sets = Conductor.objects.all()
    column_names = [
        "cedula", "nombres", 'apellidos', 'direccion', 'rh', 'telefono',
        'celular', 'correo', 'fecha_nacimiento', 'nivel_estudio',
        'numero_licencia_conduccion', 'categoria_licencia', 'estado_licencia',
        'organismo_transito', 'fecha_expedicion', 'fecha_vencimiento',
        'restricciones', 'experiencia', 'activo_inactivo'
    ]
    return excel.make_response_from_query_sets(query_sets,
                                               column_names,
                                               'xls',
                                               file_name="conductores")
def excelExport(request):
    if request.method == 'POST':
        # object_ids = request.POST.get('object_ids', None)
        # question = Expense.objects.all()
        question = excel_objects
        query_sets = question
        # query_sets = question.filter(has_been_changed=True)
        column_names = ['name', 'date', 'time', 'price', 'category_name_id']
        return excel.make_response_from_query_sets(query_sets,
                                                   column_names,
                                                   'xls',
                                                   file_name="custom")
    else:
        return render(request, 'excelExportTest.html')
Example #19
0
def export_data(request):
    # return excel.make_response_from_a_table(Ruta, 'xls', file_name="rutas")
    query_sets = Ruta.objects.all()
    column_names = [
        'codigo_ruta', 'nombre_ruta', 'tipo_viaje', 'tipo_ruta',
        'tipo_vehiculo_requerido', 'origen', 'destino', 'hora_inicio',
        'hora_fin', 'valor_hora_adicional', 'valor_ruta', 'valor_tercero',
        'comision_conductor', 'kilometros', 'link_ruta', 'nit_id',
        'activo_inactivo'
    ]
    return excel.make_response_from_query_sets(query_sets,
                                               column_names,
                                               'xls',
                                               file_name="rutas")
Example #20
0
 def export_excel(self, request, queryset):
     # data_excel =Contract.objects.all()
     # print(request.GET['q'])
     # print(queryset)
     qs = self.get_changelist_instance(request).get_queryset(request)
     column_names = [
         "code",
     ]
     return excel.make_response_from_query_sets(qs,
                                                column_names,
                                                "xlsx",
                                                status=200,
                                                sheet_name='测试',
                                                file_name='测试文件')
Example #21
0
def export_data(request):
    # return excel.make_response_from_a_table(Ruta, 'xls', file_name="rutas")
    query_sets = Planilla.objects.all()
    column_names = [
        'fecha', 'kilometros', 'hora_adicional', 'hora_inicio', 'hora_fin',
        'tiempo_operado', 'observaciones', 'novedades', 'flota', 'valor_ruta',
        'valor_tercero', 'viaticos', 'descuentos_conductor',
        'valor_hora_adicional', 'adicional_conductor', 'total_ingreso',
        'conductor_id', 'placa_id', 'ruta_id'
    ]
    return excel.make_response_from_query_sets(query_sets,
                                               column_names,
                                               'xls',
                                               file_name="planilla")
Example #22
0
def export_user(request, pk):
    users = Users.objects.filter(pk=pk)
    # user = Users.objects.get(pk=pk)
    # gifts = user.get_gifts()
    # stroka = ''
    # for gift in gifts:
    #     stroka += gift['gift_name'] + ", Статус: " + gift['status'] + "; \n"
    # users['Подарки'] = stroka
    column_names = [
        'dt_add', 'id_user', 'id_invite', 'name', 'phone', 'dt_birth'
    ]
    return excel.make_response_from_query_sets(users,
                                               column_names,
                                               'xls',
                                               file_name="custom")
Example #23
0
def exportDataToExcel(request):
    dataCounter = request.GET.get('dataCounter', '')
    data = DwfMeasureData.objects.filter(dataCounter=dataCounter)
    data2 = DwfResultData.objects.get(dataCounter=dataCounter)

    file_name = str(data2.startTime) + " to " + str(data2.targetTime)
    column_names = [
        'dataCounter', 'Z', 'R', 'C', 'freq', 'channel', 'time', 'timeMin'
    ]

    print(file_name)

    return excel.make_response_from_query_sets(data,
                                               column_names,
                                               'xlsx',
                                               file_name=file_name)
Example #24
0
def export_r5(request):
    column_names = ['IdCtto', 'NumCtto', 'DescCtto']
    exp_ctto = Ctto.objects.filter()

    e = Ctto.objects.filter()
    print(e)

    #q5 = Mdte.objects.filter(exp_ctto)
    #q6 = Ctto.objects.select_related().get(id=2)

    #print(q6.NomMandte)

    #exp_ctto = Ctto.objects.all()

    return excel.make_response_from_query_sets(exp_ctto,
                                               column_names,
                                               'xls',
                                               file_name="custom")
Example #25
0
def export_data(request, atype):
    if atype == "sheet":
        return excel.make_response_from_a_table(Item, 'xls', file_name="sheet")
    elif atype == "book":
        return excel.make_response_from_tables([Question, Choice],
                                               'xls',
                                               file_name="book")
    elif atype == "custom":
        question = Question.objects.get(slug='ide')
        query_sets = Choice.objects.filter(question=question)
        column_names = ['choice_text', 'id', 'votes']
        return excel.make_response_from_query_sets(query_sets,
                                                   column_names,
                                                   'xls',
                                                   file_name="custom")
    else:
        return HttpResponseBadRequest(
            "Bad request. please put one of these " +
            "in your url suffix: sheet, book or custom")
Example #26
0
def export_material_data(request):
    file_name = '物资表_'
    queryset = Material.objects.all()

    file_name += datetime.now().strftime("%Y-%m-%d")

    column_names = [
        'id', 'name', 'manufacturer', 'profess_id', 'profess_name', 'type_id',
        'num', 'unit'
    ]
    colnames = ['物资编号', '名称', '生产厂家', '专业id', '专业名称', '型号', '数量', '单位']
    return excel.make_response_from_query_sets(
        queryset,
        column_names,
        'xls',
        file_name=file_name,
        colnames=colnames,
        sheet_name='物资数据',
        ignore_rows=[0] if len(queryset) else [1])
Example #27
0
def export_data(request, atype):
    if atype == "sheet":
        return excel.make_response_from_a_table(
            Question, 'xls', file_name="sheet")
    elif atype == "book":
        return excel.make_response_from_tables(
            [Question, Choice], 'xls', file_name="book")
    elif atype == "custom":
        question = Question.objects.get(slug='ide')
        query_sets = Choice.objects.filter(question=question)
        column_names = ['choice_text', 'id', 'votes']
        return excel.make_response_from_query_sets(
            query_sets,
            column_names,
            'xls',
            file_name="custom"
        )
    else:
        return HttpResponseBadRequest("Bad request. please put one of these in your url suffix: sheet, book or custom")
Example #28
0
def send_to_excel(request, data, test):
    test = get_object_or_404(Test, id=test)

    if data == "answers":
        answers = Answer.objects.filter(query__test=test)
        serializer = AnswerSerializer(answers, many=True)
        file_name = u"test#%s_answers" % str(test.id)
        serializer = list(map(change_answers, serializer.data))
        return make_response_from_records(serializer, 'xls', file_name=file_name)
    elif data == "questions":
        questions = Query.objects.filter(test=test)
        file_name = u'test#%s_questions' % str(test.id)
        column_names = ['id', 'text']
        return make_response_from_query_sets(questions, column_names, 'xlsx', file_name=file_name)
    elif data == "testeds":
        testeds = change_testeds(TestedSerializer(Tested.objects.filter(test=test), many=True).data)
        file_name = u'test#%s_testeds' % str(test.id)
        return make_response_from_records(testeds, 'xls', file_name=file_name)
    else:
        return Http404("Does Not Exist")
Example #29
0
def export_data(request):
    query_sets = set(MLSession.objects.all())
    for item in query_sets:
        item.time = item.time.strftime('%H:%M')
    column_names = [
        'session_id', 'year', 'month', 'day', 'time', 'platform',
        'visitor_type', 'page_1', 'page_time_1', 'page_pictures_1', 'page_2',
        'page_time_2', 'page_pictures_2', 'page_3', 'page_time_3',
        'page_pictures_3', 'page_4', 'page_time_4', 'page_pictures_4',
        'page_5', 'page_time_5', 'page_pictures_5', 'page_6', 'page_time_6',
        'page_pictures_6', 'page_7', 'page_time_7', 'page_pictures_7',
        'page_8', 'page_time_8', 'page_pictures_8', 'page_9', 'page_time_9',
        'page_pictures_9', 'page_10', 'page_time_10', 'page_pictures_10'
    ]
    result = excel.make_response_from_query_sets(query_sets,
                                                 column_names,
                                                 'xls',
                                                 file_name="custom")

    return result
Example #30
0
def export_sheet(request, atype):
    if atype == "sheet":
        return excel.make_response_from_a_table(Location,
                                                'xls',
                                                status=200,
                                                file_name="Locations")
    elif atype == "book":
        return excel.make_response_from_tables([Location],
                                               'xls',
                                               file_name="Locations")
    elif atype == "custom":
        query_sets = Location.objects.all()
        column_names = ['location_name', 'common_name', 'location_type']
        return excel.make_response_from_query_sets(query_sets,
                                                   column_names,
                                                   'xls',
                                                   file_name="Locations")
    else:
        return HttpResponseBadRequest(
            "Bad request. please put one of these " +
            "in your url suffix: sheet, book or custom")
Example #31
0
def export_data(request):
    # return excel.make_response_from_a_table(Vehiculo, 'xls', file_name="vehiculos")
    query_sets = Vehiculo.objects.all()
    column_names = [
        'placa', 'numero_interno', 'combustible', 'numero_licencia_transito',
        'organismo_transito', 'fecha_expedicion', 'marca', 'linea',
        'cilindraje', 'modelo', 'clase_vehiculo', 'color', 'tipo_servicio',
        'carroceria', 'capacidad', 'numero_motor', 'numero_chasis',
        'propietario', 'id_propietario', 'numero_tarjeta_operacion',
        'fecha_inicio_tarjeta_operacion',
        'fecha_vencimiento_tarjeta_operacion', 'empresa_afiliado',
        'id_empresa_afiliado', 'numero_soat', 'fecha_inicio_soat',
        'aseguradora_soat', 'numero_certificado_rtm', 'fecha_inicio_rtm',
        'fecha_vencimiento_rtm', 'centro_diagnostico_automotriz',
        'numero_polizas_rce_rcc', 'fecha_inicio_rce_rcc',
        'fecha_vencimiento_rce_rcc', 'aseguradora_rce_rcc', 'activo_inactivo',
        'conductor_default_id'
    ]
    return excel.make_response_from_query_sets(query_sets,
                                               column_names,
                                               'xls',
                                               file_name="vehiculos")
Example #32
0
def export_member_data(request, dept_id=None):
    file_name = '员工表_'
    if dept_id:
        dept = get_object_or_404(Departments, pk=dept_id)
        members = Member.objects.filter(dept_id=dept_id)
        file_name += dept.dept_name + '_'
    else:
        members = Member.objects.all()

    file_name += datetime.now().strftime("%Y-%m-%d")

    column_names = ['member_id', 'dept_id', 'dept_name', 'name', 'sex', 'birthday', 'position', 'phone', 'nation',
                    'blood_type']
    colnames = ['员工工号', '部门id', '部门名字', '姓名',
                '性别', '生日', '职位', '电话', '民族', '血型']
    return excel.make_response_from_query_sets(
        members,
        column_names,
        'xls',
        file_name=file_name,
        colnames=colnames,
        ignore_rows=[0] if len(members) else [1]
    )
Example #33
0
	def get(self,request):
		payroll = Payroll.objects.all()
		column_names = ['id']
		payroll = {}
		payroll['id'] = 1
		return excel.make_response_from_query_sets(payroll,column_names,'xls')
Example #34
0
def generate_class_report(request, class_name):
    user_class_dataset = Class_code.objects.get(class_name = class_name)
    user_list = [i.user for  i in user_class_dataset.class_assignment_set.all() if i.user.role == Role.objects.get(name='student')]
    column_name = ['pk', 'username', 'firstname', 'lastname', 'role.name']
    return excel.make_response_from_query_sets(user_dataset, column_name, 'xlsx', file_name=class_name+'_stu')
Example #35
0
def generate_report(request):
    user_dataset = User.objects.all()
    column_name = ['pk', 'username', 'firstname', 'lastname', 'role.name']
    return excel.make_response_from_query_sets(user_dataset, column_name, 'xlsx', file_name="custom")
Example #36
0
def export_data(request, file):

    if file=='weekly':
        queryset=''
        column_names = ['ar_code' ,'location_code' ,'store_name' ,'activity' ,'ctn_activation_date' ,'activity_date' ,'cancel_date' ,'byod' ,'auto_pay' ,'port_type' ,'ban' ,'ctn' ,'imei' ,'operator_id' ,'sub_rank' ,'mrc' ,'previous_mrc' ,'rrc' ,'previous_rrc' ,'activation_commission' ,'plan_migration_commission' ,'incremental_commission' ,'retention_rate' ,'retention_rate_commission' ,'spif1' ,'spif2' ,'national_retail_activation' ,'device_upgrade' ,'device_return' ,'manual_transaction' ,'manual_payment' ,'offset' ,'mdf_payment' ,'commission_payout' ,'comment']
        s=str(request.META.get('HTTP_REFERER'))
        if 'search/all' in s:
            header= re.search('header=(.*)&', s)            
            value= re.search('q=(.*)$', s)
            try:
             header=header.group(1)
             value=value.group(1)             
            except:
                messages.error(request,'PLEASE TRY AGAIN WITH VALID QUERYSET TO EXPORT')
                return redirect(request.META.get('HTTP_REFERER'))
            if header=='CTN':
             value=re.sub('[^0-9]','',value)
             print(value)
             queryset=Weekly.objects.filter(ctn=value)
             print(queryset)
            if header=='IMEI':
             value=re.sub('[^0-9]','',value)
             queryset=Weekly.objects.filter(imei=value)
             
            if header=='ACTIVITY':
             value=re.sub('\+',' ',value)

             queryset=Weekly.objects.filter(activity__icontains=value)
             
        else:
         x=request.session['export']
         queryset=Weekly.objects.filter(id__in=x)
        return excel.make_response_from_query_sets(queryset,column_names,'xls', file_name="customWeeklyCTNfile")
    if file=='monthly':
        queryset=''
        column_names=['location_id' ,'location_name' ,'activity_date' ,'imei' ,'ctn' ,'qualifying_activity_type' ,'product_sku' ,'device_name' ,'promotion_name' ,'promotion_start_date' ,'promotion_end_date' ,'promotion_category' ,'promotion_sale_price' ,'imm_purchase_price' ,'credit_amount' ,'payment_date' ,'ship_date' ,'imm_invoice_number' ,'reason']
        s=str(request.META.get('HTTP_REFERER'))
        if 'search/all' in s:
            try:
                header= re.search('header=(.*)&', s)
                header=header.group(1)
                value= re.search('q=(.*)$', s)
                value=value.group(1)
            except:
                 messages.error(request,'PLEASE TRY AGAIN WITH VALID QUERYSET TO EXPORT')
                 return redirect(request.META.get('HTTP_REFERER'))
            if header=='CTN':
             value=re.sub('[^0-9]','',value)
             queryset=Monthly.objects.filter(ctn=value)
            if header=='IMEI':
             value=re.sub('[^0-9]','',value)
             queryset=Monthly.objects.filter(imei=value)
            if header=='ACTIVITY':
             value=re.sub('\+',' ',value)             
             queryset=Monthly.objects.filter(qualifying_activity_type__icontains=value)
        else:
           x=request.session['export']
           queryset=Monthly.objects.filter(id__in=x)
        return excel.make_response_from_query_sets(queryset,column_names,'xls', file_name="customMonthlyTrailingfile")
    if file=='pos':
         queryset=''
         column_names=['invoice_number' ,'tracking_number' ,'qty' ,'product_sku' ,'product_name' ,'unit_rebate' ,'partial_cb' ,'total_rebate' ,'collected' ,'balance' ,'tax_amount' ,'carrier_price' ,'related_product' ,'related_sku' ,'related_sn' ,'related_cost' ,'related_price' ,'rate_plan' ,'rate_plan_2' ,'term_code' ,'customer' ,'sales_person' ,'sales_person_id' ,'sold_on' ,'invoiced_by' ,'invoiced_at' ,'original_invoice' ,'original_sales_date' ,'flagged' ,'reconciled' ,'reconciled_by' ,'reconciled_on' ,'adjusted' ,'charge_back' ,'journal_number' ,'contract_number' ,'customer_identifier' ,'comments' ,'comments_2' ,'soc_code' ,'soc_code_2' ,'extra_field' ,'zip_code' ,'region' ,'district' ,'vendor_account_name' ,'vendor_number' ,'vendor_sku' ,'scd_response']
         s=str(request.META.get('HTTP_REFERER'))
         print(s)
         if 'search/all' in s:
            header= re.search('header=(.*)&', s)
            try:
                header=header.group(1)
                value= re.search('q=(.*)$', s)
                value=value.group(1)
            except:
                messages.error(request,'PLEASE TRY AGAIN WITH VALID QUERYSET TO EXPORT')
                return redirect(request.META.get('HTTP_REFERER'))
            if header=='CTN':
             value=re.sub('[^0-9]','',value)
             
             queryset=POS.objects.filter(tracking_number=value)
            if header=='IMEI':
             value=re.sub('[^0-9]','',value)
             queryset=POS.objects.filter(related_sn=value)
            if header=='ACTIVITY':
             value=re.sub('\+',' ',value)
             queryset=POS.objects.filter(term_code__icontains=value)
         else:
          x=request.session['export']
          queryset=POS.objects.filter(id__in=x)
         return excel.make_response_from_query_sets(queryset,column_names,'xls', file_name="customPOSfile")
    else:
        return HttpResponseBadRequest(
            "Bad request. please put one of these " +
            "in your url suffix: sheet, book or custom")
def handson_table(request, query_sets, fields):
    """function to render the scoresheets as part of the template"""
    return excel.make_response_from_query_sets(query_sets, fields, 'handsontable.html')