summaryrefslogtreecommitdiff
path: root/app/planner/views.py
blob: ea862ad94cfc62350c7af03c86dbfdf997ad3313 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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'