website cleanups
This commit is contained in:
parent
0549b1c5c9
commit
3f51705ba4
@ -16,8 +16,9 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.parent_website_route:
|
if not self.parent_website_route:
|
||||||
self.parent_website_route = frappe.get_website_route("Item Group",
|
if frappe.db.get_value("Item Group", self.parent_item_group, "show_in_website"):
|
||||||
self.parent_item_group)
|
self.parent_website_route = frappe.get_website_route("Item Group",
|
||||||
|
self.parent_item_group)
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
NestedSet.on_update(self)
|
NestedSet.on_update(self)
|
||||||
|
@ -55,6 +55,11 @@ class website_maker(object):
|
|||||||
"label":"Blog",
|
"label":"Blog",
|
||||||
"url": "blog"
|
"url": "blog"
|
||||||
})
|
})
|
||||||
|
website_settings.append("top_bar_items", {
|
||||||
|
"doctype": "Top Bar Item",
|
||||||
|
"label": _("Products"),
|
||||||
|
"url": frappe.db.get_value("Website Route", {"ref_doctype":"Item Group"})
|
||||||
|
})
|
||||||
website_settings.save()
|
website_settings.save()
|
||||||
|
|
||||||
def make_blog(self):
|
def make_blog(self):
|
||||||
|
@ -11,13 +11,18 @@ def install():
|
|||||||
records = [
|
records = [
|
||||||
|
|
||||||
# item group
|
# item group
|
||||||
{'doctype': 'Item Group', 'item_group_name': _('All Item Groups'), 'is_group': 'Yes', 'parent_item_group': ''},
|
{'doctype': 'Item Group', 'item_group_name': _('All Item Groups'),
|
||||||
{'doctype': 'Item Group', 'item_group_name': _('Products'), 'is_group': 'No',
|
'is_group': 'Yes', 'parent_item_group': ''},
|
||||||
'parent_item_group': _('All Item Groups'), "show_in_website": 1 },
|
{'doctype': 'Item Group', 'item_group_name': _('Products'),
|
||||||
{'doctype': 'Item Group', 'item_group_name': _('Raw Material'), 'is_group': 'No', 'parent_item_group': _('All Item Groups') },
|
'is_group': 'No', 'parent_item_group': _('All Item Groups'), "show_in_website": 1 },
|
||||||
{'doctype': 'Item Group', 'item_group_name': _('Services'), 'is_group': 'No', 'parent_item_group': _('All Item Groups') },
|
{'doctype': 'Item Group', 'item_group_name': _('Raw Material'),
|
||||||
{'doctype': 'Item Group', 'item_group_name': _('Sub Assemblies'), 'is_group': 'No', 'parent_item_group': _('All Item Groups') },
|
'is_group': 'No', 'parent_item_group': _('All Item Groups') },
|
||||||
{'doctype': 'Item Group', 'item_group_name': _('Consumable'), 'is_group': 'No', 'parent_item_group': _('All Item Groups') },
|
{'doctype': 'Item Group', 'item_group_name': _('Services'),
|
||||||
|
'is_group': 'No', 'parent_item_group': _('All Item Groups') },
|
||||||
|
{'doctype': 'Item Group', 'item_group_name': _('Sub Assemblies'),
|
||||||
|
'is_group': 'No', 'parent_item_group': _('All Item Groups') },
|
||||||
|
{'doctype': 'Item Group', 'item_group_name': _('Consumable'),
|
||||||
|
'is_group': 'No', 'parent_item_group': _('All Item Groups') },
|
||||||
|
|
||||||
# deduction type
|
# deduction type
|
||||||
{'doctype': 'Deduction Type', 'name': _('Income Tax'), 'description': _('Income Tax'), 'deduction_name': _('Income Tax')},
|
{'doctype': 'Deduction Type', 'name': _('Income Tax'), 'description': _('Income Tax'), 'deduction_name': _('Income Tax')},
|
||||||
|
@ -22,19 +22,20 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h3 itemprop="name" style="margin-top: 0px;">{{ item_name }}</h3>
|
<!-- <h3 itemprop="name" style="margin-top: 0px;">{{ item_name }}</h3> -->
|
||||||
<p class="help">Item Code: <span itemprop="productID">{{ name }}</span></p>
|
|
||||||
<h4>Product Description</h4>
|
|
||||||
<div itemprop="description">
|
<div itemprop="description">
|
||||||
{{ web_long_description or description or "[No description given]" }}
|
{{ web_long_description or description or _("No description given") }}
|
||||||
</div>
|
</div>
|
||||||
|
<p class="text-muted">
|
||||||
|
{{ _("Item Code") }}: <span itemprop="productID">{{ name }}</span></p>
|
||||||
|
<br>
|
||||||
<div style="min-height: 100px; margin: 10px 0;">
|
<div style="min-height: 100px; margin: 10px 0;">
|
||||||
<div class="item-price-info" style="display: none;">
|
<div class="item-price-info" style="display: none;">
|
||||||
<h4 class="item-price" itemprop="price"></h4>
|
<h4 class="item-price" itemprop="price"></h4>
|
||||||
<div class="item-stock" itemprop="availablity"></div>
|
<div class="item-stock" itemprop="availablity"></div>
|
||||||
<div id="item-add-to-cart">
|
<div id="item-add-to-cart">
|
||||||
<button class="btn btn-primary">
|
<button class="btn btn-primary">
|
||||||
<i class="icon-shopping-cart"></i> Add to Cart</button>
|
<i class="icon-shopping-cart"></i> + {{ _("Add to Cart") }}</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="item-update-cart" class="input-group col-md-4" style="display: none;
|
<div id="item-update-cart" class="input-group col-md-4" style="display: none;
|
||||||
padding-left: 0px; padding-right: 0px;">
|
padding-left: 0px; padding-right: 0px;">
|
||||||
@ -51,7 +52,7 @@
|
|||||||
{% if doc.get({"doctype":"Item Website Specification"}) -%}
|
{% if doc.get({"doctype":"Item Website Specification"}) -%}
|
||||||
<div class="row" style="margin-top: 20px">
|
<div class="row" style="margin-top: 20px">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<h4>Specifications</h4>
|
<h4>{{ _("Specifications") }}</h4>
|
||||||
<table class="table table-bordered" style="width: 100%">
|
<table class="table table-bordered" style="width: 100%">
|
||||||
{% for d in doc.get(
|
{% for d in doc.get(
|
||||||
{"doctype":"Item Website Specification"}) -%}
|
{"doctype":"Item Website Specification"}) -%}
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
{% block title %} {{ title }} {% endblock %}
|
|
||||||
|
|
||||||
{% block header %}<h2>{{ title }}</h2>{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="item-group-content">
|
<div class="item-group-content">
|
||||||
{% include 'templates/includes/product_search_box.html' %}
|
{% include 'templates/includes/product_search_box.html' %}
|
||||||
@ -11,22 +7,9 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if description %}<!-- description -->
|
{% if description %}<!-- description -->
|
||||||
<div itemprop="description">{{ description or ""}}</div>
|
<div itemprop="description">{{ description or ""}}</div>
|
||||||
{% else %}
|
|
||||||
<h3>{{ name }}</h3>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{% if sub_groups %}
|
|
||||||
<hr />
|
|
||||||
<div class="row">
|
|
||||||
{% for d in sub_groups %}
|
|
||||||
<div class="col-sm-4">
|
|
||||||
<a href="{{ d.page_name }}">{{ d.name }} ({{ d.count }})</a>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
<hr />
|
|
||||||
{% endif %}
|
|
||||||
{% if items %}
|
{% if items %}
|
||||||
<div id="search-list" class="row">
|
<div id="search-list" class="row">
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
@ -37,7 +20,7 @@
|
|||||||
<div class="alert alert-info info">Showing top 100 items.</div>
|
<div class="alert alert-info info">Showing top 100 items.</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="alert alert-warning">No items listed.</div>
|
<div class="text-muted">No items listed.</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -53,5 +36,3 @@ $(function() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
|
|
||||||
|
@ -13,9 +13,6 @@ condition_field = "show_in_website"
|
|||||||
def get_context(context):
|
def get_context(context):
|
||||||
item_group_context = context.doc.as_dict()
|
item_group_context = context.doc.as_dict()
|
||||||
item_group_context.update({
|
item_group_context.update({
|
||||||
"sub_groups": frappe.db.sql("""select name, page_name
|
|
||||||
from `tabItem Group` where parent_item_group=%s
|
|
||||||
and ifnull(show_in_website,0)=1""", context.docname, as_dict=1),
|
|
||||||
"items": get_product_list_for_group(product_group = context.docname, limit=100),
|
"items": get_product_list_for_group(product_group = context.docname, limit=100),
|
||||||
"parent_groups": get_parent_item_groups(context.docname),
|
"parent_groups": get_parent_item_groups(context.docname),
|
||||||
"title": context.docname
|
"title": context.docname
|
||||||
@ -24,22 +21,20 @@ def get_context(context):
|
|||||||
if context.doc.slideshow:
|
if context.doc.slideshow:
|
||||||
item_group_context.update(get_slideshow(context.doc))
|
item_group_context.update(get_slideshow(context.doc))
|
||||||
|
|
||||||
for d in item_group_context.get("sub_groups"):
|
|
||||||
d.count = get_group_item_count(d.name)
|
|
||||||
|
|
||||||
return item_group_context
|
return item_group_context
|
||||||
|
|
||||||
def get_product_list_for_group(product_group=None, start=0, limit=10):
|
def get_product_list_for_group(product_group=None, start=0, limit=10):
|
||||||
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)])
|
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)])
|
||||||
|
|
||||||
# base query
|
# base query
|
||||||
query = """select name, item_name, page_name, website_image, item_group,
|
query = """select t1.name, t1.item_name, t1.page_name, t1.website_image, t1.item_group,
|
||||||
web_long_description as website_description
|
t1.web_long_description as website_description, t2.name as route
|
||||||
from `tabItem` where docstatus = 0 and show_in_website = 1
|
from `tabItem` t1, `tabWebsite Route` t2
|
||||||
and (item_group in (%s)
|
where t1.show_in_website = 1 and (item_group in (%s)
|
||||||
or name in (select parent from `tabWebsite Item Group` where item_group in (%s))) """ % (child_groups, child_groups)
|
or t1.name in (select parent from `tabWebsite Item Group` where item_group in (%s)))
|
||||||
|
and t1.name = t2.docname and t2.ref_doctype='Item' """ % (child_groups, child_groups)
|
||||||
|
|
||||||
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
|
query += """order by t1.weightage desc, t1.modified desc limit %s, %s""" % (start, limit)
|
||||||
|
|
||||||
data = frappe.db.sql(query, {"product_group": product_group}, as_dict=1)
|
data = frappe.db.sql(query, {"product_group": product_group}, as_dict=1)
|
||||||
|
|
||||||
|
@ -9,6 +9,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style="height: 100px; overflow: hidden; font-size: 80%;">
|
<div style="height: 100px; overflow: hidden; font-size: 80%;">
|
||||||
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
|
<div style="margin-bottom: 2px;"><a href="{{ route or page_name }}">{{ item_name }}</a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,6 +10,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style="height: 100px; overflow: hidden; font-size: 80%;">
|
<div style="height: 100px; overflow: hidden; font-size: 80%;">
|
||||||
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
|
<div><a href="{{ page_name }}">{{ item_name }}</a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,28 +1,31 @@
|
|||||||
<div style="margin-bottom: 20px;">
|
<script>
|
||||||
<form class="form-inline form-search row">
|
frappe.ready(function() {
|
||||||
<div class="input-group col-md-4 col-md-offset-8">
|
$(".product-search").remove();
|
||||||
<input class="form-control" type="text" id="product-search" placeholder="Product Search...">
|
|
||||||
<span class="input-group-btn">
|
$('<div class="product-search">\
|
||||||
<button class="btn btn-default" type="button" id="btn-product-search">
|
<form class="form-inline form-search">\
|
||||||
<i class="icon-search"></i></button>
|
<div class="input-group">\
|
||||||
</span>
|
<input class="form-control" type="text" id="product-search" placeholder="Product Search...">\
|
||||||
</div>
|
<span class="input-group-btn">\
|
||||||
</form>
|
<button class="btn btn-default" type="button" id="btn-product-search">\
|
||||||
<script>
|
<i class="icon-search"></i></button>\
|
||||||
// redirect to product search page
|
</span>\
|
||||||
frappe.ready(function() {
|
</div>\
|
||||||
$('.dropdown-toggle').dropdown();
|
</form>\
|
||||||
$("#btn-product-search").click(function() {
|
</div>').appendTo(".page-header-right");
|
||||||
var txt = $("#product-search").val();
|
|
||||||
if(txt) {
|
$('.dropdown-toggle').dropdown();
|
||||||
window.location.href="product_search?q=" + txt;
|
$("#btn-product-search").click(function() {
|
||||||
}
|
var txt = $("#product-search").val();
|
||||||
return false;
|
if(txt) {
|
||||||
});
|
window.location.href="product_search?q=" + txt;
|
||||||
$("#product-search").keypress(function(e) {
|
}
|
||||||
if(e.which==13) $("#btn-product-search").click();
|
return false;
|
||||||
});
|
});
|
||||||
$(".form-search").on("submit", function() { return false; });
|
$("#product-search").keypress(function(e) {
|
||||||
});
|
if(e.which==13) $("#btn-product-search").click();
|
||||||
</script>
|
});
|
||||||
</div>
|
$(".form-search").on("submit", function() { return false; });
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@ -12,18 +12,19 @@ no_sitemap = 1
|
|||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_product_list(search=None, start=0, limit=10):
|
def get_product_list(search=None, start=0, limit=10):
|
||||||
# base query
|
# base query
|
||||||
query = """select name, item_name, page_name, website_image, item_group,
|
query = """select t1.name, t1.item_name, t1.page_name, t1.website_image, t1.item_group,
|
||||||
web_long_description as website_description
|
t1.web_long_description as website_description, t2.name as route
|
||||||
from `tabItem` where docstatus = 0 and show_in_website = 1 """
|
from `tabItem` t1, `tabWebsite Route` t2 where t1.show_in_website = 1
|
||||||
|
and t1.name = t2.docname and t2.ref_doctype = 'Item'"""
|
||||||
|
|
||||||
# search term condition
|
# search term condition
|
||||||
if search:
|
if search:
|
||||||
query += """and (web_long_description like %(search)s or
|
query += """and (t1.web_long_description like %(search)s or t1.description like %(search)s or
|
||||||
item_name like %(search)s or name like %(search)s)"""
|
t1.item_name like %(search)s or t1.name like %(search)s)"""
|
||||||
search = "%" + cstr(search) + "%"
|
search = "%" + cstr(search) + "%"
|
||||||
|
|
||||||
# order by
|
# order by
|
||||||
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
|
query += """order by t1.weightage desc, t1.modified desc limit %s, %s""" % (start, limit)
|
||||||
|
|
||||||
data = frappe.db.sql(query, {
|
data = frappe.db.sql(query, {
|
||||||
"search": search,
|
"search": search,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user