[website] [minor] moving to framework

This commit is contained in:
Rushabh Mehta
2013-09-09 12:17:45 +05:30
parent 46089dbc97
commit c59c4e0699
40 changed files with 49 additions and 61 deletions

View File

@@ -1,462 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
import webnotes.defaults
from webnotes.utils import flt, get_fullname, fmt_money, cstr
class WebsitePriceListMissingError(webnotes.ValidationError): pass
def set_cart_count(quotation=None):
if not quotation:
quotation = _get_cart_quotation()
webnotes.add_cookies["cart_count"] = cstr(len(quotation.doclist.get(
{"parentfield": "quotation_details"})) or "")
@webnotes.whitelist()
def get_cart_quotation(doclist=None):
party = get_lead_or_customer()
if not doclist:
quotation = _get_cart_quotation(party)
doclist = quotation.doclist
set_cart_count(quotation)
return {
"doclist": decorate_quotation_doclist(doclist),
"addresses": [{"name": address.name, "display": address.display}
for address in get_address_docs(party)],
"shipping_rules": get_applicable_shipping_rules(party)
}
@webnotes.whitelist()
def place_order():
quotation = _get_cart_quotation()
controller = quotation.make_controller()
for fieldname in ["customer_address", "shipping_address_name"]:
if not quotation.doc.fields.get(fieldname):
msgprint(_("Please select a") + " " + _(controller.meta.get_label(fieldname)), raise_exception=True)
quotation.ignore_permissions = True
quotation.submit()
from selling.doctype.quotation.quotation import _make_sales_order
sales_order = webnotes.bean(_make_sales_order(quotation.doc.name, ignore_permissions=True))
sales_order.ignore_permissions = True
sales_order.insert()
sales_order.submit()
webnotes.add_cookies["cart_count"] = ""
return sales_order.doc.name
@webnotes.whitelist()
def update_cart(item_code, qty, with_doclist=0):
quotation = _get_cart_quotation()
qty = flt(qty)
if qty == 0:
quotation.set_doclist(quotation.doclist.get({"item_code": ["!=", item_code]}))
if not quotation.doclist.get({"parentfield": "quotation_details"}) and \
not quotation.doc.fields.get("__islocal"):
quotation.__delete = True
else:
quotation_items = quotation.doclist.get({"item_code": item_code})
if not quotation_items:
quotation.doclist.append({
"doctype": "Quotation Item",
"parentfield": "quotation_details",
"item_code": item_code,
"qty": qty
})
else:
quotation_items[0].qty = qty
apply_cart_settings(quotation=quotation)
if hasattr(quotation, "__delete"):
webnotes.delete_doc("Quotation", quotation.doc.name, ignore_permissions=True)
quotation = _get_cart_quotation()
else:
quotation.ignore_permissions = True
quotation.save()
set_cart_count(quotation)
if with_doclist:
return get_cart_quotation(quotation.doclist)
else:
return quotation.doc.name
@webnotes.whitelist()
def update_cart_address(address_fieldname, address_name):
from utilities.transaction_base import get_address_display
quotation = _get_cart_quotation()
address_display = get_address_display(webnotes.doc("Address", address_name).fields)
if address_fieldname == "shipping_address_name":
quotation.doc.shipping_address_name = address_name
quotation.doc.shipping_address = address_display
if not quotation.doc.customer_address:
address_fieldname == "customer_address"
if address_fieldname == "customer_address":
quotation.doc.customer_address = address_name
quotation.doc.address_display = address_display
apply_cart_settings(quotation=quotation)
quotation.ignore_permissions = True
quotation.save()
return get_cart_quotation(quotation.doclist)
@webnotes.whitelist()
def get_addresses():
return [d.fields for d in get_address_docs()]
@webnotes.whitelist()
def save_address(fields, address_fieldname=None):
party = get_lead_or_customer()
fields = webnotes.load_json(fields)
if fields.get("name"):
bean = webnotes.bean("Address", fields.get("name"))
else:
bean = webnotes.bean({"doctype": "Address", "__islocal": 1})
bean.doc.fields.update(fields)
party_fieldname = party.doctype.lower()
bean.doc.fields.update({
party_fieldname: party.name,
(party_fieldname + "_name"): party.fields[party_fieldname + "_name"]
})
bean.ignore_permissions = True
bean.save()
if address_fieldname:
update_cart_address(address_fieldname, bean.doc.name)
return bean.doc.name
def get_address_docs(party=None):
from webnotes.model.doclist import objectify
from utilities.transaction_base import get_address_display
if not party:
party = get_lead_or_customer()
address_docs = objectify(webnotes.conn.sql("""select * from `tabAddress`
where `%s`=%s order by name""" % (party.doctype.lower(), "%s"), party.name,
as_dict=True, update={"doctype": "Address"}))
for address in address_docs:
address.display = get_address_display(address.fields)
address.display = (address.display).replace("\n", "<br>\n")
return address_docs
def get_lead_or_customer():
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, "customer")
if customer:
return webnotes.doc("Customer", customer)
lead = webnotes.conn.get_value("Lead", {"email_id": webnotes.session.user})
if lead:
return webnotes.doc("Lead", lead)
else:
lead_bean = webnotes.bean({
"doctype": "Lead",
"email_id": webnotes.session.user,
"lead_name": get_fullname(webnotes.session.user),
"territory": guess_territory(),
"status": "Open" # TODO: set something better???
})
if webnotes.session.user != "Guest":
lead_bean.ignore_permissions = True
lead_bean.insert()
return lead_bean.doc
def guess_territory():
territory = None
geoip_country = webnotes.session.get("session_country")
if geoip_country:
territory = webnotes.conn.get_value("Territory", geoip_country)
return territory or \
webnotes.conn.get_value("Shopping Cart Settings", None, "territory") or \
"All Territories"
def decorate_quotation_doclist(doclist):
for d in doclist:
if d.item_code:
d.fields.update(webnotes.conn.get_value("Item", d.item_code,
["website_image", "description", "page_name"], as_dict=True))
d.formatted_rate = fmt_money(d.export_rate, currency=doclist[0].currency)
d.formatted_amount = fmt_money(d.export_amount, currency=doclist[0].currency)
elif d.charge_type:
d.formatted_tax_amount = fmt_money(d.tax_amount / doclist[0].conversion_rate,
currency=doclist[0].currency)
doclist[0].formatted_grand_total_export = fmt_money(doclist[0].grand_total_export,
currency=doclist[0].currency)
return [d.fields for d in doclist]
def _get_cart_quotation(party=None):
if not party:
party = get_lead_or_customer()
quotation = webnotes.conn.get_value("Quotation",
{party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0})
if quotation:
qbean = webnotes.bean("Quotation", quotation)
else:
qbean = webnotes.bean({
"doctype": "Quotation",
"naming_series": webnotes.defaults.get_user_default("shopping_cart_quotation_series") or "QTN-CART-",
"quotation_to": party.doctype,
"company": webnotes.defaults.get_user_default("company"),
"order_type": "Shopping Cart",
"status": "Draft",
"docstatus": 0,
"__islocal": 1,
(party.doctype.lower()): party.name
})
if party.doctype == "Customer":
qbean.doc.contact_person = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name})
qbean.run_method("set_contact_fields")
qbean.run_method("onload_post_render")
apply_cart_settings(party, qbean)
return qbean
def update_party(fullname, company_name=None, mobile_no=None, phone=None):
party = get_lead_or_customer()
if party.doctype == "Lead":
party.company_name = company_name
party.lead_name = fullname
party.mobile_no = mobile_no
party.phone = phone
else:
party.customer_name = company_name or fullname
party.customer_type == "Company" if company_name else "Individual"
contact_name = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name})
contact = webnotes.bean("Contact", contact_name)
contact.doc.first_name = fullname
contact.doc.last_name = None
contact.doc.customer_name = party.customer_name
contact.doc.mobile_no = mobile_no
contact.doc.phone = phone
contact.ignore_permissions = True
contact.save()
party_bean = webnotes.bean(party.fields)
party_bean.ignore_permissions = True
party_bean.save()
qbean = _get_cart_quotation(party)
if not qbean.doc.fields.get("__islocal"):
qbean.doc.customer_name = company_name or fullname
qbean.run_method("set_contact_fields")
qbean.ignore_permissions = True
qbean.save()
def apply_cart_settings(party=None, quotation=None):
if not party:
party = get_lead_or_customer()
if not quotation:
quotation = _get_cart_quotation(party)
cart_settings = webnotes.get_obj("Shopping Cart Settings")
billing_territory = get_address_territory(quotation.doc.customer_address) or \
party.territory
set_price_list_and_rate(quotation, cart_settings, billing_territory)
quotation.run_method("calculate_taxes_and_totals")
set_taxes(quotation, cart_settings, billing_territory)
_apply_shipping_rule(party, quotation, cart_settings)
def set_price_list_and_rate(quotation, cart_settings, billing_territory):
"""set price list based on billing territory"""
quotation.doc.selling_price_list = cart_settings.get_price_list(billing_territory)
# reset values
quotation.doc.price_list_currency = quotation.doc.currency = \
quotation.doc.plc_conversion_rate = quotation.doc.conversion_rate = None
for item in quotation.doclist.get({"parentfield": "quotation_details"}):
item.ref_rate = item.adj_rate = item.export_rate = item.export_amount = None
# refetch values
quotation.run_method("set_price_list_and_item_details")
# set it in cookies for using in product page
webnotes.cookies[b"selling_price_list"] = quotation.doc.selling_price_list
def set_taxes(quotation, cart_settings, billing_territory):
"""set taxes based on billing territory"""
quotation.doc.charge = cart_settings.get_tax_master(billing_territory)
# clear table
quotation.set_doclist(quotation.doclist.get({"parentfield": ["!=", "other_charges"]}))
# append taxes
controller = quotation.make_controller()
controller.append_taxes_from_master("other_charges", "charge")
quotation.set_doclist(controller.doclist)
@webnotes.whitelist()
def apply_shipping_rule(shipping_rule):
quotation = _get_cart_quotation()
quotation.doc.shipping_rule = shipping_rule
apply_cart_settings(quotation=quotation)
quotation.ignore_permissions = True
quotation.save()
return get_cart_quotation(quotation.doclist)
def _apply_shipping_rule(party=None, quotation=None, cart_settings=None):
shipping_rules = get_shipping_rules(party, quotation, cart_settings)
if not shipping_rules:
return
elif quotation.doc.shipping_rule not in shipping_rules:
quotation.doc.shipping_rule = shipping_rules[0]
quotation.run_method("apply_shipping_rule")
quotation.run_method("calculate_taxes_and_totals")
def get_applicable_shipping_rules(party=None, quotation=None):
shipping_rules = get_shipping_rules(party, quotation)
if shipping_rules:
rule_label_map = webnotes.conn.get_values("Shipping Rule", shipping_rules, "label")
# we need this in sorted order as per the position of the rule in the settings page
return [[rule, rule_label_map.get(rule)] for rule in shipping_rules]
def get_shipping_rules(party=None, quotation=None, cart_settings=None):
if not party:
party = get_lead_or_customer()
if not quotation:
quotation = _get_cart_quotation()
if not cart_settings:
cart_settings = webnotes.get_obj("Shopping Cart Settings")
# set shipping rule based on shipping territory
shipping_territory = get_address_territory(quotation.doc.shipping_address_name) or \
party.territory
shipping_rules = cart_settings.get_shipping_rules(shipping_territory)
return shipping_rules
def get_address_territory(address_name):
"""Tries to match city, state and country of address to existing territory"""
territory = None
if address_name:
address_fields = webnotes.conn.get_value("Address", address_name,
["city", "state", "country"])
for value in address_fields:
territory = webnotes.conn.get_value("Territory", value)
if territory:
break
return territory
import unittest
test_dependencies = ["Item", "Price List", "Contact", "Shopping Cart Settings"]
class TestCart(unittest.TestCase):
def tearDown(self):
return
cart_settings = webnotes.bean("Shopping Cart Settings")
cart_settings.ignore_permissions = True
cart_settings.doc.enabled = 0
cart_settings.save()
def enable_shopping_cart(self):
return
if not webnotes.conn.get_value("Shopping Cart Settings", None, "enabled"):
cart_settings = webnotes.bean("Shopping Cart Settings")
cart_settings.ignore_permissions = True
cart_settings.doc.enabled = 1
cart_settings.save()
def test_get_lead_or_customer(self):
webnotes.session.user = "test@example.com"
party1 = get_lead_or_customer()
party2 = get_lead_or_customer()
self.assertEquals(party1.name, party2.name)
self.assertEquals(party1.doctype, "Lead")
webnotes.session.user = "test_contact_customer@example.com"
party = get_lead_or_customer()
self.assertEquals(party.name, "_Test Customer")
def test_add_to_cart(self):
self.enable_shopping_cart()
webnotes.session.user = "test@example.com"
update_cart("_Test Item", 1)
quotation = _get_cart_quotation()
quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"})
self.assertTrue(quotation_items)
self.assertEquals(quotation_items[0].qty, 1)
return quotation
def test_update_cart(self):
self.test_add_to_cart()
update_cart("_Test Item", 5)
quotation = _get_cart_quotation()
quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"})
self.assertTrue(quotation_items)
self.assertEquals(quotation_items[0].qty, 5)
return quotation
def test_remove_from_cart(self):
quotation0 = self.test_add_to_cart()
update_cart("_Test Item", 0)
quotation = _get_cart_quotation()
self.assertEquals(quotation0.doc.name, quotation.doc.name)
quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"})
self.assertEquals(quotation_items, [])
def test_place_order(self):
quotation = self.test_update_cart()
sales_order_name = place_order()
sales_order = webnotes.bean("Sales Order", sales_order_name)
self.assertEquals(sales_order.doclist.getone({"item_code": "_Test Item"}).prevdoc_docname, quotation.doc.name)

View File

@@ -1,32 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import now
max_communications_per_hour = 300
@webnotes.whitelist(allow_guest=True)
def send_message(subject="Website Query", message="", sender="", status="Open"):
if not message:
webnotes.response["message"] = 'Please write something'
return
if not sender:
webnotes.response["message"] = 'Email Id Required'
return
# make lead / communication
from selling.doctype.lead.get_leads import add_sales_communication
message = add_sales_communication(subject or "Website Query", message, sender, sender,
mail=None, status=status)
# guest method, cap max writes per hour
if webnotes.conn.sql("""select count(*) from `tabCommunication`
where TIMEDIFF(%s, modified) < '01:00:00'""", now())[0][0] > max_communications_per_hour:
webnotes.response["message"] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
return
webnotes.response.status = "okay"

View File

@@ -1,130 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, cint, fmt_money
from webnotes.webutils import build_html, delete_page_cache
from website.helpers.cart import _get_cart_quotation
@webnotes.whitelist(allow_guest=True)
def get_product_info(item_code):
"""get product price / stock info"""
if not cint(webnotes.conn.get_default("shopping_cart_enabled")):
return {}
cart_quotation = _get_cart_quotation()
price_list = webnotes.cookies.get("selling_price_list").value
warehouse = webnotes.conn.get_value("Item", item_code, "website_warehouse")
if warehouse:
in_stock = webnotes.conn.sql("""select actual_qty from tabBin where
item_code=%s and warehouse=%s""", (item_code, warehouse))
if in_stock:
in_stock = in_stock[0][0] > 0 and 1 or 0
else:
in_stock = -1
price = price_list and webnotes.conn.sql("""select ref_rate, ref_currency from
`tabItem Price` where parent=%s and price_list=%s""",
(item_code, price_list), as_dict=1) or []
price = price and price[0] or None
qty = 0
if price:
price["formatted_price"] = fmt_money(price["ref_rate"], currency=price["ref_currency"])
price["ref_currency"] = not cint(webnotes.conn.get_default("hide_currency_symbol")) \
and (webnotes.conn.get_value("Currency", price.ref_currency, "symbol") or price.ref_currency) \
or ""
if webnotes.session.user != "Guest":
item = cart_quotation.doclist.get({"item_code": item_code})
if item:
qty = item[0].qty
return {
"price": price,
"stock": in_stock,
"uom": webnotes.conn.get_value("Item", item_code, "stock_uom"),
"qty": qty
}
@webnotes.whitelist(allow_guest=True)
def get_product_list(search=None, start=0, limit=10):
# base query
query = """select name, item_name, page_name, website_image, item_group,
web_long_description as website_description
from `tabItem` where docstatus = 0 and show_in_website = 1 """
# search term condition
if search:
query += """and (web_long_description like %(search)s or
item_name like %(search)s or name like %(search)s)"""
search = "%" + cstr(search) + "%"
# order by
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
data = webnotes.conn.sql(query, {
"search": search,
}, as_dict=1)
return [get_item_for_list_in_html(r) for r in data]
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)])
# base query
query = """select name, item_name, page_name, website_image, item_group,
web_long_description as website_description
from `tabItem` where docstatus = 0 and 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)
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
data = webnotes.conn.sql(query, {"product_group": product_group}, as_dict=1)
return [get_item_for_list_in_html(r) for r in data]
def get_child_groups(item_group_name):
item_group = webnotes.doc("Item Group", item_group_name)
return webnotes.conn.sql("""select name
from `tabItem Group` where lft>=%(lft)s and rgt<=%(rgt)s
and show_in_website = 1""", item_group.fields)
def get_group_item_count(item_group):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)])
return webnotes.conn.sql("""select count(*) from `tabItem`
where docstatus = 0 and 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))[0][0]
def get_item_for_list_in_html(r):
scrub_item_for_list(r)
r.template = "app/website/templates/html/product_in_grid.html"
return build_html(r)
def scrub_item_for_list(r):
if not r.website_description:
r.website_description = "No description given"
if len(r.website_description.split(" ")) > 24:
r.website_description = " ".join(r.website_description.split(" ")[:24]) + "..."
def get_parent_item_groups(item_group_name):
item_group = webnotes.doc("Item Group", item_group_name)
return webnotes.conn.sql("""select name, page_name from `tabItem Group`
where lft <= %s and rgt >= %s
and ifnull(show_in_website,0)=1
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
def invalidate_cache_for(item_group):
for i in get_parent_item_groups(item_group):
if i.page_name:
delete_page_cache(i.page_name)

View File

@@ -1,139 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, formatdate
import json
def get_transaction_list(doctype, start):
# find customer id
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
if customer:
transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export
from `tab%s` where customer=%s and docstatus=1
order by creation desc
limit %s, 20""" % (doctype, "%s", "%s"), (customer, cint(start)), as_dict=True)
for doc in transactions:
doc.items = ", ".join(webnotes.conn.sql_list("""select item_name
from `tab%s Item` where parent=%s limit 5""" % (doctype, "%s"), doc.name))
doc.creation = formatdate(doc.creation)
return transactions
else:
return []
def get_common_args():
return {
"global_number_format": webnotes.conn.get_default("number_format") or "#,###.##",
"currency": webnotes.conn.get_default("currency"),
"currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol
from tabCurrency where ifnull(enabled,0)=1""")))
}
@webnotes.whitelist()
def get_orders(start=0):
return get_transaction_list("Sales Order", start)
def order_list_args():
args = get_common_args()
args.update({
"title": "My Orders",
"method": "website.helpers.transaction.get_orders",
"icon": "icon-list",
"empty_list_message": "No Orders Yet",
"page": "order",
})
return args
@webnotes.whitelist()
def get_invoices(start=0):
return get_transaction_list("Sales Invoice", start)
def invoice_list_args():
args = get_common_args()
args.update({
"title": "Invoices",
"method": "website.helpers.transaction.get_invoices",
"icon": "icon-file-text",
"empty_list_message": "No Invoices Found",
"page": "invoice"
})
return args
@webnotes.whitelist()
def get_shipments(start=0):
return get_transaction_list("Delivery Note", start)
def shipment_list_args():
args = get_common_args()
args.update({
"title": "Shipments",
"method": "website.helpers.transaction.get_shipments",
"icon": "icon-truck",
"empty_list_message": "No Shipments Found",
"page": "shipment"
})
return args
@webnotes.whitelist()
def get_tickets(start=0):
tickets = webnotes.conn.sql("""select name, subject, status, creation
from `tabSupport Ticket` where raised_by=%s
order by modified desc
limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True)
for t in tickets:
t.creation = formatdate(t.creation)
return tickets
def ticket_list_args():
return {
"title": "My Tickets",
"method": "website.helpers.transaction.get_tickets",
"icon": "icon-ticket",
"empty_list_message": "No Tickets Raised",
"page": "ticket"
}
def get_transaction_args(doctype, name):
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
bean = webnotes.bean(doctype, name)
if bean.doc.customer != customer:
return {
"doc": {"name": "Not Allowed"}
}
else:
return {
"doc": bean.doc,
"doclist": bean.doclist,
"webnotes": webnotes,
"utils": webnotes.utils
}
def get_order_args():
args = get_transaction_args("Sales Order", webnotes.form_dict.name)
args.update({
"parent_link": "orders",
"parent_title": "My Orders"
})
return args
def get_invoice_args():
args = get_transaction_args("Sales Invoice", webnotes.form_dict.name)
args.update({
"parent_link": "invoices",
"parent_title": "Invoices"
})
return args
def get_shipment_args():
args = get_transaction_args("Delivery Note", webnotes.form_dict.name)
args.update({
"parent_link": "shipments",
"parent_title": "Shipments"
})
return args

View File

@@ -1,26 +0,0 @@
{% extends "app/website/templates/html/page.html" %}
{% block content %}
<div class="col-md-12" itemscope itemtype="http://schema.org/Organization">
<div class="row">
<div class="col-md-4">
{% if logo -%}
<img itemprop="brand" src="{{ logo }}" class="partner-logo"
alt="{{ partner_name }}" title="{{ partner_name }}" />
<br><br>
{%- endif %}
<address>
{% if partner_website -%}<p><a href="{{ partner_website }}"
target="_blank">{{ partner_website }}</a></p>{%- endif %}
{% if partner_address -%}<p itemprop="address">{{ partner_address }}</p>{%- endif %}
{% if phone -%}<p itemprop="telephone">{{ phone }}</p>{%- endif %}
{% if email -%}<p itemprop="email"><span class="icon-envelope"></span> {{ email }}</p>{%- endif %}
</address>
</div>
<div class="col-md-8">
<h3 itemprop="name" style="margin-top: 0px;">{{ partner_name }}</h3>
<p>{{ description }}</p>
</div>
</div>
</div>
{% endblock %}

View File

@@ -1,12 +0,0 @@
{% if obj.parent_groups and len(obj.parent_groups) > 1 %}
<div class="col-md-12">
<div class="clearfix">
<ul class="breadcrumb">
{% for ig in obj.parent_groups[:-1] %}
<li><a href="{{ ig.page_name }}.html">{{ ig.name }}</a></li>
{% endfor %}
<li class="active">{{ obj.parent_groups[-1].name }}</li>
</ul>
</div>
</div>
{% endif %}

