Example #1
0
def get_website_settings(context=None):
	hooks = frappe.get_hooks()
	context = context or frappe._dict()
	context = context.update({
		'top_bar_items': get_items('top_bar_items'),
		'footer_items': get_items('footer_items'),
		"post_login": [
			{"label": _("My Account"), "url": "/me"},
			{"label": _("Logout"), "url": "/?cmd=web_logout"}
		]
	})

	settings = frappe.get_single("Website Settings")
	for k in ["banner_html", "banner_image", "brand_html", "copyright", "twitter_share_via",
		"facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup", "hide_footer_signup", "head_html", "title_prefix",
		"navbar_search", "enable_view_tracking", "footer_logo", "call_to_action", "call_to_action_url"]:
		if hasattr(settings, k):
			context[k] = settings.get(k)

	if settings.address:
		context["footer_address"] = settings.address

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		context[k] = int(context.get(k) or 0)

	if frappe.request:
		context.url = quote(str(get_request_site_address(full_address=True)), safe="/:")

	context.encoded_title = quote(encode(context.title or ""), str(""))

	for update_website_context in hooks.update_website_context or []:
		frappe.get_attr(update_website_context)(context)

	context.web_include_js = hooks.web_include_js or []

	context.web_include_css = hooks.web_include_css or []

	via_hooks = frappe.get_hooks("website_context")
	for key in via_hooks:
		context[key] = via_hooks[key]
		if key not in ("top_bar_items", "footer_items", "post_login") \
			and isinstance(context[key], (list, tuple)):
			context[key] = context[key][-1]

	add_website_theme(context)

	if not context.get("favicon"):
		context["favicon"] = "/assets/frappe/images/favicon.png"

	if settings.favicon and settings.favicon != "attach_files:":
		context["favicon"] = settings.favicon

	context["hide_login"] = settings.hide_login

	return context
Example #2
0
def get_website_settings():
	hooks = frappe.get_hooks()
	context = frappe._dict({
		'top_bar_items': get_items('top_bar_items'),
		'footer_items': get_items('footer_items'),
		"post_login": [
			{"label": _("My Account"), "url": "/me"},
#			{"class": "divider"},
			{"label": _("Logout"), "url": "/?cmd=web_logout"}
		]
	})

	settings = frappe.get_single("Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
		"facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup", "hide_footer_signup", "head_html", "title_prefix",
		"navbar_search"]:
		if hasattr(settings, k):
			context[k] = settings.get(k)

	if settings.address:
		context["footer_address"] = settings.address

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		context[k] = int(context.get(k) or 0)

	if frappe.request:
		context.url = quote(str(get_request_site_address(full_address=True)), safe="/:")

	context.encoded_title = quote(encode(context.title or ""), str(""))

	for update_website_context in hooks.update_website_context or []:
		frappe.get_attr(update_website_context)(context)

	context.web_include_js = hooks.web_include_js or []

	context.web_include_css = hooks.web_include_css or []

	via_hooks = frappe.get_hooks("website_context")
	for key in via_hooks:
		context[key] = via_hooks[key]
		if key not in ("top_bar_items", "footer_items", "post_login") \
			and isinstance(context[key], (list, tuple)):
			context[key] = context[key][-1]

	add_website_theme(context)

	if not context.get("favicon"):
		context["favicon"] = "/assets/frappe/images/favicon.png"

	if settings.favicon and settings.favicon != "attach_files:":
		context["favicon"] = settings.favicon

	return context
