From d897062304dfbcc12668f0a42466d3463724a5cf Mon Sep 17 00:00:00 2001 From: marination Date: Thu, 8 Jul 2021 13:58:00 +0530 Subject: [PATCH] fix: Rename Wishlist Item, Use Website Item Name in Wishlist Cards - Renamed Wishlist Items to Wishlist Item - Use Website Item Name in Wishlist - Add Website Item Name field in Wishlist Item - Remove accidental extra `font-size` attribute --- .../e_commerce/doctype/website_item/website_item.py | 2 +- erpnext/e_commerce/doctype/wishlist/wishlist.json | 4 ++-- erpnext/e_commerce/doctype/wishlist/wishlist.py | 9 +++++---- .../{wishlist_items => wishlist_item}/__init__.py | 0 .../wishlist_item.json} | 13 +++++++++++-- .../wishlist_item.py} | 2 +- erpnext/e_commerce/product_query.py | 2 +- erpnext/public/scss/shopping_cart.scss | 1 - erpnext/templates/includes/macros.html | 8 ++++---- erpnext/templates/pages/wishlist.py | 4 ++-- 10 files changed, 27 insertions(+), 18 deletions(-) rename erpnext/e_commerce/doctype/{wishlist_items => wishlist_item}/__init__.py (100%) rename erpnext/e_commerce/doctype/{wishlist_items/wishlist_items.json => wishlist_item/wishlist_item.json} (91%) rename erpnext/e_commerce/doctype/{wishlist_items/wishlist_items.py => wishlist_item/wishlist_item.py} (88%) diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py index 3331532ec1..8d3127e01f 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.py +++ b/erpnext/e_commerce/doctype/website_item/website_item.py @@ -195,7 +195,7 @@ class WebsiteItem(WebsiteGenerator): get_item_reviews(self.name, 0, 4, context) context.wished = False - if frappe.db.exists("Wishlist Items", {"item_code": self.item_code, "parent": frappe.session.user}): + if frappe.db.exists("Wishlist Item", {"item_code": self.item_code, "parent": frappe.session.user}): context.wished = True context.user_is_customer = check_if_user_is_customer() diff --git a/erpnext/e_commerce/doctype/wishlist/wishlist.json b/erpnext/e_commerce/doctype/wishlist/wishlist.json index ae24207d5f..922924e53b 100644 --- a/erpnext/e_commerce/doctype/wishlist/wishlist.json +++ b/erpnext/e_commerce/doctype/wishlist/wishlist.json @@ -28,13 +28,13 @@ "fieldname": "items", "fieldtype": "Table", "label": "Items", - "options": "Wishlist Items" + "options": "Wishlist Item" } ], "in_create": 1, "index_web_pages_for_search": 1, "links": [], - "modified": "2021-03-24 20:42:58.402031", + "modified": "2021-07-08 13:11:21.693956", "modified_by": "Administrator", "module": "E-commerce", "name": "Wishlist", diff --git a/erpnext/e_commerce/doctype/wishlist/wishlist.py b/erpnext/e_commerce/doctype/wishlist/wishlist.py index c817657a50..94f19ff215 100644 --- a/erpnext/e_commerce/doctype/wishlist/wishlist.py +++ b/erpnext/e_commerce/doctype/wishlist/wishlist.py @@ -13,11 +13,11 @@ class Wishlist(Document): def add_to_wishlist(item_code, price, formatted_price=None): """Insert Item into wishlist.""" - if frappe.db.exists("Wishlist Items", {"item_code": item_code, "parent": frappe.session.user}): + if frappe.db.exists("Wishlist Item", {"item_code": item_code, "parent": frappe.session.user}): return web_item_data = frappe.db.get_value("Website Item", {"item_code": item_code}, - ["image", "website_warehouse", "name", "item_name", "item_group", "route"] + ["image", "website_warehouse", "name", "web_item_name", "item_name", "item_group", "route"] , as_dict=1) wished_item_dict = { @@ -25,6 +25,7 @@ def add_to_wishlist(item_code, price, formatted_price=None): "item_name": web_item_data.get("item_name"), "item_group": web_item_data.get("item_group"), "website_item": web_item_data.get("name"), + "web_item_name": web_item_data.get("web_item_name"), "price": frappe.utils.flt(price), "formatted_price": formatted_price, "image": web_item_data.get("image"), @@ -48,10 +49,10 @@ def add_to_wishlist(item_code, price, formatted_price=None): @frappe.whitelist() def remove_from_wishlist(item_code): - if frappe.db.exists("Wishlist Items", {"item_code": item_code, "parent": frappe.session.user}): + if frappe.db.exists("Wishlist Item", {"item_code": item_code, "parent": frappe.session.user}): frappe.db.sql(""" delete - from `tabWishlist Items` + from `tabWishlist Item` where item_code=%(item_code)s """ % {"item_code": frappe.db.escape(item_code)}) diff --git a/erpnext/e_commerce/doctype/wishlist_items/__init__.py b/erpnext/e_commerce/doctype/wishlist_item/__init__.py similarity index 100% rename from erpnext/e_commerce/doctype/wishlist_items/__init__.py rename to erpnext/e_commerce/doctype/wishlist_item/__init__.py diff --git a/erpnext/e_commerce/doctype/wishlist_items/wishlist_items.json b/erpnext/e_commerce/doctype/wishlist_item/wishlist_item.json similarity index 91% rename from erpnext/e_commerce/doctype/wishlist_items/wishlist_items.json rename to erpnext/e_commerce/doctype/wishlist_item/wishlist_item.json index 6623921f18..aecdbdda19 100644 --- a/erpnext/e_commerce/doctype/wishlist_items/wishlist_items.json +++ b/erpnext/e_commerce/doctype/wishlist_item/wishlist_item.json @@ -7,6 +7,7 @@ "field_order": [ "item_code", "website_item", + "web_item_name", "column_break_3", "item_name", "item_group", @@ -126,15 +127,23 @@ "fieldname": "formatted_price", "fieldtype": "Data", "label": "Formatted Price" + }, + { + "fetch_from": "website_item.web_item_name", + "fetch_if_empty": 1, + "fieldname": "web_item_name", + "fieldtype": "Data", + "label": "Webiste Item Name", + "read_only": 1 } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-03-18 16:04:52.965613", + "modified": "2021-07-08 13:14:14.919749", "modified_by": "Administrator", "module": "E-commerce", - "name": "Wishlist Items", + "name": "Wishlist Item", "owner": "Administrator", "permissions": [], "sort_field": "modified", diff --git a/erpnext/e_commerce/doctype/wishlist_items/wishlist_items.py b/erpnext/e_commerce/doctype/wishlist_item/wishlist_item.py similarity index 88% rename from erpnext/e_commerce/doctype/wishlist_items/wishlist_items.py rename to erpnext/e_commerce/doctype/wishlist_item/wishlist_item.py index 25ce17d655..ee08cfea59 100644 --- a/erpnext/e_commerce/doctype/wishlist_items/wishlist_items.py +++ b/erpnext/e_commerce/doctype/wishlist_item/wishlist_item.py @@ -6,5 +6,5 @@ from __future__ import unicode_literals # import frappe from frappe.model.document import Document -class WishlistItems(Document): +class WishlistItem(Document): pass diff --git a/erpnext/e_commerce/product_query.py b/erpnext/e_commerce/product_query.py index e5af7e1bec..b4d3bed2c1 100644 --- a/erpnext/e_commerce/product_query.py +++ b/erpnext/e_commerce/product_query.py @@ -74,7 +74,7 @@ class ProductQuery: self.get_stock_availability(item) item.wished = False - if frappe.db.exists("Wishlist Items", {"item_code": item.item_code, "parent": frappe.session.user}): + if frappe.db.exists("Wishlist Item", {"item_code": item.item_code, "parent": frappe.session.user}): item.wished = True discounts = [] diff --git a/erpnext/public/scss/shopping_cart.scss b/erpnext/public/scss/shopping_cart.scss index 4e948c1faf..5f0f0230cd 100644 --- a/erpnext/public/scss/shopping_cart.scss +++ b/erpnext/public/scss/shopping_cart.scss @@ -73,7 +73,6 @@ body.product-page { border-radius: var(--border-radius); font-size: 2rem; color: var(--gray-500); - font-size: 52px; display: flex; align-items: center; justify-content: center; diff --git a/erpnext/templates/includes/macros.html b/erpnext/templates/includes/macros.html index a4bba5c8b7..8413bb0eba 100644 --- a/erpnext/templates/includes/macros.html +++ b/erpnext/templates/includes/macros.html @@ -144,7 +144,7 @@ {%- macro wishlist_card(item, settings) %} -{%- set title = item.item_name or item.item_code -%} +{%- set title = item.web_item_name or ''-%} {%- set title = title[:50] + "..." if title|len > 50 else title -%}
@@ -167,15 +167,15 @@
- {{ wishlist_card_body(item, settings) }} + {{ wishlist_card_body(item, title, settings) }} {%- endmacro -%} -{%- macro wishlist_card_body(item, settings) %} +{%- macro wishlist_card_body(item, title, settings) %}
-
{{ item.item_name or item.item_code or ''}}
+
{{ title or ''}}
{{ item.formatted_price or '' }} diff --git a/erpnext/templates/pages/wishlist.py b/erpnext/templates/pages/wishlist.py index 9bbec33cbe..5992863b67 100644 --- a/erpnext/templates/pages/wishlist.py +++ b/erpnext/templates/pages/wishlist.py @@ -45,10 +45,10 @@ def get_wishlist_items(): if frappe.db.exists("Wishlist", frappe.session.user): return frappe.db.sql(""" Select - item_code, item_name, website_item, price, + web_item_name, item_code, item_name, website_item, price, warehouse, image, item_group, route, formatted_price from - `tabWishlist Items` + `tabWishlist Item` where parent=%(user)s""", {"user": frappe.session.user}, as_dict=1) return \ No newline at end of file