View File

@@ -1,42 +0,0 @@
{% extends "app/website/templates/html/page.html" %}
{% block content %}
{% include 'app/website/templates/html/product_search_box.html' %}
{% include 'app/website/templates/html/product_breadcrumbs.html' %}
<div class="col-md-12">
{% if slideshow %}<!-- slideshow -->
{% include "app/website/templates/html/slideshow.html" %}
{% endif %}
{% if description %}<!-- description -->
<div>{{ description or ""}}</div>
{% else %}
<h3>{{ name }}</h3>
{% endif %}
</div>
<div class="col-md-12">
{% if sub_groups %}
<hr />
<div class="row">
{% for d in sub_groups %}
<div class="col-md-4">
<a href="{{ d.page_name }}">{{ d.name }} ({{ d.count }})</a>
</div>
{% endfor %}
</div>
<hr />
{% endif %}
{% if items %}
<div id="search-list" class="row">
{% for item in items %}
{{ item }}
{% endfor %}
</div>
{% if len(items)==100 %}
<div class="alert info">Showing top 100 items.</div>
{% endif %}
{% else %}
<div class="alert">No items listed.</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -1,14 +0,0 @@
<div class="col-md-3">
<div style="height: 120px; overflow: hidden;">
<a href="{{ page_name }}">
{%- if website_image -%}
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
{%- else -%}
{% include 'app/website/templates/html/product_missing_image.html' %}
{%- endif -%}
</a>
</div>
<div style="height: 100px; overflow: hidden; font-size: 80%;">
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
</div>
</div>

View File

@@ -1,15 +0,0 @@
<!-- TODO product listing -->
<div class="col-md-12">
<div style="height: 120px; overflow: hidden;">
<a href="{{ page_name }}">
{%- if website_image -%}
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
{%- else -%}
{% include 'app/website/templates/html/product_missing_image.html' %}
{%- endif -%}
</a>
</div>
<div style="height: 100px; overflow: hidden; font-size: 80%;">
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
</div>
</div>

View File

@@ -1 +0,0 @@
<div class="missing-image"><i class="icon-camera"></i></div>

View File

@@ -1,74 +0,0 @@
{% extends "app/website/templates/html/page.html" %}
{% block javascript %}
{% include "app/website/templates/js/product_page.js" %}
{% endblock %}
{% block css %}
{% include "app/website/templates/css/product_page.css" %}
{% endblock %}
{% block content %}
{% include 'app/website/templates/html/product_search_box.html' %}
{% include 'app/website/templates/html/product_breadcrumbs.html' %}
<div class="col-md-12 product-page-content" itemscope itemtype="http://schema.org/Product">
<div class="row">
<div class="col-md-6">
{% if slideshow %}
{% include "app/website/templates/html/slideshow.html" %}
{% else %}
{% if website_image %}
<image itemprop="image" class="item-main-image"
src="{{ website_image }}" />
{% else %}
<div class="img-area">
{% include 'app/website/templates/html/product_missing_image.html' %}
</div>
{% endif %}
{% endif %}
</div>
<div class="col-md-6">
<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">
{{ web_long_description or description or "[No description given]" }}
</div>
<div style="min-height: 100px; margin: 10px 0;">
<div class="item-price-info" style="display: none;">
<h4 class="item-price" itemprop="price"></h4>
<div class="item-stock" itemprop="availablity"></div>
<div id="item-add-to-cart">
<button class="btn btn-primary">
<i class="icon-shopping-cart"></i> Add to Cart</button>
</div>
<div id="item-update-cart" class="input-group col-md-4" style="display: none;
padding-left: 0px; padding-right: 0px;">
<input class="form-control" type="text">
<div class="input-group-btn">
<button class="btn btn-primary">
<i class="icon-ok"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
{% if obj.doclist.get({"doctype":"Item Website Specification"}) -%}
<div class="row" style="margin-top: 20px">
<div class="col-md-12">
<h4>Specifications</h4>
<table class="table table-bordered" style="width: 100%">
{% for d in obj.doclist.get(
{"doctype":"Item Website Specification"}) -%}
<tr>
<td style="width: 30%;">{{ d.label }}</td>
<td>{{ d.description }}</td>
</tr>
{%- endfor %}
</table>
</div>
</div>
{%- endif %}
</div>
{% endblock %}

View File

@@ -1,29 +0,0 @@
<div class="col-md-12 clearfix">
<div class="pull-right" style="margin-top: 15px; margin-bottom: 15px;">
<form class="form-search">
<div class="input-group col-md-4 col-md-offset-8">
<input class="form-control" type="text" id="product-search" placeholder="Product Search...">
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="btn-product-search">
<i class="icon-search"></i></button>
</span>
</div>
</form>
</div>
<script>
// redirect to product search page
$(document).ready(function() {
$('.dropdown-toggle').dropdown()
$("#btn-product-search").click(function() {
var txt = $("#product-search").val();
if(txt) {
window.location.href="product_search.html?q=" + txt;
}
return false;
});
$("#product-search").keypress(function(e) {
if(e.which==13) $("#product-search-btn").click();
})
})
</script>
</div>

View File

@@ -14,6 +14,7 @@ $(document).ready(function() {
.parent().append("<div class='alert alert-warning'>Comments are closed.</div>")
}
$(".add-comment").click(function() {
$(this).toggle(false);
$("#comment-form").toggle();
$("#comment-form input, #comment-form, textarea").val("");
})

View File

@@ -7,7 +7,7 @@ $(document).ready(function() {
wn.cart.bind_events();
return wn.call({
type: "POST",
method: "website.helpers.cart.get_cart_quotation",
method: "selling.utils.cart.get_cart_quotation",
callback: function(r) {
console.log(r);
$("#cart-container").removeClass("hide");
@@ -194,7 +194,7 @@ $.extend(wn.cart, {
return wn.call({
btn: btn,
type: "POST",
method: "website.helpers.cart.apply_shipping_rule",
method: "selling.utils.cart.apply_shipping_rule",
args: { shipping_rule: rule },
callback: function(r) {
if(!r.exc) {
@@ -242,7 +242,7 @@ $.extend(wn.cart, {
return wn.call({
type: "POST",
method: "website.helpers.cart.update_cart_address",
method: "selling.utils.cart.update_cart_address",
args: {
address_fieldname: $address_wrapper.attr("data-fieldname"),
address_name: $(this).attr("data-address-name")
@@ -273,7 +273,7 @@ $.extend(wn.cart, {
place_order: function() {
return wn.call({
type: "POST",
method: "website.helpers.cart.place_order",
method: "selling.utils.cart.place_order",
callback: function(r) {
if(r.exc) {
var msg = "";

View File

@@ -15,7 +15,7 @@ window.get_product_list = function() {
url: "server.py",
dataType: "json",
data: {
cmd: "website.helpers.product.get_product_list",
cmd: "selling.utils.product.get_product_list",
start: window.start,
search: window.search,
product_group: window.product_group

View File

@@ -7,7 +7,7 @@ $(document).ready(function() {
wn.call({
type: "POST",
method: "website.helpers.product.get_product_info",
method: "selling.utils.product.get_product_info",
args: {
item_code: "{{ name }}"
},

View File

@@ -89,7 +89,7 @@
wn.call({
btn: $(this),
type: "POST",
method: "website.helpers.cart.save_address",
method: "selling.utils.cart.save_address",
args: { fields: fields, address_fieldname: get_url_arg("address_fieldname") },
callback: function(r) {
if(r.exc) {

View File

@@ -26,7 +26,7 @@
var fetch_addresses = function() {
wn.call({
method: "website.helpers.cart.get_addresses",
method: "selling.utils.cart.get_addresses",
callback: function(r) {
$("#address-list .progress").remove();
var $list = $("#address-list");

View File

@@ -1,31 +0,0 @@
{% extends "app/website/templates/html/transactions.html" %}
{% block javascript -%}
{{ super() }}
var render = function(doc) {
doc.sender = doc.sender ? doc.sender : "To ";
doc.recipients = doc.recipients ? (" to " + doc.recipients) : "";
doc.content = remove_script_and_style(doc.content);
if(!is_html(doc.content)) {
doc.content = doc.content.replace("\n", "<br>");
}
$(repl('<a class="list-group-item">\
<div class="row col-md-12">%(subject)s</div>\
<div class="row text-muted">\
<div class="col-md-6">%(sender)s%(recipients)s</div>\
<div class="col-md-6 text-right">%(creation)s</div>\
</div>\
<div class="row col-md-12 msg-content" style="display: none;"><hr>%(content)s</div>\
</a>', doc))
.appendTo($list)
.on("click", function() {
$(this).find(".msg-content").toggle();
});
}
{%- endblock %}

View File

@@ -1,30 +0,0 @@
{% extends "app/website/templates/html/page.html" %}
{% set title="Partners" %}
{% block content %}
<div class="col-md-12">
<h2 id="blog-title">{{ title }}</h2>
<hr>
{% for partner_info in partners %}
<div class="row">
<div class="col-md-3">
{% if partner_info.logo -%}
<a href="{{ partner_info.page_name }}">
<img itemprop="brand" src="{{ partner_info.logo }}" class="partner-logo"
alt="{{ partner_info.partner_name }}" title="{{ partner_info.partner_name }}" />
</a>
{%- endif %}
</div>
<div class="col-md-9">
<a href="{{ partner_info.page_name }}">
<h4>{{ partner_info.partner_name }}</h4>
</a>
<p style="color: #999">{{ partner_info.territory }} - {{ partner_info.partner_type }}</p>
<p>{{ partner_info.introduction }}</p>
</div>
</div>
<hr>
{% endfor %}
</div>
{% endblock %}

View File

@@ -1,33 +0,0 @@
{% extends "app/website/templates/html/page.html" %}
{% set title="Product Search" %}
{% block javascript %}
{% include "app/website/templates/js/product_list.js" %}
{% endblock %}
{% block content %}
<script>
$(document).ready(function() {
var txt = get_url_arg("q");
$(".search-results").html("Search results for: " + txt);
window.search = txt;
window.start = 0;
window.get_product_list();
});
</script>
{% include 'app/website/templates/html/product_search_box.html' %}
<div class="col-md-12">
<h3 class="search-results">Search Results</h3>
<div id="search-list" class="row">
</div>
<div style="text-align: center;">
<div class="more-btn"
style="display: none; text-align: center;">
<button class="btn">More...</button>
</div>
</div>
</div>
{% endblock %}

View File

@@ -1,67 +0,0 @@
{% extends "app/website/templates/html/page.html" %}
{% set title=doc.name %}
{% set status_label = {
"Open": "label-success",
"To Reply": "label-danger",
"Closed": "label-default"
} %}
{% block content %}
<div class="col-md-12">
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li><a href="tickets">My Tickets</a></li>
<li class="active"><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</li>
</ul>
<h3><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</h3>
{% if doc.name == "Not Allowed" -%}
<script>ask_to_login();</script>
{% else %}
<hr>
{%- if doc.status -%}
{% if doc.status == "Waiting for Customer" -%}
{% set status = "To Reply" %}
{% else %}
{% set status = doc.status %}
{%- endif -%}
<div class="row">
<div class="col-md-2" style="margin-bottom: 7px;">
<span class="label {{ status_label.get(status) or 'label-default' }}">{{ status }}</span>
</div>
<div class="col-md-8">
<div class="row col-md-12">{{ doc.subject }}</div>
</div>
<div class="col-md-2 pull-right">
<span class="text-muted">{{ utils.formatdate(doc.creation) }}</span>
</div>
</div>
<br>
<h4>Messages</h4>
{%- if doclist.get({"doctype":"Communication"}) -%}
<div>
<table class="table table-bordered table-striped">
<tbody>
{%- for comm in doclist.get({"doctype":"Communication"}) %}
<tr>
<td>
<h5 style="text-transform: none">
{{ comm.sender }} on {{ utils.formatdate(doc.modified) }}</h5>
<hr>
<p>{{ webnotes.utils.is_html(comm.content) and comm.content or
comm.content.replace("\n", "<br>")}}</p>
</td>
</tr>
{% endfor -%}
</tbody>
</table>
</div>
{%- else -%}
<div class="alert">No messages</div>
{%- endif -%}
{%- endif -%}
{% endif -%}
</div>
{% endblock %}

View File

@@ -1,31 +0,0 @@
{% extends "app/website/templates/html/transactions.html" %}
{% block javascript -%}
{{ super() }}
var status_label = {
"Open": "label-success",
"Waiting for Customer": "label-danger",
"Closed": "label-default"
}
var render = function(doc) {
doc.status = doc.status.trim();
doc.label_class = status_label[doc.status] || "label-default";
if(doc.status==="Waiting for Customer") doc.status = "To Reply";
$(repl('<a href="{{ page }}?name=%(name)s" class="list-group-item">\
<div class="row">\
<div class="col-md-2" style="margin-bottom: 7px;"><span class="label %(label_class)s">\
%(status)s</span></div>\
<div class="col-md-8">\
<div class="row col-md-12">%(name)s</div>\
<div class="row col-md-12 text-muted">%(subject)s</div>\
</div>\
<div class="col-md-2 pull-right">\
<span class="text-muted">%(creation)s</span>\
</div>\
</div>\
</a>', doc)).appendTo($list);
};
{%- endblock %}