Added forms.py file. Added a modal in auction.html.

Attempted to link modal to db (failed)
Co-authored-by: 's avatarpinkboheme <pinkboheme@users.noreply.github.com>
Co-authored-by: 's avatarChristine <cdeeerrr@users.noreply.github.com>
parent a0267123
{% extends 'boodlesite\templates\base.html' %} a{% extends 'boodlesite\templates\base.html' %}
{% load static %} {% load static %}
{% block title %}Auction{% endblock %} {% block title %}Auction{% endblock %}
...@@ -50,10 +50,43 @@ ...@@ -50,10 +50,43 @@
<p>{{ item_specs }}</p> <p>{{ item_specs }}</p>
</div> </div>
<button class="btn-place-bid">Place Bid</button> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">Place Bid</button>
<h1>Latest Bids</h1> <h1>Latest Bids</h1>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Enter Bid</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Enter Bid amount:</label>
<form id="form" method="post">
<input type="number" class="form-control" id="amount">
{% csrf_token %}
</form>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Confirm Bid</button>
</div>
</div>
</div>
</div>
<h1>This is the Bid: {{ item_bid }}</h1>
<!-- latest bids / history --> <!-- latest bids / history -->
<ul class="cards"> <ul class="cards">
<li><img src="" alt=""> <li><img src="" alt="">
......
from django import forms
from django.forms import (ModelForm,
TextInput, Textarea, widgets)
from .models import *
class PlaceBidForm(forms.ModelForm):
class Meta:
model = AuctionBid
fields = ['amount']
...@@ -2,6 +2,7 @@ from django.shortcuts import render, redirect ...@@ -2,6 +2,7 @@ from django.shortcuts import render, redirect
from django.http import HttpResponse from django.http import HttpResponse
from .models import * from .models import *
from .forms import *
from datetime import datetime, timedelta from datetime import datetime, timedelta
...@@ -30,13 +31,14 @@ def homepage(request): ...@@ -30,13 +31,14 @@ def homepage(request):
def auction(request, pk): def auction(request, pk):
# Current auction ID # Current auction ID
auction = Auction.objects.get(pk=pk) auction = Auction.objects.get(pk=pk)
auction_bid = AuctionBid.objects.get(auctionid = pk)
auction_item = auction.itemid auction_item = auction.itemid
context = { context = {
'item_name':auction_item.itemname, 'item_name':auction_item.itemname,
'item_specs': auction_item.itemspecs 'item_specs': auction_item.itemspecs,
'item_bid' : auction_bid.amount
} }
if auction.auctionend < datetime.now(): if auction.auctionend < datetime.now():
...@@ -45,10 +47,3 @@ def auction(request, pk): ...@@ -45,10 +47,3 @@ def auction(request, pk):
return HttpResponse("This auction has not yet started.") return HttpResponse("This auction has not yet started.")
else: else:
return render(request, "boodlesite/templates/auction.html",context) return render(request, "boodlesite/templates/auction.html",context)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment