from django.views.generic import ListView from django.views.generic.detail import DetailView from django.views.generic.edit import CreateView, UpdateView from django.urls import reverse from django.utils import timezone from django.conf import settings from utils.views import PaginatedListView from .models import Camp class PlannerListView(PaginatedListView): model = Camp template_name = 'planner/list.html' def get_context_data(self, **kwargs): # Call the base implementation first to get a context context = super(PlannerListView, self).get_context_data(**kwargs) return context def get_queryset(self): queryset = super(PlannerListView, self).get_queryset() return queryset.filter(date_arrive__gte=timezone.now()) class PlannerModelFormView(CreateView): model = Camp fields = [ 'name', 'date_arrive', 'date_depart', 'distance_from_previous', 'notes', 'link', 'map_link', 'price', 'site_number', 'has_water', 'has_electric', 'has_dump', 'point', ] success_url = '/planner/' template_name = 'planner/create_form.html' class PlannerUpdateView(UpdateView): model = Camp fields = [ 'name', 'date_arrive', 'date_depart', 'distance_from_previous', 'notes', 'link', 'map_link', 'price', 'site_number', 'has_water', 'has_electric', 'has_dump', 'point', ] success_url = '/planner/' template_name = 'planner/update_form.html'