{% extends "base_generic.html" %}
{% load tags %}
{% block script %}
<script>
    $(document).ready(function(){
$('form').submit(function () {


    if () {
        alert('CID doubled');
        return false;
    }
});

});
</script>
{% endblock %}

{% block content %}

<div class="container-fluid">

<h3 style="margin-top: 10px"> {{user.username}}'s products </h3>

{% if product_list %}
 <table class="table table-sm table-hover">
    <caption>Projekte</caption>

     <thead class="">
    <tr>
        <th scope="col"></th>
        <th scope="col"> Projekt</th>
        <th scope="col"> </th>
        <th scope="col"> Bearbeiten</th>
        <th scope="col"> Löschen</th>
        <th scope="col"> Freischaltung beantragen</th>

    </tr>
    {% for product in product_list %}
    <tr class="{{ product.pk }}"   >
        <td  scope="col"><img src="{{product.media_set.first.image_small.url}}"  width="50" height="50" alt="{{ product.pk }}"> </td>
        <td  scope="col"> <a href="{% url 'product-detail' product.pk %}">   {{product.name|upper }} </a></td>
          <td scope="col">
        {% for category in product.category.all %}
        {{category.short_name}}{% if not forloop.last %} | {% endif %}
             {% endfor %}
        </td>
        <td scope="col"> {% if product.edit %} <a href="{% url 'projekt-bearbeiten' product.pk %}"> Projekt bearbeiten</a> ; <a href="{% url 'add-image' product.pk %}"> Media bearbeiten </a> {% else %} Es kann nicht bearbeitet werden {% endif %} </td>
        <td scope="col"> <a href="{% url 'product-delete' pk=product.pk %}" target="" rel="">Löschen</a>   </td>
        <td scope="col"> <a href="{% url 'product-publish' pk=product.pk %}" target="" rel="">Freischaltung</a>   </td>

    </tr>
    {% endfor %}




 </table>
    <a href="{% url 'neues-wohnprojekt' %}"><button class="btn border-dark rounded-0 mybtn" type="submit">Add product </button> </a>
 {% else %}
<div class="container-fluid">

    <h6>Scheint, als hättest du noch nichts eingetragen :( <br> Gib jetzt ein Projekt ein:<a href="{% url 'neues-wohnprojekt' %}"><button class="btn border-dark rounded-0 mybtn" type="submit">Projekt eintragen </button> </a></h6>
</div>

{% endif %}

{% endblock %}
