Merge pull request #5631 from KanchanChauhan/address-viewww-fixed

Address view fixed for website
This commit is contained in:
Rushabh Mehta 2016-07-04 15:50:40 +05:30 committed by GitHub
commit bc10431b7d
3 changed files with 30 additions and 5 deletions

View File

@ -81,6 +81,13 @@ website_route_rules = [
"parents": [{"title": _("Request for Quotation"), "name": "rfq"}]
}
},
{"from_route": "/addresses", "to_route": "Address"},
{"from_route": "/addresses/<path:name>", "to_route": "addresses",
"defaults": {
"doctype": "Address",
"parents": [{"title": _("Addresses"), "name": "addresses"}]
}
},
{"from_route": "/jobs", "to_route": "Job Opening"},
]

View File

@ -1,8 +1,14 @@
<div class="web-list-item">
<a href="/addresses?name={{ doc.name | urlencode }}" class="no-decoration">
<h4 class="strong">{{ doc.address_title }}</h4>
<p class="text-muted small">
{{ frappe.get_doc(doc).get_display() }}
</p>
<div class="row">
<div class="col-xs-3">
<span class="indicator {{ "red" if doc.address_type=="Office" else "green" if doc.address_type=="Billing" else "blue" if doc.address_type=="Shipping" else "darkgrey" }}">{{ doc.address_title }}</span>
</div>
<div class="col-xs-2"> {{ doc.address_type }} </div>
<div class="col-xs-2"> {{ doc.city }} </div>
<div class="col-xs-5 text-right small text-muted">
{{ frappe.get_doc(doc).get_display() }}
</div>
</div>
</a>
</div>

View File

@ -9,6 +9,7 @@ from frappe.utils import cstr
from frappe.model.document import Document
from jinja2 import TemplateSyntaxError
from frappe.utils.user import is_website_user
class Address(Document):
def __setup__(self):
@ -123,11 +124,22 @@ def get_list_context(context=None):
from erpnext.shopping_cart.cart import get_address_docs
return {
"title": _("Addresses"),
"get_list": get_address_docs,
"get_list": get_address_list,
"row_template": "templates/includes/address_row.html",
'no_breadcrumbs': True,
}
def get_address_list(doctype, txt, filters, limit_start, limit_page_length=20):
from frappe.www.list import get_list
user = frappe.session.user
ignore_permissions = False
if is_website_user():
if not filters: filters = []
filters.append(("Address", "owner", "=", user))
ignore_permissions = True
return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)
def has_website_permission(doc, ptype, user, verbose=False):
"""Returns true if customer or lead matches with user"""
customer = frappe.db.get_value("Contact", {"email_id": frappe.session.user}, "customer")