35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import http
|
|
from odoo.http import request
|
|
from markupsafe import Markup
|
|
from ..utils.blog_data import get_all_posts, get_post_by_slug, get_recent_posts
|
|
|
|
|
|
class V2BlogController(http.Controller):
|
|
|
|
@http.route('/blog', type='http', auth='public', website=True)
|
|
def blog_list(self, **kwargs):
|
|
"""Render the blog listing page with all posts."""
|
|
posts = get_all_posts()
|
|
return request.render('theme_aakriti_v2.v2_blog_list', {
|
|
'posts': posts,
|
|
'page_title': 'Blog — Aakriti Events',
|
|
})
|
|
|
|
@http.route('/blog/<string:slug>', type='http', auth='public', website=True)
|
|
def blog_detail(self, slug, **kwargs):
|
|
"""Render a single blog post by slug."""
|
|
post = get_post_by_slug(slug)
|
|
if not post:
|
|
return request.not_found()
|
|
|
|
post = dict(post)
|
|
post['content'] = Markup(post.get('content', ''))
|
|
|
|
recent = get_recent_posts(exclude_slug=slug, limit=3)
|
|
return request.render('theme_aakriti_v2.v2_blog_detail', {
|
|
'post': post,
|
|
'recent_posts': recent,
|
|
'page_title': post['title'] + ' — Aakriti Events',
|
|
})
|