blob: 98a4c70181e42b473642be8d0e38599301ca0df4 (
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
|
from django.views.generic import ListView
from .models import LuxExpense, Expense, Trip, CATS
class ExpenseListView(ListView):
model = Expense
context_object_name = 'object_list'
template_name = 'details/expenses.html'
def get_queryset(self):
return Expense.objects.filter(
trip__slug=self.kwargs['slug']
)
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(ExpenseListView, self).get_context_data(**kwargs)
context['categories'] = CATS
return context
class LuxExpenseListView(ListView):
model = LuxExpense
context_object_name = 'object_list'
template_name = 'details/expenses.html'
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(LuxExpenseListView, self).get_context_data(**kwargs)
context['categories'] = CATS
return context
class TripListView(ListView):
model = Trip
context_object_name = 'object_list'
template_name = 'archives/expenses.html'
def get_queryset(self):
return Trip.objects.all()
|