Priyatham-sai-chand/auctions/templates/auctions/index.html

80 lines
3.2 KiB
HTML

{% extends "auctions/layout.html" %}
{% block body %}
<h2>Active Listings</h2>
<div class="row">
{% for listing in Listings %}
<div class="col-lg-3 mb-10">
<a href="listing/{{ listing.title}}" style = "color:inherit;text-decoration: none;">
<div class="card border-light" style="width: 18rem;">
<div class="shadow p-2 mb-2 bg-white rounded">
<img class="card-img-top" src="{{ listing.picture }}" alt="Preview not found">
<hr>
<div class="card-body">
<h4>{{ listing.title }}</h4><br>
{% if not listing.closed %}
<p class="card-text" style="font-size: medium;">
{% for bidding in listing.bidding_listing.all %}
<b>bid price</b> : ${{bidding.bid_value}}<br>
<b>Last bid by</b>: {{bidding.user}}
<br>
<b>created by</b>: {{listing.user}}<br>
{% endfor %}
<small class="text-muted"><i> created on {{listing.date_added}}</i> </small>
</p>
{% else %}
<p class="card-text" style="font-size: medium;">
<strong style="color:red;">CLOSED</strong>
<br>
This listing is over.
<br>
<br>
{% for bidding in listing.bidding_listing.all %}
{% if user == bidding.user %}
<b>You won this listing!!!</b>
{% else %}
<b>This is won by <strong style="color:navy;font-size: large;">@{{ bidding.user }}</strong></b>
for <strong>${{bidding.bid_value}}</strong>
{% endif %}
{% endfor %}
</p>
{% endif %}
<div class = "text-right">
{% if listing.closed %}
{% elif user.is_authenticated %}
<form action="{% url 'watch' listing.title %}" method="POST">
{% csrf_token %}
{% if user not in listing.watchlists.all %}
<button type="submit" name="watch", value="{{user}}", class="btn btn-primary btn-sm">Watch</button>
{% else %}
<button type="submit" name="watch", value="{{user}}", class="btn btn-secondary btn-sm">Unwatch</button>
{% endif %}
<input type="hidden" name="previous" value="{{ request.path }}">
</form>
{% else %}
<small>log in to watch this listing</small>
{% endif %}
</div>
</div>
</div>
</div>
</a>
</div>
{% endfor %}
</div>
{% endblock %}