Beispiel #1
0
def product_detail(request, product_id):
    try:
        product = Product.objects.get(pk = product_id)
    except Product.DoesNotExist:
        raise Http404

    partner = utils.get_partner(request.user)
    tearsheet_url = ''
    tearsheet_metric_url = ''
    if partner:
        if partner.show_us_version and product.tearsheet:
            tearsheet_url = product.tearsheet.url
        if partner.show_metric and product.tearsheet_metric:
            tearsheet_metric_url = product.tearsheet_metric.url
    else:
        if product.tearsheet:
            tearsheet_url = product.tearsheet.url
        if product.tearsheet_metric:
            tearsheet_metric_url = product.tearsheet_metric.url

    return render(request, 'partner/product_detail.html', {
        'product': product,
        'tearsheet_metric_url': tearsheet_metric_url,
        'tearsheet_url': tearsheet_url
    })
Beispiel #2
0
def home(request):
    try:
        partner = utils.get_partner(request.user)
        name = partner.name
    except:
        name = request.user.username

    return render(request, 'partner/home.html', {
        'name': name
    })
Beispiel #3
0
def product_category_list(request):
    partner = utils.get_partner(request.user)
    show_us = True
    show_metric = True
    if partner:
        show_us = partner.show_us_version
        show_metric = partner.show_metric
    return render(request, 'partner/product_category_list.html', {
        'categories': Category.objects.all(),
        'show_us': show_us,
        'show_metric': show_metric
    })
Beispiel #4
0
def sales_tools(request):
    files = SalesTool.objects.all().order_by('name')

    try:
        partner = utils.get_partner(request.user)
        if partner and partner.hide_sales_tools:
            return redirect('/partner/home/')
        files = files.filter(is_eu_format = partner.show_eu_price)
    except:
        pass

    return render(request, 'partner/sales_tools.html', {
        'files': files
    })
Beispiel #5
0
def price_lists(request):
    partner = utils.get_partner(request.user)
    if partner and partner.group:
        if partner.hide_price:
            return redirect('/partner/home/')

        files = PriceList.objects.filter(
            Q(partner_group = partner.group)
            | Q(partner_group = None))

    else:
        files = PriceList.objects.all()

    return render(request, 'partner/price_lists.html', {
        'files': files.order_by('name')
    })
Beispiel #6
0
def product_category(request, category_slug):
    partner = utils.get_partner(request.user)
    category = Category.objects.filter(slug = category_slug).first()
    if not category:
        raise Http404
    products = Product.objects.filter(category = category).order_by('name')
    show_us = True
    show_metric = True
    if partner:
        show_us = partner.show_us_version
        show_metric = partner.show_metric

    return render(request, 'partner/product_category.html', {
        'products': products,
        'show_us': show_us,
        'show_metric': show_metric,
        'category': category
    })