Commit 1a2173fb authored by Daniel W Bond's avatar Daniel W Bond
Browse files

added course to listings

parent 15dfe400
......@@ -74,3 +74,15 @@ body .modal-dialog {
.modal-backdrop {
opacity:0.9 !important;
}
@media (max-width: 991px) {
.small-text-right {
text-align: right;
}
}
@media (max-width: 991px) {
.small-text-center {
text-align: center;
}
}
......@@ -25,7 +25,7 @@ class ListingForm(forms.ModelForm):
placeholder='Richard W. Thorington, Jr., and Katie Ferrell'),
'edition',
Field('year', placeholder='2006'),
#'course',
Field('course_abbr', placeholder='ENGH 302'),
'condition',
'access_code',
AppendedPrependedText('price', '$', '.00',
......@@ -45,6 +45,7 @@ class ListingForm(forms.ModelForm):
super(ListingForm, self).__init__(*args, **kwargs)
self.fields['isbn'].label = "ISBN"
self.fields['course_abbr'].label = "Course"
self.fields['description'].label = "Other Notes"
class Meta:
......
......@@ -57,6 +57,9 @@ class Listing(TimeStampedModel):
max_length=20, default=GOOD)
access_code = models.CharField(choices=ACCESS_CODE_CHOICES,
max_length=30, default=NOT_APPLICABLE)
course_abbr = models.CharField(max_length=10, blank=True,
validators=[RegexValidator('^([a-zA-Z]){2,4}( )?(\d){3}$',
message='Please enter a valid course.')])
description = models.TextField(blank=True, max_length=2000)
price = models.PositiveIntegerField(default=0,
validators=[MaxValueValidator(1000)])
......
......@@ -16,7 +16,7 @@ class ListingIndex(indexes.SearchIndex, indexes.Indexable):
ISBN = indexes.CharField(model_attr='isbn')
condition = indexes.CharField(model_attr='condition')
description = indexes.CharField(model_attr='description')
#course = indexes.CharField(model_attr='course')
course_abbr = indexes.CharField(model_attr='course_abbr')
def get_model(self):
return Listing
......
......@@ -106,11 +106,11 @@ SRCT Bookshare • {{ listing.title }}
</div>
<div class="row">
<div class="col-md-3 col-sm-4 col-xs-4">
<div class="col-md-3 col-sm-6 col-xs-6">
<h4><small>ISBN</small> {{ listing.isbn }}</h4>
</div>
<div class="col-md-2 col-sm-4 col-xs-4">
<div class="col-md-2 col-sm-6 col-xs-6 small-text-right">
<h4>
{% if listing.edition %}
{{ listing.edition|ordinal }}<small> edition</small>
......@@ -118,13 +118,11 @@ SRCT Bookshare &bull; {{ listing.title }}
</h4>
</div>
<div class="col-md-2">
{% comment %}
<h4><small>Course</small> ENGH 302 </h4>
{% endcomment %}
<div class="col-md-3 col-sm-6 col-xs-6">
<h4><small>Course</small>{{ listing.course_abbr }}</h4>
</div>
<div class="col-md-7 col-sm-4 col-xs-4 text-right">
<div class="col-md-4 col-sm-6 col-xs-6 text-right">
<h4><small>Sold by</small><a href="{% url 'profile' listing.seller.user.username %}"> {{ listing.seller.user.first_name }} {{ listing.seller.user.last_name }}</a>
{% if request.user == listing.seller.user %}
(Me)
......@@ -133,15 +131,15 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
<div class="row">
<div class="col-md-3 col-sm-4 col-xs-4">
<div class="col-md-3 col-sm-6 col-xs-6">
<h4><small>Condition</small> {{ listing.condition }}</h4>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-6 col-xs-6 small-text-right">
<h4><small>Access Code</small> {{ listing.access_code }}</h4>
</div>
<div class="col-md-2 col-md-offset-3 col-sm-4 col-xs-4 text-right">
<div class="col-md-5 text-right small-text-center">
{% if request.user == listing.seller.user %}
{% else %}
{% if can_flag %}
......@@ -165,11 +163,7 @@ SRCT Bookshare &bull; {{ listing.title }}
<div class="col-md-9 col-sm-6 col-xs-12">
<h4><small>Description/Comments</small>
{% if listing.description %}
{{ listing.description }}
{% else %}
None provided.</h4>
{% endif %}
</div>
</div>
......@@ -209,7 +203,7 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
{% else %}
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-12">
<div class="panel panel-default" style="margin-top:10px;">
<div class="panel-heading">
<h4 class="panel-title">
......@@ -222,7 +216,7 @@ SRCT Bookshare &bull; {{ listing.title }}
{% crispy my_form %}
</div>
{% else %}
<div class="col-lg-12">
<div class="col-md-12">
<h5 class="text-center">This listing has been
{% if listing.cancelled %}
cancelled
......@@ -240,7 +234,7 @@ SRCT Bookshare &bull; {{ listing.title }}
{% endif %}
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-12">
<div class="panel panel-default" style="margin-top:10px;">
<div class="panel-heading">
<h4 class="panel-title text-center">
......@@ -259,18 +253,18 @@ SRCT Bookshare &bull; {{ listing.title }}
<!-- BID DISPLAY -->
<div class="row">
<div class="col-lg-3 text-center">
<div class="col-md-3 col-sm-6 col-xs-6 text-center">
<h4><a href="{{ bid.bidder.get_absolute_url }}">
{{ bid.bidder.user.first_name }}
{{ bid.bidder.user.last_name }}
</a></h4>
</div>
<div class="col-lg-2">
<div class="col-md-2 col-sm-6 col-xs-6 small-text-center">
<h4><small>{{ bid.created|naturaltime }}</small></h4>
</div>
<div class="col-lg-5">
<div class="col-md-5 col-sm-6 col-xs-6 small-text-center">
<h4><small>
{% if bid.text %}
{{ bid.text }}
......@@ -279,7 +273,7 @@ SRCT Bookshare &bull; {{ listing.title }}
</small></h4>
</div>
<div class="col-lg-2 text-center">
<div class="col-md-2 col-sm-6 col-xs-6 text-center">
{% if bid == listing.winning_bid %}
<h4><small><span class="label label-success">Winning Bid</span></small> <strong>${{ bid.price }}</strong></h4>
{% else %}
......
......@@ -4,5 +4,6 @@
{{ object.year }}
{{ object.condition }}
{{ object.edition }}
{{ object.course_abbr }}
{{ object.description }}
{{ object.created }}
......@@ -64,8 +64,8 @@ class ListListings(LoginRequiredMixin, ListView):
class CreateListing(LoginRequiredMixin, CreateView):
model = Listing
fields = ['isbn', 'title', 'author', 'edition', 'year', 'condition',
'access_code', 'price', 'photo', 'description']
fields = ['isbn', 'title', 'author', 'edition', 'year', 'course_abbr',
'condition', 'access_code', 'price', 'photo', 'description']
template_name = 'create_listing.html'
context_object_name = 'listing'
# ISBN query!
......
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