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
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
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):
|
2022-04-01 06:25:19 +00:00
|
|
|
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:
|
2021-02-23 08:36:38 +00:00
|
|
|
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
|
|
|
|
2019-03-19 06:18:32 +00:00
|
|
|
homepage.title = homepage.title or homepage.company
|
|
|
|
context.title = homepage.title
|
|
|
|
context.homepage = homepage
|
2016-08-09 11:13:15 +00:00
|
|
|
|
2019-03-19 06:18:32 +00:00
|
|
|
if homepage.hero_section_based_on == "Homepage Section" and homepage.hero_section:
|
2022-04-01 06:25:19 +00:00
|
|
|
homepage.hero_section_doc = frappe.get_cached_doc("Homepage Section", homepage.hero_section)
|
2016-05-12 09:52:59 +00:00
|
|
|
|
2019-03-19 06:18:32 +00:00
|
|
|
if homepage.slideshow:
|
2022-04-01 06:25:19 +00:00
|
|
|
doc = frappe.get_cached_doc("Website Slideshow", homepage.slideshow)
|
2019-03-19 06:18:32 +00:00
|
|
|
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
|
|
|
)
|
2019-03-19 06:18:32 +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 = [
|
2022-04-01 06:25:19 +00:00
|
|
|
frappe.get_cached_doc("Homepage Section", name) for name in homepage_sections
|
2019-03-19 06:18:32 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
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"
|