Added seperate minerals detail page

This commit is contained in:
2014-01-21 21:43:23 +10:00
parent 07c6260bde
commit d5867c8d4a
6 changed files with 34 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ Define the views for the Django MVC
from django import template
from django.views import generic
from three_d_viewer.models import Sample, Category
from three_d_viewer.models import Sample, Category, Mineral
register = template.Library()
@@ -19,7 +19,7 @@ class HomeView(generic.ListView):
def get_context_data(self, **kwargs):
context = super(HomeView, self).get_context_data(**kwargs)
context['active_samples'] = Sample.objects.filter(active=True).order_by('name')
context['active_samples'] = Sample.objects.select_subclasses(Mineral).filter(active=True).order_by('name')
context['parent_categories'] = Category.objects.filter(parent=None). \
filter(active=True).order_by('name')
return context
@@ -37,7 +37,15 @@ class DetailView(generic.DetailView):
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
context['active_samples'] = Sample.objects.filter(active=True).order_by('name')
context['active_samples'] = Sample.objects.select_subclasses(Mineral).filter(active=True).order_by('name')
context['parent_categories'] = Category.objects.filter(parent=None). \
filter(active=True).order_by('name')
return context
class MineralDetailView(DetailView):
"""
Add extra functionality for mineral details
"""
model = Mineral
template_name = 'three_d_viewer/mineral_detail.html'