Ejemplo n.º 1
0
def detail(request, id, slug):
    prismic = PrismicHelper()

    document = prismic.get_document(id)

    parameters = {'context': prismic.get_context(), 'document': document}
    return render(request, 'prismic_app/detail.html', parameters)
def job(request, id, slug):
    prismic = PrismicHelper(request)
    context = prismic.get_context()

    return render(request, 'prismic_app/job_detail.html', {
        'context': context,
        'main': prismic.get_bookmark("jobs"),
        'job': prismic.get_document(id)
    })
def store(request, id, slug):
    prismic = PrismicHelper(request)
    context = prismic.get_context()

    the_store = prismic.get_document(id)
    openings = map(lambda day: [day, the_store.get_text("store.%s[0]" % day.lower())], WEEKDAYS)
    return render(request, 'prismic_app/store_detail.html', {
        'context': context,
        'main': prismic.get_bookmark("stores"),
        'store': the_store,
        'openings': openings
        })
def blog_post(request, id, slug):
    prismic = PrismicHelper(request)
    context = prismic.get_context()

    post = prismic.get_document(id)
    related_posts = prismic.get_documents(map(lambda d: d.id, post.get_all("blog-post.relatedpost")))
    related_products = prismic.get_documents(map(lambda d: d.id, post.get_all("blog-post.relatedproduct")))

    return render(request, 'prismic_app/post_detail.html', {
        'context': context,
        'categories': BLOG_CATEGORIES,
        'post': post,
        'related_posts': related_posts,
        'related_products': related_products,
        'allow_comments': post.get_text("blog-post.allow_comments") == "Yes",
        'post_url': request.build_absolute_uri(reverse('prismic:blog_post', args=[post.id, post.slug]))
    })
def product(request, id, slug):
    prismic = PrismicHelper(request)
    context = prismic.get_context()

    product = prismic.get_document(id)
    summary = product.get_text('product.short_lede')
    if summary is None:
        summary = product.get_text('product.name')

    related = prismic.get_documents(map(lambda d: d.id, product.get_all("product.related")))

    return render(request, 'prismic_app/product_detail.html', {
        'context': context,
        'product': product,
        'summary': summary,
        'author': product.get_text("product.testimonial_author"),
        'quote': product.get_text("product.testimonial_quote"),
        'related': related
    })