diff --git a/gawa/blog/views.py b/gawa/blog/views.py
index c4c094e..3c55917 100644
--- a/gawa/blog/views.py
+++ b/gawa/blog/views.py
@@ -8,6 +8,7 @@ from start.views import SearchableView
import logging
logger = logging.getLogger(__name__)
+
class Index(TemplateView, SearchableView):
"""
The index page of the gawa/blog app.
@@ -20,15 +21,17 @@ class Index(TemplateView, SearchableView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
- context['featured_posts'] = BlogPost.objects.filter(featured=True, public=True)
+ context['featured_posts'] = BlogPost.objects.filter(
+ featured=True, public=True)
return context
+
class Post(DetailView):
"""
Main page of a blog post
"""
- model=BlogPost
+ model = BlogPost
template_name = "blog/blogpost.html"
context_object_name = "post"
@@ -37,6 +40,7 @@ class Post(DetailView):
context['featured_posts'] = BlogPost.objects.filter(featured=True)
return context
+
class Browse(ListView):
"""
Scroll through a list of blog posts
@@ -45,10 +49,19 @@ class Browse(ListView):
Of course, Articles will also show up in the MainSearchView
"""
- model=BlogPost
+ model = BlogPost
template_name = "blog/browse.html"
context_object_name = "posts"
+ def get_queryset(self):
+ objects = BlogPost.objects.all()
+ if "category" in self.request.GET and len(
+ self.request.GET["category"].strip()) > 0:
+ category = self.request.GET["category"]
+ category = Category.objects.get(slug=category)
+ objects = objects.filter(category=category)
+ return objects
+
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['featured_posts'] = BlogPost.objects.filter(featured=True)