This repository has been archived by the owner on Sep 3, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.views.generic import ListView | ||
from django.contrib.auth.models import User | ||
|
||
from blog.models import Post | ||
from blog.settings import BLOG_PAGINATE_BY | ||
|
||
class BlogPostAuthorListView(ListView): | ||
|
||
context_object_name = "authors" | ||
template_name = "blog/author/list.html" | ||
|
||
def get_queryset(self): | ||
return User.objects.filter(is_staff=True) | ||
|
||
class BlogPostAuthorDetailView(ListView): | ||
|
||
context_object_name = "post_list" | ||
template_name = "blog/author/detail.html" | ||
paginate_by = BLOG_PAGINATE_BY | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(BlogPostAuthorDetailView, self).get_context_data(**kwargs) | ||
context['author'] = self.author | ||
return context | ||
|
||
def get_queryset(self): | ||
self.author = User.objects.get(username__iexact=self.kwargs['username']) | ||
return Post.objects.published(author=self.author) |