mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
Fixed a bad merge
This commit is contained in:
commit
409b7b86f5
4 changed files with 24 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -9,3 +9,4 @@ media/js/*.r*.js
|
|||
media/css/*.r*.css
|
||||
*DS_Store
|
||||
*.egg-info
|
||||
|
||||
|
|
|
|||
0
categories/templates/categories/category_detail.html
Normal file
0
categories/templates/categories/category_detail.html
Normal file
|
|
@ -1,19 +1,19 @@
|
|||
from django.conf.urls.defaults import *
|
||||
from categories.models import *
|
||||
from categories.models import Category
|
||||
|
||||
categorytree_dict = {
|
||||
'queryset': CategoryTree.objects.all()
|
||||
'queryset': Category.objects.all()
|
||||
}
|
||||
|
||||
urlpatterns = patterns('django.views.generic.list_detail',
|
||||
url(
|
||||
r'^$', 'object_list', categorytree_dict, name='categories_tree_list'
|
||||
),
|
||||
url(
|
||||
r'^(?P<slug>[\w-]+)/$', 'object_detail', categorytree_dict, name='categories_tree'
|
||||
),
|
||||
#url(
|
||||
# r'^(?P<slug>[\w-]+)/$', 'object_detail', categorytree_dict, name='categories_tree'
|
||||
#),
|
||||
)
|
||||
|
||||
urlpatterns += patterns('categories.views',
|
||||
url(r'^(?P<slug>[\w-]+)/(?P<category_slug>[\w\-\/]+)/$', 'category_detail', name='categories_category'),
|
||||
url(r'^(?P<slug>[\w-]+)/$', 'category_detail', {'with_stories': True}, name='categories_category'),
|
||||
)
|
||||
|
|
@ -1,21 +1,23 @@
|
|||
from django.shortcuts import get_object_or_404, render_to_response
|
||||
from django.template import RequestContext
|
||||
from ellington.categories.models import *
|
||||
from categories.models import Category
|
||||
from stories.models import Story
|
||||
from django.db.models import Q
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
def category_detail(request, slug, category_slug):
|
||||
"""
|
||||
A detail view of a category.
|
||||
|
||||
Templates:
|
||||
:template:`categories/category_detail.html`
|
||||
Context:
|
||||
category
|
||||
A :model:`categories.Category` object.
|
||||
"""
|
||||
def category_detail(request, slug, with_stories=False,
|
||||
template_name='categories/category_detail.html'):
|
||||
context = {}
|
||||
category = get_object_or_404(Category,
|
||||
hierarchy__slug=slug,
|
||||
slug_path="/%s" % category_slug)
|
||||
return render_to_response('categories/category_detail.html',
|
||||
{'category' : category},
|
||||
slug__iexact=slug)
|
||||
|
||||
context['category'] = category
|
||||
|
||||
if with_stories:
|
||||
stories = Story.published.filter(Q(primary_category=category) | Q(categories__in=[category,]))
|
||||
context['stories'] = stories
|
||||
|
||||
return render_to_response(template_name,
|
||||
context,
|
||||
context_instance=RequestContext(request)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue