[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.fix_duplicate_icons
erpnext.patches.v7_0.remove_features_setup
erpnext.patches.v7_0.update_home_page

View File

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

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

View File

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

View File

@ -32,7 +32,8 @@
background-size: cover;
background-repeat: no-repeat;
background-position: center top;
border-radius: 4px;
border-radius-top: 4px;
border-radius-right: 4px;
}
.product-image.missing-image {
@ -157,6 +158,13 @@
border-top: 1px solid @border-color;
padding-top: 15px;
}
.tax-grand-total {
display: inline-block;
font-size: 16px;
font-weight: bold;
margin-top: 5px;
}
}
.cart-container {
@ -294,7 +302,7 @@
}
.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)])
# 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,
concat(parent_website_route, "/", page_name) as route
from `tabItem`

View File

@ -22,7 +22,7 @@
<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="#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>
</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
class website_maker(object):
def __init__(self, company, tagline, user):
self.company = company
self.tagline = tagline
self.user = user
def __init__(self, args):
self.args = args
self.company = args.company_name
self.tagline = args.company_tagline
self.user = args.name
self.make_web_page()
self.make_website_settings()
self.make_blog()
def make_web_page(self):
# home page
self.webpage = frappe.get_doc({
"doctype": "Web Page",
"title": self.company,
"published": 1,
"header": "<div class='hero text-center'><h1>{0}</h1>".format(self.tagline or "Headline")+\
'<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()
homepage = frappe.get_doc('Homepage', 'Homepage')
homepage.company = self.company
homepage.tag_line = self.tagline
homepage.setup_items()
homepage.save()
def make_website_settings(self):
# update in home page in 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.copyright = self.company
website_settings.top_bar_items = []
@ -88,5 +81,5 @@ def test():
frappe.delete_doc("Blog Post", "welcome")
frappe.delete_doc("Blogger", "administrator")
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()

View File

@ -22,7 +22,9 @@ domains = {
'remove_roles': ['Manufacturing User', 'Manufacturing Manager', 'Maintenance User'],
'properties': [
{'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 = []
setup_domain(args.get('domain'))
website_maker(args.company_name.strip(), args.company_tagline, args.name)
website_maker(args)
create_logo(args)
frappe.db.commit()

View File

@ -144,22 +144,22 @@ class Item(WebsiteGenerator):
return
# 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
}, fields=["name", "is_private"], order_by="is_private asc", limit_page_length=1)
if file:
file = file[0]
if file_doc:
file_doc = file_doc[0]
if not file:
if not file_doc:
if not auto_set_website_image:
frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found")
.format(self.website_image, self.name))
self.website_image = None
elif file.is_private:
elif file_doc.is_private:
if not auto_set_website_image:
frappe.msgprint(_("Website Image should be a public file or website URL"))

View File

@ -2,6 +2,7 @@
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2013-06-24 16:37:54",
"custom": 0,
"description": "Settings",
@ -184,6 +185,32 @@
"set_only_once": 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,
"bold": 0,
@ -487,7 +514,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2016-04-15 06:51:47.497431",
"modified": "2016-05-12 12:28:29.374452",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Settings",
@ -517,5 +544,6 @@
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"sort_order": "ASC",
"track_seen": 0
}

View File

@ -6,11 +6,9 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import cint
from frappe.model.document import Document
class StockSettings(Document):
def validate(self):
for key in ["item_naming_by", "item_group", "stock_uom", "allow_negative_stock"]:
frappe.db.set_default(key, self.get(key, ""))
@ -25,4 +23,6 @@ class StockSettings(Document):
self.stock_frozen_upto_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 class="col-xs-8 col-sm-10">
{{ 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>

View File

@ -13,9 +13,9 @@
</div>
{% endfor %}
<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">
<span class="tax-grand-total">
<span class="tax-grand-total bold">
{{ doc.get_formatted("grand_total") }}
</span>
</div>

View File

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

View File

@ -27,7 +27,7 @@
</div>
</div>
<!-- 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>
{% endif %}
</div>

View File

@ -3,8 +3,6 @@
from __future__ import unicode_literals
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_sitemap = 1
@ -13,8 +11,18 @@ def get_context(context):
homepage = frappe.get_doc('Homepage')
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 {
'homepage': homepage

View File

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