Commit 96fb76e7 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

modified template names

parent ad78c7eb
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare • Create Listing
{% endblock %}
{% block content %}
{% load crispy_forms_tags %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Create Listing</strong></p>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="well">
<div class="row">
{% crispy form %}
</div>
</div>
</div>
</div>
{% endblock %}
{% extends 'layouts/base.html' %}
{% load thumbnail %}
{% block title %}
SRCT Bookshare &bull; {{listing.title}}
{% endblock %}
{% block content %}
<div class="page-header" id="banner">
{% if listing.sold %}
<div class="row">
<div class="col-lg-12">
<div class="alert alert-danger text-center">
<strong>This listing has been sold.</strong>
</div>
</div>
</div>
{% elif not listing.active %}
<div class="row">
<div class="col-lg-12">
<div class="alert alert-danger text-center">
<strong>This listing has been closed.</strong>
</div>
</div>
</div>
{% elif old %}
<div class="row">
<div class="col-lg-12">
<div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">&times;</button>
Heads up, this listing is <strong>over a month old</strong> and may no longer be valid!
</div>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-md-8 col-sm-6 col-xs-12">
<h1>
<em>{{ listing.title }}</em>
</h1>
<h4>
<small>by</small> {{ listing.author }}
{% if listing.year %}
({{ listing.year }})
{% endif %}
</h4>
<h4>
{% if listing.edition %}
{{ listing.edition }}<small>th edition</small> |
{% endif %}
<small>ISBN</small> {{ listing.isbn }}
</h4>
</div>
<div class="col-md-4 col-sm-6 col-xs-12 text-right">
<h1>
{% if listing.sold %}
${{ listing.finalPrice }}
{% else %}
${{ listing.price }}
{% endif %}
</h1>
<h4><small>Listed</small> {{ listing.created|date:"M d y P" }}</h4>
Sold by<a href="{% url 'profile' listing.seller.username %}"> {{ listing.seller.username }}</a> |
<span class="label label-danger"><strong><a href="#"><i class="fa fa-flag"></i> Report</a></strong></span>
{% if request.user == listing.seller.user %}
<br /><a href="{% url 'profile' request.user.get_absolute_url %}">Manage Listing</a>
{% endif %}
</div>
</div>
</div>
<div class ="row">
<div class="col-md-3 col-sm-12 col-xs-12">
<div class="text-center">
<a href="{{ media }}{{ listing.photo }}" class="thumbnail">
<img src="{{ listing.photo|thumbnail_url:'listing_photo' }}"
alt="User submitted textbook photo" class="img-thumbnail" />
</a>
</div>
</div>
<div class="col-md-2 col-sm-12 col-xs-12">
<h4><small>Condition</small> {{ listing.condition }}</h4>
</div>
<div class="col-md-6 col-sm-12 col-xs-12">
<h4><small>Description/Comments</small>
{% if listing.description %}
{{ listing.description }}
{% else %}
None provided.</h4>
{% endif %}
</div>
<div class="col-md-1 col-sm-12 col-xs-12">
<h4><strong>ENGH 302</strong></h4>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="panel panel-default" style="margin-top:10px;">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#bids">
Hide/Show Bids ({{ bid_count }})
</a>
</h4>
</div>
<div class="panel-body">
{% if bids %}
<div id="bids" class="panel-collapse collapse in">
{% endif %}
{% for bid in bids %}
<!-- BID DISPLAY -->
<div class="row">
<div class="col-lg-3">
<a href="{{ bid.bidder.get_absolute_url }}">
{{ bid.bidder.user.first_name }}
{{ bid.bidder.user.last_name }}
</a>
</div>
<div class="col-lg-2">
<h4><small>{{ bid.created|date:"M d y P" }}</small></h4>
</div>
<div class="col-lg-6">
<h4>
{% if bid.text %}
{{ bid.text }}
{% else %}
{% endif %}
</h4>
</div>
<div class="col-lg-1">
<h4><strong>${{ bid.price }}</strong></h4>
</div>
</div>
<hr/>
<!-- BID DISPLAY -->
{% endfor %}
{% if bids %}
</div>
{% endif %}
<!-- BID FORM -->
<div class="row">
<div class="col-lg-12">
{% if listing.active and not listing.sold %}
<form class="form-horizontal" action="" method="post" role="form">
{% csrf_token %}
<fieldset>
<legend>Your Bid</legend>
<div class="form-group has-error">
<div class="col-lg-10 col-lg-offset-2">
{% for error in bid_form.non_field_errors %}
<span class="help-block">{{ error }}</span>
{% endfor %}
{% if listing.seller.user == request.user %}
<span class="help-block">You can't bid on your own
listing!</span>
{% endif %}
</div>
</div>
<div class="form-group{%if bid_form.price.errors%} has-error{%endif%}">
<label for="{{bid_form.price.id_for_label}}"
class="col-lg-2 control-label">
{{bid_form.price.label}}
</label>
<div class="col-lg-10">
<div class="input-group">
<span class="input-group-addon"> $ </span>
{% if listing.seller.user == request.user %}
<input type="text" class="form-control"
placeholder="Price" disabled>
{% else %}
{{bid_form.price}}
{% endif %}
</div>
{%for error in bid_form.price.errors%}
<span class="help-block">{{ error }}</span>
{%endfor%}
</div>
</div>
<div class="form-group{%if bid_form.text.errors%} has-error{%endif%}">
<label for="{{bid_form.text.id_for_label}}"
class="col-lg-2 control-label">
{{bid_form.text.label}}
</label>
<div class="col-lg-10">
{% if listing.seller.user == request.user %}
<textarea class="form-control" rows="3"
disabled></textarea>
{% else %}
{{bid_form.text}}
{% endif %}
{%for error in bid_form.text.errors%}
<span class="help-block">{{ error }}</span>
{%endfor%}
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
{% if listing.seller.user == request.user %}
<button type="submit" class="btn btn-primary"
value="Submit" disabled="">Submit a Bid</button>
{% else %}
<button type="submit" class="btn btn-primary"
value="Submit">Submit a Bid</button>
{% endif %}
</div>
</div>
</fieldset>
</form>
{% else %}
<h5 class="text-center">You cannot bid on an incative listing.</h5>
{% endif %}
</div>
</div>
<!-- BID FORM -->
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare &bull; Latest Listings
{% endblock %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12">
<h1 class="text-center"><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Latest Listings</strong></p>
</div>
</div>
</div>
{% if listings %}
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<p>Want to <strong><a href="/search">search</a></strong> for something specific?</p>
</div>
</div>
<div class="row">
{% comment %}
Essentially the logic here is to create 3 columns where
there are n rows in each.
The first conditional will add an initial column tag if the loop is
beginning a new column. The second conditional adds a closing column
tag when the loop ends a column.
{% endcomment %}
{% for listing in listings %}
{% if forloop.counter|add:-1|divisibleby:rows %}
<div class="col-md-4">
{% endif %}
{% include 'listing_preview_panel.html' %}
{% if forloop.counter|add:rows|divisibleby:rows %}
</div>
{% endif %}
{% endfor %}
</div>
<div class="row">
<div class="col-lg-4 col-lg-offset-4">
<ul class="pager">
{% if listings.has_previous %}
<li class="previous">
<a href="?page={{ listings.previous_page_number }}">
&larr; Newer
</a>
</li>
{% else %}
<li class="previous disabled">
<a>
&larr; Newer
</a>
</li>
{% endif %}
{% if listings.has_next %}
<li class="next">
<a href="?page={{ listings.next_page_number }}">
Older &rarr;
</a>
</li>
{% else %}
<li class="next disabled">
<a>
Older &rarr;
</a>
</li>
{% endif %}
</ul>
</div>
</div>
{% else %}
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<div class="panel panel-warning">
<div class="panel-body">
<h3>There aren't any books in the database!</h3>
<p>
Looks like you'll be the first to <a href="#">create one</a>!
</p>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}
......@@ -11,21 +11,21 @@ urlpatterns = patterns('',
paginate_by = 15,
queryset=Listing.objects.all().order_by('-created'),
context_object_name='listings',
template_name='listListings.html'),
name='all_listings'),
template_name='list_listings.html'),
name='list_listings'),
url(r'^new/$',
CreateListing.as_view(
model=Listing,
template_name='createListing.html'),
name='createListing'),
template_name='create_listing.html'),
name='create_listing'),
url(r'^(?P<slug>[\w-]+)/$',
url(r'^listing/(?P<slug>[\w-]+)/$',
DetailListing.as_view(
model=Listing,
# slug_field='slug__exact',
context_object_name='listing',
template_name='listing.html'),
name='listing'),
template_name='detail_listing.html'),
name='detail_listing'),
)
......@@ -70,16 +70,14 @@ class DetailListing(LoginRequiredMixin, DetailView):
login_url = '/'
"""
# Listing page
def view_listing(request, book_id):
# Grab the listing itself
listing = get_object_or_404(Listing,pk=book_id)
# grab the bidder
bidder = request.user.seller
class CreateListing(LoginRequiredMixin, CreateView):
model = Listing
form_class = ListingForm
# ISBN query!
#success_url = '/'
login_url = '/'
"""
# if the listing is over a week old, it's old
old_threshold = timezone.now() - timedelta(weeks=3)
......@@ -87,24 +85,6 @@ def view_listing(request, book_id):
bids = Bid.objects.filter( listing = listing )
bid_count = len(bids)
bid_form = BidForm()
if request.method == 'POST' and listing.active and not listing.sold:
if listing.active and not listing.sold:
bid_form = BidForm( request.POST.copy() )
# Override whatever the user may have input into the bidder and
# listing fields (hopefully they will not have set these values
# anyway).
bid_form.data['bidder'] = bidder.pk
bid_form.data['listing'] = listing.pk
if bid_form.is_valid():
bid = bid_form.save(commit=False)
bid.bidder = bidder
bid.listing = listing
bid.full_clean()
bid.save()
return redirect( 'view_listing', listing.pk )
return render(request, 'listing.html', {
'listing' : listing,
......@@ -116,10 +96,3 @@ def view_listing(request, book_id):
},
)
"""
class CreateListing(LoginRequiredMixin, CreateView):
model = Listing
form_class = ListingForm
# ISBN query!
success_url = '/'
login_url = '/'
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