Example #3
0
def get_website_settings():
	hooks = frappe.get_hooks()

	all_top_items = frappe.db.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""", as_dict=1)

	top_items = [d for d in all_top_items if not d['parent_label']]

	# attach child items to top bar
	for d in all_top_items:
		if d['parent_label']:
			for t in top_items:
				if t['label']==d['parent_label']:
					if not 'child_items' in t:
						t['child_items'] = []
					t['child_items'].append(d)
					break

	context = frappe._dict({
		'top_bar_items': top_items,
		'footer_items': frappe.db.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""", as_dict=1),
		"post_login": [
			{"label": "My Account", "url": "/me"},
			{"class": "divider"},
			{"label": "Logout", "url": "/?cmd=web_logout"}
		]
	})

	settings = frappe.get_doc("Website Settings", "Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
		"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup", "hide_footer_signup"]:
		if hasattr(settings, k):
			context[k] = settings.get(k)

	if settings.address:
		context["footer_address"] = settings.address

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		context[k] = int(context.get(k) or 0)

	if frappe.request:
		context.url = quote(str(get_request_site_address(full_address=True)), safe="/:")

	context.encoded_title = quote(encode(context.title or ""), str(""))

	for update_website_context in hooks.update_website_context or []:
		frappe.get_attr(update_website_context)(context)

	context.web_include_js = hooks.web_include_js or []

	context.web_include_css = hooks.web_include_css or []

	add_website_theme(context)

	via_hooks = frappe.get_hooks("website_context")
	for key in via_hooks:
		context[key] = via_hooks[key]
		if key not in ("top_bar_items", "footer_items", "post_login") \
			and isinstance(context[key], (list, tuple)):
			context[key] = context[key][0]

	if not context.get("favicon"):
		context["favicon"] = "/assets/frappe/images/favicon.png"

	return context
Example #4
0
	for update_website_context in hooks.update_website_context or []:
		frappe.get_attr(update_website_context)(context)

	context.web_include_js = hooks.web_include_js or []

	context.web_include_css = hooks.web_include_css or []

	via_hooks = frappe.get_hooks("website_context")
	for key in via_hooks:
		context[key] = via_hooks[key]
		if key not in ("top_bar_items", "footer_items", "post_login") \
			and isinstance(context[key], (list, tuple)):
			context[key] = context[key][-1]

	add_website_theme(context)

	if not context.get("favicon"):
		context["favicon"] = "/assets/frappe/images/favicon.png"

	if settings.favicon and settings.favicon != "attach_files:":
		context["favicon"] = settings.favicon

	return context

def get_items(parentfield):
	all_top_items = frappe.db.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield= %s
		order by idx asc""", parentfield, as_dict=1)
Example #5
0
def get_website_settings():
    hooks = frappe.get_hooks()

    all_top_items = frappe.db.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""",
                                  as_dict=1)

    top_items = [d for d in all_top_items if not d['parent_label']]

    # attach child items to top bar
    for d in all_top_items:
        if d['parent_label']:
            for t in top_items:
                if t['label'] == d['parent_label']:
                    if not 'child_items' in t:
                        t['child_items'] = []
                    t['child_items'].append(d)
                    break

    context = frappe._dict({
        'top_bar_items':
        top_items,
        'footer_items':
        frappe.db.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""",
                      as_dict=1),
        "post_login": [{
            "label": "My Account",
            "url": "/me"
        }, {
            "class": "divider"
        }, {
            "label": "Logout",
            "url": "/?cmd=web_logout"
        }]
    })

    settings = frappe.get_doc("Website Settings", "Website Settings")
    for k in [
            "banner_html", "brand_html", "copyright", "twitter_share_via",
            "facebook_share", "google_plus_one", "twitter_share",
            "linked_in_share", "disable_signup", "hide_footer_signup",
            "head_html"
    ]:
        if hasattr(settings, k):
            context[k] = settings.get(k)

    if settings.address:
        context["footer_address"] = settings.address

    for k in [
            "facebook_share", "google_plus_one", "twitter_share",
            "linked_in_share", "disable_signup"
    ]:
        context[k] = int(context.get(k) or 0)

    if frappe.request:
        context.url = quote(str(get_request_site_address(full_address=True)),
                            safe="/:")

    context.encoded_title = quote(encode(context.title or ""), str(""))

    for update_website_context in hooks.update_website_context or []:
        frappe.get_attr(update_website_context)(context)

    context.web_include_js = hooks.web_include_js or []

    context.web_include_css = hooks.web_include_css or []

    via_hooks = frappe.get_hooks("website_context")
    for key in via_hooks:
        context[key] = via_hooks[key]
        if key not in ("top_bar_items", "footer_items", "post_login") \
         and isinstance(context[key], (list, tuple)):
            context[key] = context[key][0]

    add_website_theme(context)

    if not context.get("favicon"):
        context["favicon"] = "/assets/frappe/images/favicon.png"

    if settings.favicon and settings.favicon != "attach_files:":
        context["favicon"] = settings.favicon

    return context