summaryrefslogtreecommitdiff
path: root/app/expenses/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/expenses/views.py')
-rw-r--r--app/expenses/views.py35
1 files changed, 26 insertions, 9 deletions
diff --git a/app/expenses/views.py b/app/expenses/views.py
index 7442178..3a8d2cb 100644
--- a/app/expenses/views.py
+++ b/app/expenses/views.py
@@ -1,12 +1,29 @@
-from django.shortcuts import render_to_response, get_object_or_404
-from django.template import RequestContext
+from django.views.generic import ListView
-from .models import Expense, CATS
+from .models import Expense, Trip, CATS
-def detail(request):
- context = {
- 'object_list': Expense.objects.all(),
- 'categories': CATS
- }
- return render_to_response('details/expenses.html', context, context_instance=RequestContext(request))
+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 TripListView(ListView):
+ model = Trip
+ context_object_name = 'object_list'
+ template_name = 'archives/expenses.html'
+
+ def get_queryset(self):
+ return Trip.objects.all()