-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hidden input to listing forms that explicitly indicates which form wa…
…s submitted
- Loading branch information
1 parent
580a0f1
commit bed936f
Showing
3 changed files
with
126 additions
and
108 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
project_2/commerce/auctions/migrations/0010_alter_listing_category.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.1 on 2024-09-15 16:22 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('auctions', '0009_rename_last_modifed_by_listing_last_modified_by'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='listing', | ||
name='category', | ||
field=models.CharField(blank=True, choices=[('Electronics', 'Electronics'), ('Fashion', 'Fashion'), ('Home', 'Home'), ('Toys', 'Toys'), ('Books', 'Books'), ('Sports', 'Sports'), ('Health', 'Health'), ('Beauty', 'Beauty'), ('Jewelry', 'Jewelry'), ('Garden', 'Garden'), ('Music', 'Music')], max_length=64), | ||
), | ||
] |
162 changes: 79 additions & 83 deletions
162
project_2/commerce/auctions/templates/auctions/listing.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,91 @@ | ||
{% extends "auctions/layout.html" %} | ||
|
||
{% block title %} | ||
{{ title }} | ||
{% endblock %} | ||
|
||
{% block body %} | ||
{% extends "auctions/layout.html" %} {% block title %} {{ title }} {% endblock %} {% block body %} | ||
|
||
<h2>Listing: {{ listing.title }}</h2> | ||
|
||
{% if not listing.active %} | ||
<div class="alert alert-danger">This listing is closed.</div> | ||
{% if listing.last_modified_by == user %} | ||
<div class="alert alert-success">Congratulations! You have won this auction.</div> | ||
{% endif %} | ||
{% endif %} | ||
<div class="alert alert-danger">This listing is closed.</div> | ||
{% if listing.last_modified_by == user %} | ||
<div class="alert alert-success">Congratulations! You have won this auction.</div> | ||
{% endif %} {% endif %} | ||
|
||
<div class="listing"> | ||
<div class="listing-top"> | ||
{% if listing.imageURL %} | ||
<img src= "{{ listing.imageURL }}" alt="listingImage" height="400px" class="listing-image-single"> | ||
<div class="listing-top"> | ||
{% if listing.imageURL %} | ||
<img | ||
src="{{ listing.imageURL }}" | ||
alt="listingImage" | ||
height="400px" | ||
class="listing-image-single" | ||
/> | ||
{% else %} | ||
<div class="placeholder-rectangle-listing"></div> | ||
{% endif %} | ||
<div class="bid"> | ||
<h4 class="listing-bid">{{ listing.bid }}€</h4> | ||
{% if user.is_authenticated %} | ||
<form action="{% url 'listing' listing.title %}" method="post" class="bid-form"> | ||
{% csrf_token %} {{ form.as_p }} | ||
<input type="hidden" name="form_type" value="bid_form" /> | ||
<!-- Other form elements --> | ||
<button type="submit" class="btn btn-primary btn-submit">Submit</button> | ||
</form> | ||
|
||
<form method="post"> | ||
{% csrf_token %} {% if listing in user.watchlist.all %} | ||
<button type="submit" name="remove_from_watchlist" class="btn btn-danger"> | ||
Remove from Watchlist | ||
</button> | ||
{% else %} | ||
<div class="placeholder-rectangle-listing"></div> | ||
<button type="submit" name="add_to_watchlist" class="btn btn-primary"> | ||
Add to Watchlist | ||
</button> | ||
{% endif %} | ||
<div class = "bid"> | ||
<h4 class="listing-bid">{{ listing.bid }}€</h4> | ||
{% if user.is_authenticated %} | ||
<form action="{% url 'listing' listing.title %}" method="post" class="bid-form"> | ||
<div class="mb-3"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
{% if messages %} | ||
<div> | ||
{% for message in messages %} | ||
<div class="alert custom-alert {% if message.tags %}alert-{{ message.tags }}{% else %}alert-info{% endif %}" role="alert"> | ||
<div>{{ message | safe }}</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
<button type="submit" class="btn btn-primary btn-submit">Submit</button> | ||
</div> | ||
</form> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{% if listing in user.watchlist.all %} | ||
<button type="submit" name="remove_from_watchlist" class="btn btn-danger">Remove from Watchlist</button> | ||
{% else %} | ||
<button type="submit" name="add_to_watchlist" class="btn btn-primary">Add to Watchlist</button> | ||
{% endif %} | ||
</form> | ||
{% if user == listing.created_by %} | ||
<form method="post"> | ||
{% csrf_token %} | ||
{% if listing.active == True %} | ||
<button type="submit" name="close_listing" class="btn btn-danger">Close Listing</button> | ||
{% endif %} | ||
</form> | ||
{% endif %} | ||
{% endif %} | ||
|
||
</div> | ||
<div class = "listing-details"> | ||
<div>Category: {{ listing.category }}</div> | ||
<div>Listed by {{ listing.created_by }}</div> | ||
<div>Last Bid by {{ listing.last_modified_by }}</div> | ||
<div>Created time: {{ listing.created_at }}</div> | ||
<div>Updated time: {{ listing.updated_at }}</div> | ||
<div>Statuse: | ||
{%if listing.active%} | ||
<span class="badge text-bg-success">Active</span> | ||
{% else %} | ||
<span class="badge text-bg-danger">Closed</span> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</form> | ||
{% if user == listing.created_by %} | ||
<form method="post"> | ||
{% csrf_token %} {% if listing.active == True %} | ||
<button type="submit" name="close_listing" class="btn btn-danger">Close Listing</button> | ||
{% endif %} | ||
</form> | ||
{% endif %} {% endif %} | ||
</div> | ||
<div class="listing-details"> | ||
<div>Category: {{ listing.category }}</div> | ||
<div>Listed by {{ listing.created_by }}</div> | ||
<div>Last Bid by {{ listing.last_modified_by }}</div> | ||
<div>Created time: {{ listing.created_at }}</div> | ||
<div>Updated time: {{ listing.updated_at }}</div> | ||
<div> | ||
Statuse: {%if listing.active%} | ||
<span class="badge text-bg-success">Active</span> | ||
{% else %} | ||
<span class="badge text-bg-danger">Closed</span> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="listing-bottom"> | ||
<p class="listing-description-heading">Description</p> | ||
<p class="listing-description">{{ listing.description }}</p> | ||
<div class="comments"> | ||
<p class="listing-description-heading">Comments</p> | ||
{% if user.is_authenticated %} | ||
<form action="{% url 'listing' listing.title %}" method="post"> | ||
{% csrf_token %} | ||
{{ comment_form.as_p }} | ||
<button type="submit" class="btn btn-primary" name="comment">Add Comment</button> | ||
</form> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="listing-bottom"> | ||
<p class="listing-description-heading">Description</p> | ||
<p class="listing-description">{{ listing.description }}</p> | ||
<div class="comments"> | ||
<p class="listing-description-heading">Comments</p> | ||
{% if user.is_authenticated %} | ||
<form action="{% url 'listing' listing.title %}" method="post"> | ||
{% csrf_token %} {{ comment_form.as_p }} | ||
<input type="hidden" name="form_type" value="comment_form" /> | ||
<button type="submit" class="btn btn-primary">Add Comment</button> | ||
</form> | ||
|
||
{% endif %} {% for comment in comments %} | ||
<div class="comment-item"> | ||
<p><strong>{{ comment.commenter.username }}</strong> ({{ comment.timestamp }}):</p> | ||
<p>{{ comment.comment }}</p> | ||
</div> | ||
{% empty %} | ||
<p>No comments yet. Be the first to comment!</p> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{% endblock %} | ||
{% endblock %} |
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