Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
auction/auction/templates/my_items.html
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
85 lines (70 sloc)
4.36 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html"%} <!-- 'inherits' from the base.html file using jinga --> | |
{% block body %} | |
<h3 align="center">{{user.username}}'s items for sale:</h3> | |
<!-- displays a list of all the items put up by the current user, | |
using the relationship between the user and item tables --> | |
<!-- basically same code as home page, | |
but just displays the items the current user has up for sale --> | |
<br/> | |
<div class="row"> | |
{% for item in user.items %} <!-- for loop prints information about each item --> | |
<div class="col-12 col-md-6 col-lg-4 mb-4"> <!-- moves cards underneath eachother when tab is small --> | |
<!-- creates a card that displays a picture and info about the item--> | |
<div class="card" style="width: 18rem;"> | |
<!-- gets the relavent image from the static/images folder under the item_id.jpg --> | |
<img class="card-img-top border-bottom" src="/static/images/{{item.item_id}}.jpg"> | |
<div class="card-body"> | |
<!-- if statement changes card contents, including sold badge and actions buttons depending on sold value --> | |
{% if item.sold == True %} | |
<!-- shows a sold badge if the item has been marked as sold --> | |
<h5 class="card-title">{{item.item_name}} <span class="badge bg-success text-light">Sold</span></h5> | |
<main class="card-text">Sold for: £{{item.current_bid}}</main> | |
<p><small class="card-text text-muted">Added on {{item.date.strftime("%d/%m/%Y")}}</small></p> | |
<!-- dropdown with user actions regarding the item --> | |
<div class="dropdown"> | |
<a class="btn btn-dark dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-expanded="false"> | |
Actions | |
</a> | |
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> | |
<li><a class="dropdown-item" href="{{ url_for('routes.item_info', item_id=item.item_id)}}">More information</a></li> | |
<li><hr class="dropdown-divider"></li> | |
<li><a class="dropdown-item text-danger" href="{{ url_for('routes.item_delete', item_id=item.item_id)}}">Delete item</a></li> | |
</ul> | |
</div> | |
{% elif dt > item.auction_end %} | |
<!-- shows an expired badge if the auction has expired --> | |
<h5 class="card-title">{{item.item_name}} <span class="badge bg-danger text-light">Expired</span></h5> | |
{% if item.current_bid > 0 %} | |
<p class="card-text">Mark as sold to continue</p> | |
<a class="btn btn-danger" href="{{ url_for('routes.sold', item_id=item.item_id)}}" role="button">Mark as sold</a> | |
{% elif item.current_bid == 0 %} | |
<p class="card-text">Item did not sell</p> | |
<a class="btn btn-danger" href="{{ url_for('routes.item_delete', item_id=item.item_id)}}" role="button">Delete item</a> | |
{% endif %} | |
{% else %} | |
<h5 class="card-title">{{item.item_name}}</h5> | |
{% if item.current_bid == 0 %} | |
<main class="card-text">£{{item.price}}</main> | |
{% else%} | |
<main class="card-text">Current bid: £{{item.current_bid}}</main> | |
{% endif %} | |
<p><small class="card-text text-muted">Added on {{item.date.strftime("%d/%m/%Y")}}</small></p> | |
<!-- dropdown with user actions regarding the item --> | |
<div class="dropdown"> | |
<a class="btn btn-dark dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-expanded="false"> | |
Actions | |
</a> | |
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> | |
<li><a class="dropdown-item" href="{{ url_for('routes.item_info', item_id=item.item_id)}}">More information</a></li> | |
<li><a class="dropdown-item" href="{{ url_for('routes.sold', item_id=item.item_id)}}">Mark as sold</a></li> | |
<li><hr class="dropdown-divider"></li> | |
<li><a class="dropdown-item text-danger" href="{{ url_for('routes.item_delete', item_id=item.item_id)}}">Delete item</a></li> | |
</ul> | |
</div> | |
{% endif %} | |
</div> | |
</div> | |
</div> | |
{% endfor %} | |
</div> | |
{% endblock %} |