refactor: Cache Item Reviews and other review feedback

- `get_doc` -> `get_values` and `db.sql` -> `db.delete` in Wishlist Item deletion
- cache first page of Item Reviews and burst cache on addition and deletion of reviews
- Update redisearch docs link in E Commerce Settings
- Removed unused cint import
- Broke setting attribute context into smaller functions and code cleanup
- Minor recommended items padding tweak
- Item reviews form dict now uses website item as key
- Customer reviews rendered from UI style consistency
- Stock status consistency in listing and full page
- Handle no price in variant dialog for matched item
This commit is contained in:
marination
2021-08-25 13:09:35 +05:30
parent 341d9b4b6d
commit c1f6898f1a
14 changed files with 217 additions and 128 deletions

View File

@@ -35,8 +35,8 @@
{% if cart_settings.show_stock_availability %}
<div class="mt-2">
{% if product_info.in_stock == 0 %}
<span class="text-danger no-stock">
{{ _('Not in stock') }}
<span class="no-stock out-of-stock">
{{ _('Out of stock') }}
</span>
{% elif product_info.in_stock == 1 %}
<span class="in-green has-stock">

View File

@@ -214,7 +214,7 @@ class ItemConfigure {
? `<div class="alert alert-success d-flex justify-content-between align-items-center" role="alert">
<div><div>
${one_item}
${product_info && product_info.price
${product_info && product_info.price && !$.isEmptyObject()
? '(' + product_info.price.formatted_price_sales_uom + ')'
: ''
}

View File

@@ -29,7 +29,7 @@
{% if total_reviews > 4 %}
<div class="mt-6 mb-6"style="color: var(--primary);">
<a href="/customer_reviews?item_code={{ doc.item_code }}">{{ _("View all reviews") }}</a>
<a href="/customer_reviews?web_item={{ doc.name }}">{{ _("View all reviews") }}</a>
</div>
{% endif %}

View File

@@ -96,23 +96,25 @@ $(() => {
reviews.forEach((review) => {
$content.append(`
<div class="mb-3 review">
<div style="display: flex;">
<div class="d-flex">
<p class="mr-4 user-review-title">
<span>${__(review.review_title)}</span>
</p>
<div class="rating">
${me.get_review_stars(review.rating)}
</div>
<p class="ml-4 user-review-title">
<span>${__(review.review_title)}</span>
</p>
</div>
<div class="review-signature">
<span class="reviewer">${__(review.customer)}</span>
<span>${__(review.published_on)}</span>
</div>
<div class="product-description mb-4 mt-4">
<div class="product-description mb-4">
<p>
${__(review.comment)}
</p>
</div>
<div class="review-signature mb-2">
<span class="reviewer">${__(review.customer)}</span>
<span class="indicator grey" style="--text-on-gray: var(--gray-300);"></span>
<span class="reviewer">${__(review.published_on)}</span>
</div>
</div>
`);
});
@@ -122,9 +124,11 @@ $(() => {
let stars = ``;
for (let i = 1; i < 6; i++) {
let fill_class = i <= rating ? 'star-click' : '';
stars += `<svg class="icon icon-md ${fill_class}">
stars += `
<svg class="icon icon-sm ${fill_class}">
<use href="#icon-star"></use>
</svg>`;
</svg>
`;
}
return stars;
}

View File

@@ -10,10 +10,10 @@ def get_context(context):
context.full_page = True
context.reviews = None
if frappe.form_dict and frappe.form_dict.get("item_code"):
context.item_code = frappe.form_dict.get("item_code")
context.web_item = frappe.db.get_value("Website Item", {"item_code": context.item_code}, "name")
if frappe.form_dict and frappe.form_dict.get("web_item"):
context.web_item = frappe.form_dict.get("web_item")
context.user_is_customer = check_if_user_is_customer()
context.enable_reviews = get_shopping_cart_settings().enable_reviews
if context.enable_reviews:
get_item_reviews(context.web_item, 0, 10, context)
reviews_data = get_item_reviews(context.web_item)
context.update(reviews_data)