summaryrefslogtreecommitdiff
path: root/app/planner/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/planner/views.py')
-rw-r--r--app/planner/views.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/app/planner/views.py b/app/planner/views.py
new file mode 100644
index 0000000..b89506a
--- /dev/null
+++ b/app/planner/views.py
@@ -0,0 +1,44 @@
+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',
+ 'price',
+ 'site_number',
+ 'has_water',
+ 'has_electric',
+ 'has_dump',
+ 'point',
+ ]
+ success_url = '/planner/'
+ template_name = 'planner/create_form.html'
+