2021-01-08 22:23:52 +01:00
|
|
|
from django.shortcuts import render,redirect, get_object_or_404
|
|
|
|
from django.views.generic import (
|
|
|
|
ListView,
|
|
|
|
DetailView,
|
|
|
|
View
|
|
|
|
)
|
|
|
|
from camper.models import Offer, Image_offer
|
|
|
|
from django.http import Http404, HttpResponseRedirect
|
2021-01-27 20:09:55 +01:00
|
|
|
from django.core.paginator import Paginator ,EmptyPage, PageNotAnInteger
|
2021-01-17 17:10:04 +01:00
|
|
|
|
2021-01-08 22:23:52 +01:00
|
|
|
class Home(View):
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
return render(request, 'index.html')
|
|
|
|
|
|
|
|
class OfferDetailView(DetailView):
|
|
|
|
template_name = 'offer/offer-detail.html'
|
|
|
|
model = Offer
|
2021-01-17 17:10:04 +01:00
|
|
|
context_object_name = 'offer'
|
|
|
|
|
2021-01-08 22:23:52 +01:00
|
|
|
class OfferListView(ListView):
|
|
|
|
model = Offer
|
|
|
|
template_name = 'offer/offers.html'
|
2021-01-17 17:10:04 +01:00
|
|
|
context_object_name = 'active_offers_list'
|
2021-01-27 20:09:55 +01:00
|
|
|
paginate_by = 4
|
|
|
|
|
|
|
|
ordering = ['-date_added']
|
2021-01-08 22:23:52 +01:00
|
|
|
|
|
|
|
def get_queryset(self):
|
2021-01-17 17:10:04 +01:00
|
|
|
return Offer.objects.filter(status = 'Active')
|
|
|
|
|
|
|
|
#def book_detail_view(request, primary_key):
|
|
|
|
# book = get_object_or_404(Book, pk=primary_key)
|
|
|
|
# return render(request, 'catalog/book_detail.html', context={'book': book})
|