brotherton-erpnext/erpnext/templates/pages/home.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.7 KiB
Python
Raw Normal View History

2016-04-22 09:09:02 +00:00
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
2016-04-22 09:09:02 +00:00
import frappe
no_cache = 1
2022-03-28 13:22:46 +00:00
2016-04-22 13:23:21 +00:00
def get_context(context):
homepage = frappe.get_cached_doc("Homepage")
2016-05-12 09:52:59 +00:00
2016-05-02 06:13:44 +00:00
for item in homepage.products:
route = frappe.db.get_value("Website Item", {"item_code": item.item_code}, "route")
2016-06-27 06:34:13 +00:00
if route:
item.route = "/" + route
2016-05-12 09:52:59 +00:00
homepage.title = homepage.title or homepage.company
context.title = homepage.title
context.homepage = homepage
if homepage.hero_section_based_on == "Homepage Section" and homepage.hero_section:
homepage.hero_section_doc = frappe.get_cached_doc("Homepage Section", homepage.hero_section)
2016-05-12 09:52:59 +00:00
if homepage.slideshow:
doc = frappe.get_cached_doc("Website Slideshow", homepage.slideshow)
context.slideshow = homepage.slideshow
context.slideshow_header = doc.header
context.slides = doc.slideshow_items
context.blogs = frappe.get_all(
"Blog Post",
fields=["title", "blogger", "blog_intro", "route"],
filters={"published": 1},
order_by="modified desc",
limit=3,
)
# filter out homepage section which is used as hero section
homepage_hero_section = (
homepage.hero_section_based_on == "Homepage Section" and homepage.hero_section
2022-03-28 13:22:46 +00:00
)
homepage_sections = frappe.get_all(
"Homepage Section",
filters=[["name", "!=", homepage_hero_section]] if homepage_hero_section else None,
order_by="section_order asc",
)
context.homepage_sections = [
frappe.get_cached_doc("Homepage Section", name) for name in homepage_sections
]
context.metatags = context.metatags or frappe._dict({})
context.metatags.image = homepage.hero_image or None
context.metatags.description = homepage.description or None
context.explore_link = "/all-products"