示例#1
0
def services(request):
    check_set_session(request)
    context = {
        'title': 'Services',
        'PageContent': WebContent.objects.get(position="Services")
    }
    return render(request, 'home/page.html', context)
示例#2
0
def shop(request):
    check_set_session(request)
    # The shop page has to get data from the database of the selected Jar
    wishlist_jar_number = request.session.get('session')['products']
    buy_jar_number = request.session.get('session')['buy']
    print(request.session.get('session'))
    if buy_jar_number:
        product = Jar.objects.select_related('product_details').get(
            jar_number__iexact=buy_jar_number)
        if product.jar_status == "Sold":
            request.session.get('session')['products'].remove(buy_jar_number)
            request.session.get('session')['buy'] = ""
            request.session.modified = True

    elif len(wishlist_jar_number) == 1:
        product = Jar.objects.select_related('product_details').get(
            jar_number__iexact=wishlist_jar_number[0])
        if product.jar_status == "Sold":
            request.session.get('session')['products'].remove(buy_jar_number)
            request.session.get('session')['buy'] = ""
            request.session.modified = True
    else:
        product = None

    if len(wishlist_jar_number) > 1:
        SeveralItemsWishlisted = True
    else:
        SeveralItemsWishlisted = False

    context = {'product': product, 'itemswishlisted': SeveralItemsWishlisted}

    return render(request, 'shop/shop.html', context)
示例#3
0
def about(request):
    check_set_session(request)
    context = {
        'title': 'About',
        'PageContent': WebContent.objects.get(position="AboutPageText")
    }
    return render(request, 'home/page.html', context)
示例#4
0
def index(request):
    check_set_session(request)
    context = {
        'title':
        'Homepage',
        'description':
        WebContent.objects.get(position="HomePageDescriptionText"),
        'posts':
        Post.objects.filter(
            categories__position='Jars').order_by('-date_created')[:3],
    }
    return render(request, 'home/index.html', context)
示例#5
0
def legal(request):
    check_set_session(request)
    content = request.GET
    try:
        legal_content = Legal.objects.get(url__iexact=content['legal'])
        single = True
    except:
        legal_content = Legal.objects.all()
        single = False
    context = {
        'single': single,
        'legals': legal_content,
    }

    return render(request, 'legal/legal.html', context)
示例#6
0
def contact2(request):
    check_set_session(request)
    form = ContactForm()
    context = {
        'title': 'Contact Us',
        'PageContent': WebContent.objects.get(position="Contact"),
        'PageContent2': WebContent.objects.get(position="Contactdetails"),
        'form': form
    }
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            form.save()
            form = ContactForm()
            messages.success(request, 'Thank you!')
        else:
            messages.error(request, 'Email not valid or already exists!')
            form = ContactForm()
    else:
        form = ContactForm()
    return render(request, 'home/contact2.html', context)
示例#7
0
def page(request):
    check_set_session(request)
    content = request.GET
    context = {'PageContent': WebContent.objects.get(position=content['page'])}
    return render(request, 'home/page.html', context)