[cleanup] homepage

This commit is contained in:
Rushabh Mehta 2016-05-12 15:22:59 +05:30
parent 825070e504
commit 4b9238a03b
24 changed files with 172 additions and 157 deletions

View File

@ -264,3 +264,4 @@ erpnext.patches.v7_0.update_party_status
erpnext.patches.v7_0.update_item_projected erpnext.patches.v7_0.update_item_projected
erpnext.patches.v7_0.fix_duplicate_icons erpnext.patches.v7_0.fix_duplicate_icons
erpnext.patches.v7_0.remove_features_setup erpnext.patches.v7_0.remove_features_setup
erpnext.patches.v7_0.update_home_page

View File

@ -1,11 +1,13 @@
import frappe import frappe
from erpnext.setup.install import create_compact_item_print_custom_field from erpnext.setup.install import create_compact_item_print_custom_field
from frappe.utils import cint
def execute(): def execute():
if not frappe.db.get_value("Features Setup", None, "fs_item_barcode"): frappe.reload_doctype('Stock Settings')
# hide barcode fields stock_settings = frappe.get_doc('Stock Settings', 'Stock Settings')
frappe.make_property_setter(dict(fieldname='barcode', property='hidden', value=1)) stock_settings.show_barcode_field = cint(frappe.db.get_value("Features Setup", None, "fs_item_barcode"))
stock_settings.save()
create_compact_item_print_custom_field() create_compact_item_print_custom_field()

View File

@ -0,0 +1,18 @@
import frappe
import erpnext
def execute():
website_settings = frappe.get_doc('Website Settings', 'Website Settings')
if frappe.db.exists('Web Page', website_settings.home_page):
header = frappe.db.get_value('Web Page', website_settings.home_page, 'header')
print header
if header and header.startswith("<div class='hero text-center'>"):
homepage = frappe.get_doc('Homepage', 'Homepage')
homepage.company = erpnext.get_default_company()
homepage.tagline = header.split('<h1>')[1].split('</h1>')[0]
homepage.setup_items()
homepage.save()
website_settings.home_page = 'home'
website_settings.save()

View File

@ -135,7 +135,7 @@
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0, "unique": 0,
@ -151,7 +151,7 @@
"issingle": 1, "issingle": 1,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-05-02 18:03:13.165280", "modified": "2016-05-12 14:19:41.689519",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Portal", "module": "Portal",
"name": "Homepage", "name": "Homepage",

View File

@ -7,4 +7,19 @@ import frappe
from frappe.model.document import Document from frappe.model.document import Document
class Homepage(Document): class Homepage(Document):
pass def validate(self):
if not self.products:
self.setup_items()
if not self.description:
self.description = frappe._("This is an example website auto-generated from ERPNext")
def setup_items(self):
for d in frappe.get_all('Item', fields=['name', 'item_name', 'description', 'image'],
filters={'show_in_website': 1}, limit=3):
# set missing routes (?)
doc = frappe.get_doc('Item', d.name)
doc.save()
self.append('products', dict(item_code=d.name,
item_name=d.item_name, description=d.description, image=d.image))

View File

@ -23,7 +23,8 @@
background-size: cover; background-size: cover;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center top; background-position: center top;
border-radius: 4px; border-radius-top: 4px;
border-radius-right: 4px;
} }
.product-image.missing-image { .product-image.missing-image {
width: 100%; width: 100%;
@ -32,7 +33,8 @@
background-size: cover; background-size: cover;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center top; background-position: center top;
border-radius: 4px; border-radius-top: 4px;
border-radius-right: 4px;
position: relative; position: relative;
background-color: #EBEFF2; background-color: #EBEFF2;
} }
@ -124,6 +126,12 @@
border-top: 1px solid #d1d8dd; border-top: 1px solid #d1d8dd;
padding-top: 15px; padding-top: 15px;
} }
.order-container .tax-grand-total {
display: inline-block;
font-size: 16px;
font-weight: bold;
margin-top: 5px;
}
.cart-container { .cart-container {
margin: 50px 0px; margin: 50px 0px;
} }
@ -228,7 +236,7 @@
height: 75px; height: 75px;
} }
.product-image-wrapper { .product-image-wrapper {
padding-bottom: 30px; padding-bottom: 40px;
} }
.featured-product-heading, .featured-product-heading,
.all-products { .all-products {

View File

@ -32,7 +32,8 @@
background-size: cover; background-size: cover;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center top; background-position: center top;
border-radius: 4px; border-radius-top: 4px;
border-radius-right: 4px;
} }
.product-image.missing-image { .product-image.missing-image {
@ -157,6 +158,13 @@
border-top: 1px solid @border-color; border-top: 1px solid @border-color;
padding-top: 15px; padding-top: 15px;
} }
.tax-grand-total {
display: inline-block;
font-size: 16px;
font-weight: bold;
margin-top: 5px;
}
} }
.cart-container { .cart-container {
@ -294,7 +302,7 @@
} }
.product-image-wrapper { .product-image-wrapper {
padding-bottom: 30px; padding-bottom: 40px;
} }

