{% extends "lfs/base.html" %}
{% load i18n %}

{% block section %}add-review {% endblock %}
{% block left-slot-wrapper %}{% endblock %}
{% block right-slot-wrapper %}{% endblock %}

{% block content %}

    <h1>{% trans 'Add Review' %}</h1>
    
    <img class="image-left" 
         src="{{object.get_image.url_200x200}}" 
         width="100px" />
    <div>{{ object.get_name }}</div>
    <br clear="all" />
     
    <form action="{% url reviews_add content_type_id content_id %}"
          method="post">

        {% if request.user.is_anonymous %}
            <div class="field">
                <div class="label">
                    {{ form.user_name.label_tag }}:
                </div>

                {% if form.user_name.errors %}
                    <div class="error">
                        {{ form.user_name }}
                        {{ form.user_name.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.user_name }}
                    </div>
                {% endif %}
            </div>

            <div class="field">
                <div class="label">
                    {{ form.user_email.label_tag }}:
                </div>

                {% if form.user_email.errors %}
                    <div class="error">
                        {{ form.user_email }}
                        {{ form.user_email.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.user_email }}
                    </div>
                {% endif %}
            </div>
        {% endif %}

        <div class="label">
            {{ form.score.label_tag }}:
        </div>
        <div class="star-rating-wrapper">
            {% if form.score.errors %}            
                <div class="field error">
                    {{ form.score.errors }}
                </div>            
            {% endif %}
            <ul class="star-rating">
                {% for score in scores %}
                    <li>
                        <a href="#" 
                           class="rate {% if score.current %}current-rating{% endif %}"
                           title="{{score.title}}"
                           data="{{score.value}}"
                           style="z-index:{{score.z_index}}; width:{{score.width}}px">
                        </a>
                    </li>
                {% endfor %}
            </ul>
        </div>
        <div class="field">
            <div class="label">
                {{ form.comment.label_tag }}:
            </div>

            {% if form.comment.errors %}
                <div class="error">
                    {{ form.comment }}
                    {{ form.comment.errors }}
                </div>
            {% else %}
                <div>
                    {{ form.comment }}
                </div>
            {% endif %}
        </div>

        <input type="hidden"
               name="score"
               id="id_score" 
               value="{{request.POST.score}}" />

        <input type="hidden"
               name="content_type_id"
               value="{{content_type_id}}" />

        <input type="hidden"
               name="content_id"
               value="{{content_id}}" />

        {% if show_preview %}
            <input type="submit" 
                   value="{% trans 'Preview' %}" />
        {% else %}               
            <input type="submit" 
                   value="{% trans 'Send' %}" />        
        {% endif %}
        
    </form>
    
{% endblock %}
