Пример #1
0
def search_gsx(request, what, arg, value):
    if request.is_ajax():

        if what == "parts" and value != "None":
            results = []
            GsxAccount.default(user=request.user)

            try:
                product = gsxws.Product(productName=value)
                parts = product.parts()
                for p in parts:
                    results.append(Product.from_gsx(p))
            except gsxws.GsxError, e:
                data = {'message': e}
                return render(request, "search/results/gsx_error.html", data)

            data = {'results': results}

        return render(request, "search/results/gsx_%s.html" % what, data)
Пример #2
0
        results.append(result)

    if what == "parts":
        # looking for parts
        if gsx_type == "partNumber":
            # ... with a part number
            part = gsxws.Part(partNumber=query)

            try:
                partinfo = part.lookup()
            except gsxws.GsxError, e:
                error = {'message': e}
                return render(request, error_template, error)

            product = Product.from_gsx(partinfo)
            cache.set(query, product)
            results.append(product)
        else:
            # ... with a serial number
            try:
                results = device.get_parts()
                data['device'] = device
            except Exception, e:
                error = {'message': e}
                return render(request, error_template, error)

    if what == "repairs":
        # Looking for GSX repairs
        if gsx_type == "serialNumber":
            # ... with a serial number