View File

@ -74,7 +74,7 @@ def get_product_list_for_group(product_group=None, start=0, limit=10, search=Non
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, item_code, page_name, website_image, thumbnail, item_group, query = """select name, item_name, item_code, page_name, image, website_image, thumbnail, item_group,
description, web_long_description as website_description, description, web_long_description as website_description,
concat(parent_website_route, "/", page_name) as route concat(parent_website_route, "/", page_name) as route
from `tabItem` from `tabItem`

View File

@ -22,7 +22,7 @@
<ul class="list-unstyled"> <ul class="list-unstyled">
<li><a class="text-muted" href="#">{%= __("Go to the Desktop and start using ERPNext") %}</a></li> <li><a class="text-muted" href="#">{%= __("Go to the Desktop and start using ERPNext") %}</a></li>
<li><a class="text-muted" href="#modules/Learn">{%= __("View a list of all the help videos") %}</a></li> <li><a class="text-muted" href="#modules/Learn">{%= __("View a list of all the help videos") %}</a></li>
<li><a class="text-muted" href="https://manual.erpnext.com" target="_blank">{%= __("Read the ERPNext Manual") %}</a></li> <li><a class="text-muted" href="https://frappe.github.io/erpnext/user" target="_blank">{%= __("Read the ERPNext Manual") %}</a></li>
<li><a class="text-muted" href="https://discuss.erpnext.com" target="_blank">{%= __("Community Forum") %}</a></li> <li><a class="text-muted" href="https://discuss.erpnext.com" target="_blank">{%= __("Community Forum") %}</a></li>
</ul> </ul>

View File

@ -1,40 +0,0 @@
.page-header {
color: white;
background: #263248;
text-align: center;
padding: 80px 0px;
}
.page-header .page-header-left {
width: 100%;
}
.page-header h1 {
color: white;
}
.slide h2 {
margin-bottom: 30px;
}
.slides {
margin-top: -15px;
}
.slide {
padding: 30px 40px;
max-width: 800px;
margin: auto;
}
.container {
max-width: 900px;
}
.img-wrapper {
text-align: center;
padding: 30px;
background-color: #eee;
border-radius: 5px;
margin-bottom: 15px;
}

View File

@ -1,28 +0,0 @@
<div class="slides">
<div class="row slide">
<h2 class="text-center">{{ _("Awesome Products") }}</h2>
<div class="col-md-6 text-center">
<div class="img-wrapper">
<i class="icon-wrench text-muted" style="font-size: 100px;"></i>
</div>
</div>
<div class="col-md-6">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<div class="row slide alt">
<h2 class="text-center">{{ _("Awesome Services") }}</h2>
<div class="col-md-6 text-center">
<div class="img-wrapper">
<i class="icon-phone text-muted" style="font-size: 100px;"></i>
</div>
</div>
<div class="col-md-6">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
<p class="text-center" style="margin-bottom: 50px;">
<a href="/products" class="btn btn-success">Explore <i class="icon-chevron-right"></i></a>
</p>
<!-- no-sidebar -->

View File

@ -8,34 +8,27 @@ from frappe import _
from frappe.utils import nowdate from frappe.utils import nowdate
class website_maker(object): class website_maker(object):
def __init__(self, company, tagline, user): def __init__(self, args):
self.company = company self.args = args
self.tagline = tagline self.company = args.company_name
self.user = user self.tagline = args.company_tagline
self.user = args.name
self.make_web_page() self.make_web_page()
self.make_website_settings() self.make_website_settings()
self.make_blog() self.make_blog()
def make_web_page(self): def make_web_page(self):
# home page # home page
self.webpage = frappe.get_doc({ homepage = frappe.get_doc('Homepage', 'Homepage')
"doctype": "Web Page", homepage.company = self.company
"title": self.company, homepage.tag_line = self.tagline
"published": 1, homepage.setup_items()
"header": "<div class='hero text-center'><h1>{0}</h1>".format(self.tagline or "Headline")+\ homepage.save()
'<p>'+_("This is an example website auto-generated from ERPNext")+"</p>"+\
'<p><a class="btn btn-primary" href="/login">Login</a></p></div>',
"description": self.company + ":" + (self.tagline or ""),
"css": frappe.get_template("setup/setup_wizard/data/sample_home_page.css").render(),
"main_section": frappe.get_template("setup/setup_wizard/data/sample_home_page.html").render({
"company": self.company, "tagline": (self.tagline or "")
})
}).insert()
def make_website_settings(self): def make_website_settings(self):
# update in home page in settings # update in home page in settings
website_settings = frappe.get_doc("Website Settings", "Website Settings") website_settings = frappe.get_doc("Website Settings", "Website Settings")
website_settings.home_page = self.webpage.name website_settings.home_page = 'home'
website_settings.brand_html = self.company website_settings.brand_html = self.company
website_settings.copyright = self.company website_settings.copyright = self.company
website_settings.top_bar_items = [] website_settings.top_bar_items = []
@ -88,5 +81,5 @@ def test():
frappe.delete_doc("Blog Post", "welcome") frappe.delete_doc("Blog Post", "welcome")
frappe.delete_doc("Blogger", "administrator") frappe.delete_doc("Blogger", "administrator")
frappe.delete_doc("Blog Category", "general") frappe.delete_doc("Blog Category", "general")
website_maker("Test Company", "Better Tools for Everyone", "Administrator") website_maker({'company':"Test Company", 'company_tagline': "Better Tools for Everyone", 'name': "Administrator"})
frappe.db.commit() frappe.db.commit()

View File

@ -22,7 +22,9 @@ domains = {
'remove_roles': ['Manufacturing User', 'Manufacturing Manager', 'Maintenance User'], 'remove_roles': ['Manufacturing User', 'Manufacturing Manager', 'Maintenance User'],
'properties': [ 'properties': [
{'doctype': 'Item', 'fieldname': 'is_stock_item', 'property': 'default', 'value': 0}, {'doctype': 'Item', 'fieldname': 'is_stock_item', 'property': 'default', 'value': 0},
{'fieldname': 'barcode', 'property': 'hidden', 'value': 1} ],
'set_value': [
['Stock Settings', 'show_barcode', 0]
] ]
} }
} }

View File

@ -35,7 +35,7 @@ def setup_complete(args=None):
frappe.local.message_log = [] frappe.local.message_log = []
setup_domain(args.get('domain')) setup_domain(args.get('domain'))
website_maker(args.company_name.strip(), args.company_tagline, args.name) website_maker(args)
create_logo(args) create_logo(args)
frappe.db.commit() frappe.db.commit()

View File

@ -144,22 +144,22 @@ class Item(WebsiteGenerator):
return return
# find if website image url exists as public # find if website image url exists as public
file = frappe.get_all("File", filters={ file_doc = frappe.get_all("File", filters={
"file_url": self.website_image "file_url": self.website_image
}, fields=["name", "is_private"], order_by="is_private asc", limit_page_length=1) }, fields=["name", "is_private"], order_by="is_private asc", limit_page_length=1)
if file: if file_doc:
file = file[0] file_doc = file_doc[0]
if not file: if not file_doc:
if not auto_set_website_image: if not auto_set_website_image:
frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found") frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found")
.format(self.website_image, self.name)) .format(self.website_image, self.name))
self.website_image = None self.website_image = None
elif file.is_private: elif file_doc.is_private:
if not auto_set_website_image: if not auto_set_website_image:
frappe.msgprint(_("Website Image should be a public file or website URL")) frappe.msgprint(_("Website Image should be a public file or website URL"))

View File

@ -2,6 +2,7 @@
"allow_copy": 0, "allow_copy": 0,
"allow_import": 0, "allow_import": 0,
"allow_rename": 0, "allow_rename": 0,
"beta": 0,
"creation": "2013-06-24 16:37:54", "creation": "2013-06-24 16:37:54",
"custom": 0, "custom": 0,
"description": "Settings", "description": "Settings",
@ -184,6 +185,32 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"default": "1",
"fieldname": "show_barcode_field",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Show Barcode Field",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -487,7 +514,7 @@
"issingle": 1, "issingle": 1,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-04-15 06:51:47.497431", "modified": "2016-05-12 12:28:29.374452",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Stock Settings", "name": "Stock Settings",
@ -517,5 +544,6 @@
"quick_entry": 1, "quick_entry": 1,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"sort_order": "ASC",
"track_seen": 0 "track_seen": 0
} }

View File

@ -6,11 +6,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
from frappe.utils import cint
from frappe.model.document import Document from frappe.model.document import Document
class StockSettings(Document): class StockSettings(Document):
def validate(self): def validate(self):
for key in ["item_naming_by", "item_group", "stock_uom", "allow_negative_stock"]: for key in ["item_naming_by", "item_group", "stock_uom", "allow_negative_stock"]:
frappe.db.set_default(key, self.get(key, "")) frappe.db.set_default(key, self.get(key, ""))
@ -25,4 +23,6 @@ class StockSettings(Document):
self.stock_frozen_upto_days = stock_frozen_limit self.stock_frozen_upto_days = stock_frozen_limit
frappe.msgprint (_("`Freeze Stocks Older Than` should be smaller than %d days.") %stock_frozen_limit) frappe.msgprint (_("`Freeze Stocks Older Than` should be smaller than %d days.") %stock_frozen_limit)
# show/hide barcode field
frappe.make_property_setter({'fieldname': 'barcode', 'property': 'hidden',
'value': 0 if self.show_barcode_field else 1})

View File

@ -9,7 +9,7 @@
</div> </div>
<div class="col-xs-8 col-sm-10"> <div class="col-xs-8 col-sm-10">
{{ d.item_code }} {{ d.item_code }}
<p class="text-muted small item-description">{{ d.description }}</p> <div class="text-muted small item-description">{{ d.description }}</div>
</div> </div>
</div> </div>

View File

@ -13,9 +13,9 @@
</div> </div>
{% endfor %} {% endfor %}
<div class="row tax-grand-total-row"> <div class="row tax-grand-total-row">
<div class="col-xs-8 text-right">{{ _("Grand Total") }}</div> <div class="col-xs-8 text-right text-uppercase h6 text-muted">{{ _("Grand Total") }}</div>
<div class="col-xs-4 text-right"> <div class="col-xs-4 text-right">
<span class="tax-grand-total"> <span class="tax-grand-total bold">
{{ doc.get_formatted("grand_total") }} {{ doc.get_formatted("grand_total") }}
</span> </span>
</div> </div>

View File

@ -12,7 +12,7 @@
<div class="col-sm-4 items-preview text-ellipsis"> <div class="col-sm-4 items-preview text-ellipsis">
{{ doc.items_preview }} {{ doc.items_preview }}
</div> </div>
<div class="col-sm-3 text-right"> <div class="col-sm-3 text-right bold">
{{ doc.get_formatted("grand_total") }} {{ doc.get_formatted("grand_total") }}
</div> </div>
<!-- <div class="col-sm-3 text-right"> <!-- <div class="col-sm-3 text-right">

View File

@ -27,7 +27,7 @@
</div> </div>
</div> </div>
<!-- TODO: remove hardcoding of /products --> <!-- TODO: remove hardcoding of /products -->
<div class=" text-center text-uppercase"><a href="/products" class="btn btn-primary all-products"> {{ _("View All Products") }}</a></div> <div class="text-center"><a href="/products" class="btn btn-primary all-products"> {{ _("View All Products") }}</a></div>
</div> </div>
{% endif %} {% endif %}
</div> </div>

View File

@ -3,8 +3,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr, nowdate
from erpnext.setup.doctype.item_group.item_group import get_item_for_list_in_html
no_cache = 1 no_cache = 1
no_sitemap = 1 no_sitemap = 1
@ -13,8 +11,18 @@ def get_context(context):
homepage = frappe.get_doc('Homepage') homepage = frappe.get_doc('Homepage')
for item in homepage.products: for item in homepage.products:
item.route = '/' + '/'.join(frappe.db.get_value('Item', item.item_code, ['parent_website_route', 'page_name'])) parent_website_route, page_name = frappe.db.get_value('Item', item.item_code,
['parent_website_route', 'page_name'])
item.route = '/' + '/'.join(filter(None, [parent_website_route, page_name]))
# show atleast 3 products
if len(homepage.products) < 3:
for i in xrange(3 - len(homepage.products)):
homepage.append('products', {
'item_code': 'product-{0}'.format(i),
'item_name': frappe._('Product {0}').format(i),
'route': '#'
})
return { return {
'homepage': homepage 'homepage': homepage

View File

@ -59,7 +59,7 @@
<div class="col-sm-2 col-xs-3 text-right"> <div class="col-sm-2 col-xs-3 text-right">
{{ d.get_formatted("amount") }} {{ d.get_formatted("amount") }}
<p class="text-muted small">{{ <p class="text-muted small">{{
_("Rate: {0}").format(d.get_formatted("rate")) }}</p> _("@ {0}").format(d.get_formatted("rate")) }}</p>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}