{% extends "base.html" %} {% block title %}{{ product.name }} - Product Recommendation Engine{% endblock %} {% block content %}
{% if product.image_url %} {{ product.name }} {% else %}
{% endif %}

{{ product.name }}

{{ product.category }}
{% set avg_rating = product.get_average_rating() %} {% if avg_rating > 0 %} {% for i in range(5) %} {% if i < avg_rating %}★{% else %}☆{% endif %} {% endfor %} ({{ product.get_rating_count() }} reviews) {% else %} No ratings yet {% endif %}

${{ "%.2f"|format(product.price) }}

Description

{{ product.description }}

{% if current_user.is_authenticated %}
Rate this Product
{% for i in range(1, 6) %} {% endfor %}
{% if user_rating %} You rated this product {{ user_rating }} stars {% endif %}
{% else %}
Login to rate and review this product.
{% endif %}
{% if ratings %}

Customer Reviews

{% for rating in ratings %}
{{ rating.user.username }}
{% for i in range(5) %} {% if i < rating.rating %}★{% else %}☆{% endif %} {% endfor %}
{{ rating.created_at.strftime('%B %d, %Y') }}
{% if rating.review %}

{{ rating.review }}

{% endif %}
{% endfor %}
{% endif %} {% if related_products %}

Related Products

{% for related_product in related_products %}
{% if related_product.image_url %} {{ related_product.name }} {% else %}
{% endif %}
{{ related_product.name }}

{{ related_product.description[:80] }}{% if related_product.description|length > 80 %}...{% endif %}

{{ related_product.category }}
{% set related_avg_rating = related_product.get_average_rating() %} {% if related_avg_rating > 0 %} {% for i in range(5) %} {% if i < related_avg_rating %}★{% else %}☆{% endif %} {% endfor %} ({{ related_product.get_rating_count() }}) {% else %} No ratings yet {% endif %}
${{ "%.2f"|format(related_product.price) }} View Details
{% endfor %}
{% endif %}
{% endblock %} {% block extra_scripts %} {% endblock %}