1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/project/blog/views.py

21 lines
693 B
Python
Raw Normal View History

2016-02-20 19:27:18 +00:00
from project.common.views import CustomTemplate
2016-02-20 23:06:49 +00:00
from .utils import get_post, reformat_date
2016-02-20 19:27:18 +00:00
from django.http import Http404
class BlogView(CustomTemplate):
2016-02-20 21:37:03 +00:00
template_name = "blog/posts.html"
2016-02-20 19:27:18 +00:00
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['blog'] = self.blog_data
2016-02-20 23:06:49 +00:00
context['blog']['date'] = reformat_date(self.blog_data['date'])
2016-02-20 19:27:18 +00:00
return context
def dispatch(self, request, *args, **kwargs):
self.blog_data = get_post(kwargs['slug'])
if not self.blog_data:
raise Http404
self.html_title = self.blog_data['title']
return super().dispatch(request, *args, **kwargs)