Commit 1a9d8079 authored by Daniel W Bond's avatar Daniel W Bond

improved accuracy -- sold to exchanged

parent 133bb269
......@@ -64,7 +64,7 @@ SRCT Bookshare • {{ student.user.get_full_name }}
</thead>
{% for listing in listings %}
<tbody>
{% if listing.sold %}
{% if listing.exchanged %}
<tr class="success">
{% else %}
<tr>
......@@ -72,7 +72,7 @@ SRCT Bookshare &bull; {{ student.user.get_full_name }}
<td class="text-center"><h5>{{ listing.isbn }}</h5></td>
<td class="text-center"><h5><a href="{{ listing.get_absolute_url }}">{{ listing.title|title }}</h5></a></td>
<td class="text-center"><h5>
{% if listing.sold %}
{% if listing.exchanged %}
${{ listing.final_price }}
{% else %}
${{ listing.price }}
......@@ -80,10 +80,10 @@ SRCT Bookshare &bull; {{ student.user.get_full_name }}
</h5></td>
<td class="text-center"><h5>{{ listing.bids|length }}</h5></td>
<td class="text-center"><h5>
{% if listing.sold %}
<span class="label label-primary"><strong>Sold</strong></span>
{% if listing.exchanged %}
<span class="label label-primary"><strong>Exchanged</strong></span>
{% if student.user == request.user %}
<small>(<a href="{% url 'unsell_listing' listing.slug %}">Cancel Sale</a>)</small>
<small>(<a href="{% url 'unsell_listing' listing.slug %}">Cancel Exchange</a>)</small>
{% endif %}
{% elif listing.cancelled %}
<span class="label label-default"><strong>Cancelled</strong></span>
......@@ -105,7 +105,7 @@ SRCT Bookshare &bull; {{ student.user.get_full_name }}
</table>
{% if student.user == request.user %}
<h4>
<strong>Total Sales:</strong> {{ sales }} |
<strong>Total Exchanges:</strong> {{ exchanges }} |
<strong>Total Proceeds:</strong> ${{ proceeds }}
</h4>
{% endif %}
......@@ -148,8 +148,8 @@ SRCT Bookshare &bull; {{ student.user.get_full_name }}
<td class="text-center"><h5>{{ bid.created|date:"m/d/y" }}</h5></td>
<td class="text-center"><h5><a href="{{ bid.listing.get_absolute_url }}">{{ bid.listing.isbn|isbn_name|title }}<a/></h5></td>
<td class="text-center"><h5>
{% if bid.listing.sold %}
<span class="label label-primary"><strong>Sold</strong></span>
{% if bid.listing.exchanged %}
<span class="label label-primary"><strong>Exchanged</strong></span>
{% elif bid.listing.cancelled %}
<span class="label label-default"><strong>Cancelled</strong></span>
{% elif not listing.active %}
......
......@@ -20,9 +20,9 @@ class DetailStudent(LoginRequiredMixin, DetailView):
student_listings = Listing.objects.filter(seller=self.get_object().pk)
total_sales = student_listings.filter(sold=True).count()
total_exchanges = student_listings.filter(exchanged=True).count()
total_proceeds = Bid.objects.filter(listing__seller__user=self.get_object()).filter(listing__sold=True).aggregate(Sum('price'))['price__sum']
total_proceeds = Bid.objects.filter(listing__seller__user=self.get_object()).filter(listing__exchanged=True).aggregate(Sum('price'))['price__sum']
student_ratings = Rating.objects.filter(listing__seller__user=self.get_object())
if student_ratings:
......@@ -37,7 +37,7 @@ class DetailStudent(LoginRequiredMixin, DetailView):
context['lookouts'] = Lookout.objects.filter(owner=self.get_object())
context['proceeds'] = total_proceeds
context['sales'] = total_sales
context['exchanges'] = total_exchanges
context['bids'] = Bid.objects.filter(bidder=self.get_object())
......
......@@ -21,7 +21,7 @@ class Lookout(TimeStampedModel):
slug = RandomSlugField(length=6)
def get_listings(self):
isbn_listings = models.Q(isbn=self.isbn, sold=False, cancelled=False)
isbn_listings = models.Q(isbn=self.isbn, exchanged=False, cancelled=False)
return Listing.objects.filter(isbn_listings)
def get_absolute_url(self):
......
......@@ -20,7 +20,7 @@ SRCT Bookshare &bull; Lookouts
<div class="row">
{% for listing in lookout.get_listings %}
{% if not listing.cancelled or listing.sold %}
{% if not listing.cancelled or listing.exchanged %}
<div class="col-md-6">
{% include 'listing_preview_panel.html' %}
</div>
......
......@@ -22,7 +22,7 @@ PIWIK_SITE_ID = ''
PIWIK_URL = ''
# configurations to send email via Amazon SES
# if you do not set these, you simply won't be able to mark listings sold
# if you do not set these, you simply won't be able to mark listings exchanged
EMAIL_HOST = 'email-smtp.region-code.amazonaws.com'
EMAIL_HOST_USER = 'ses-smtp-username'
EMAIL_HOST_PASSWORD = 'ses-smtp-password'
......
......@@ -35,8 +35,8 @@ class ChartsView(LoginRequiredMixin, TemplateView):
grossing = []
# set to eliminate duplicates
for isbn in set(all_isbns):
# only want sold listings (not cancelled is assumed)
listings = Listing.objects.exclude(sold=False).filter(isbn=isbn)
# only want exchanged listings (not cancelled is assumed)
listings = Listing.objects.exclude(exchanged=False).filter(isbn=isbn)
# make list of all of that listing's final prices (assume no Nones)
listing_winning_bids = [listing.final_price() for listing in listings]
# add all those together
......
......@@ -11,7 +11,7 @@ SRCT Bookshare &bull; Homepage
<div class="col-md-12 license">
<div class="jumbotron jumboindex">
<h1 class="text-center"><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<h3 class="text-center">A place for Mason students to buy and sell textbooks.</h3>
<h3 class="text-center">A place for Mason students to exchange textbooks.</h3>
</div>
<a href="https://creativecommons.org/licenses/by/4.0/" target="_blank"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/80x15.png" title="'Mason Statue Desktop' by Daniel Bond is licensed under a Creative Commons Attribution 4.0 International License."/></a>
</div>
......@@ -28,7 +28,7 @@ SRCT Bookshare &bull; Homepage
<legend><i class="fa fa-book"></i> <a href="{{ lookout.get_absolute_url }}">{{ lookout.isbn|isbn_name|title }}</a></legend>
<div class="row">
{% for listing in lookout.get_listings %}
{% if not listing.cancelled or listing.sold %}
{% if not listing.cancelled or listing.exchanged %}
<div class="col-md-6">
{% include 'listing_preview_panel.html' %}
</div>
......@@ -74,11 +74,11 @@ SRCT Bookshare &bull; Homepage
</div>
<div class="col-sm-3 text-center">
<h3><i class="fa fa-gift fa-lg"></i></h3>
<h4>Sell your used textbooks to Mason students</h4>
<h4>Exchange your used textbooks with Mason students</h4>
</div>
<div class="col-sm-3 text-center">
<h3><i class="fa fa-book fa-lg"></i></h3>
<h4>Search for textbooks by course, price, and more</h4>
<h4>Search for textbooks by course and more</h4>
</div>
<div class="col-sm-3 text-center">
<h3><i class="fa fa-eye fa-lg"></i></h3>
......
......@@ -4,7 +4,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="A place for Mason students to buy and sell textbooks.">
<meta name="description" content="A place for Mason students to exchange textbooks.">
{% load static from staticfiles %}
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" media="screen">
<link href="{% static 'css/bootswatch.min.css' %}" rel="stylesheet" media="screen">
......
......@@ -15,7 +15,8 @@ class BidAdmin(admin.ModelAdmin):
class ListingAdmin(admin.ModelAdmin):
list_display = ('id', 'created', 'modified', 'title', 'author', 'isbn',
'year', 'edition', 'condition', 'description',
'price', 'sold', 'cancelled', 'winning_bid', 'date_closed')
'price', 'exchanged', 'cancelled', 'winning_bid',
'date_closed')
list_filter = ('created', 'modified', 'seller', 'condition',
'price', 'cancelled')
......
......@@ -131,7 +131,7 @@ class SellListingForm(forms.ModelForm):
placeholder='Do you want to meet tomorrow by the JC Info Desk at 4?'),
HTML("""<em><p>Thanks for using SRCT Bookshare!</p><p>Mason SRCT</p></em></div>"""),
HTML("""<hr/ >"""),
FormActions(Submit('submit', 'Email and Sell',
FormActions(Submit('submit', 'Email and Exchange',
css_class='btn-primary'),
Button('cancel', 'Never Mind',
css_class='btn-default',
......@@ -160,11 +160,10 @@ class UnSellListingForm(forms.ModelForm):
Fieldset("",
HTML("""<strong>Your Email to Your Bidder</strong>"""),
HTML("""<div class="well"><em><p>Hey there!</p><p>Seller {{ listing.seller.user.first_name }} {{ listing.seller.user.last_name }} has cancelled your bid for {{ listing.title }} on SRCT Bookshare.</p><p>We certainly hope that this doesn't come as a shock. :-P</p><p>(If you don't know why you're getting this email, hey're the cc'ed email address-- {{ listing.seller.user.email }}. Contact them ASAP to clear up any confusion.)<p></em>"""),
Field('email_message',
placeholder='I haven\'t heard from you in a couple of days, so I\'m going to have to try to sell my textbook to someone else. :-/'),
Field('email_message', placeholder='I haven\'t heard from you in a couple of days, so I\'m going to have to try to exchange my textbook to someone else. :-/'),
HTML("""<em><p>Thanks for using SRCT Bookshare!</p><p>Mason SRCT</p></em></div>"""),
HTML("""<hr/ >"""),
FormActions(Submit('submit', 'Email and Cancel Sale',
FormActions(Submit('submit', 'Email and Cancel Exchange',
css_class='btn-primary'),
Button('cancel', 'Never Mind',
css_class='btn-default',
......
......@@ -68,7 +68,7 @@ class Listing(TimeStampedModel):
default='listing_photos/default_listing_photo.jpg')
# these remaining fields are for internal usage, not for users
sold = models.BooleanField(default=False)
exchanged = models.BooleanField(default=False)
cancelled = models.BooleanField(default=False)
email_message = models.TextField(blank=True, max_length=2000)
......@@ -76,7 +76,7 @@ class Listing(TimeStampedModel):
# future feature: tell sellers what price their book has been getting
winning_bid = models.ForeignKey('Bid', blank=True, null=True,
related_name='winning_bid')
# the date either cancelled or sold
# the date either cancelled or exchanged
date_closed = models.DateField(null=True, blank=True)
slug = RandomSlugField(length=6)
......
......@@ -25,4 +25,4 @@ class ListingIndex(indexes.SearchIndex, indexes.Indexable):
def index_queryset(self, using=None):
"""When the entire index for model is updated."""
return self.get_model().objects.filter(sold=False).filter(cancelled=False)
return self.get_model().objects.filter(exchanged=False).filter(cancelled=False)
......@@ -65,20 +65,20 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
</div>
</div>
{% elif listing.sold %}
{% elif listing.exchanged %}
<div class="row">
<div class="col-lg-12">
{% if listing.winning_bid.bidder.user == request.user %}
<div class="alert alert-success text-center">
<strong>You purchased this listing {{ listing.date_closed|timesince }} ago.</strong>
<strong>You exchanged this listing {{ listing.date_closed|timesince }} ago.</strong>
{% if rating %}
<strong><a href="{% url 'edit_rating' listing.slug rating.slug %}">Edit</a> <a href="{% url 'ratings' listing.seller.slug %}">your rating</a> of this sale.</strong>
<strong><a href="{% url 'edit_rating' listing.slug rating.slug %}">Edit</a> <a href="{% url 'ratings' listing.seller.slug %}">your rating</a> of this exchange.</strong>
{% else %}
<strong>Rate your experience with {{ listing.seller.user.first_name }} <a href="{% url 'create_rating' listing.slug %}">here</a>.</strong>
{% endif %}
{% else %}
<div class="alert alert-danger text-center">
<strong>This listing has been sold.</strong>
<strong>This listing has been exchanged.</strong>
{% endif %}
</div>
</div>
......@@ -89,7 +89,7 @@ SRCT Bookshare &bull; {{ listing.title }}
<div class="alert alert-warning text-center 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 we haven't seen its seller around recently either. It may no longer be valid!
Heads up, this listing is <strong>over a month old</strong> and we haven't seen the student who posted it around recently either. It may no longer be valid!
</div>
</div>
</div>
......@@ -103,7 +103,7 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
<div class="col-xs-4 text-right">
<h1>
{% if listing.sold %}
{% if listing.exchanged %}
<small>Final</small> <strong>${{ listing.final_price }}</strong>
{% else %}
<small>Asking</small> <strong>${{ listing.price }}</strong>
......@@ -147,7 +147,7 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
<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>
<h4><small>Posted 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)
{% endif %}</h4>
......@@ -199,9 +199,9 @@ SRCT Bookshare &bull; {{ listing.title }}
<div class="col-md-6 col-md-offset-3">
<h3>
{% if bid_count > 0 %}
{% if not listing.sold and not listing.cancelled %}
{% if not listing.exchanged and not listing.cancelled %}
<span class="label label-default">
<a href="{% url 'sell_listing' listing.slug %}">Mark Sold</a>
<a href="{% url 'sell_listing' listing.slug %}">Exchange</a>
</a></span>
{% elif not listing.cancelled %}
<span class="label label-default">
......@@ -210,17 +210,17 @@ SRCT Bookshare &bull; {{ listing.title }}
{% endif %}
{% endif %}
&nbsp;
{% if not listing.sold and not listing.cancelled %}
{% if not listing.exchanged and not listing.cancelled %}
<span class="label label-default">
<a href="{% url 'edit_listing' listing.slug %}">Edit Listing</a>
</span>
{% endif %}
&nbsp;
{% if not listing.cancelled and not listing.sold %}
{% if not listing.cancelled and not listing.exchanged %}
<span class="label label-default">
<a href="{% url 'cancel_listing' listing.slug %}">Cancel Listing</a>
</span>
{% elif not listing.sold %}
{% elif not listing.exchanged %}
<span class="label label-default">
<a href="{% url 'reopen_listing' listing.slug %}">Reopen Listing</a>
</span>
......@@ -238,7 +238,7 @@ SRCT Bookshare &bull; {{ listing.title }}
</h4>
</div>
<div class="panel-body">
{% if not listing.cancelled and not listing.sold %}
{% if not listing.cancelled and not listing.exchanged %}
<div class="row">
{% crispy my_form %}
</div>
......@@ -247,8 +247,8 @@ SRCT Bookshare &bull; {{ listing.title }}
<h5 class="text-center">This listing has been
{% if listing.cancelled %}
cancelled
{% elif listing.sold %}
sold
{% elif listing.exchanged %}
exchanged
{% endif %}
and is no longer accepting bids.
</h5>
......@@ -301,7 +301,7 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
<div class="col-md-2 col-sm-6 col-xs-6 text-center">
{% if not listing.sold or not listing.cancelled and bid.bidder.user == request.user %}
{% if not listing.exchanged or not listing.cancelled and bid.bidder.user == request.user %}
<h4><a href="{% url 'edit_bid' listing.slug bid.slug %}"<span class="label label-default">Edit</span></a></h4>
{% endif %}
{% if bid == listing.winning_bid %}
......
......@@ -4,8 +4,8 @@
<h4>
{% if not listing.active %}
<small><span class="label label-warning"><strong>Inactive</strong></span></small>
{% elif listing.sold %}
<small><span class="label label-primary"><strong>Sold</strong></span></small>
{% elif listing.exchanged %}
<small><span class="label label-primary"><strong>Exchanged</strong></span></small>
{% endif %}
<a href="{{ listing.get_absolute_url }}">
<strong>{{ listing.title }}</strong>
......@@ -26,7 +26,7 @@
</div>
<div class="col-md-4 text-right">
<h4>
{% if listing.sold %}
{% if listing.exchanged %}
<small>Final</small><strong> ${{ listing.final_price }}</strong>
{% else %}
<small>Asking</small><strong> ${{ listing.price }}</strong>
......
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare &bull; {{ listing.title }} &bull; Sell
SRCT Bookshare &bull; {{ listing.title }} &bull; Exchange
{% endblock %}
{% block content %}
......@@ -10,7 +10,7 @@ SRCT Bookshare &bull; {{ listing.title }} &bull; Sell
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Sell Listing</strong></p>
<p class="lead text-center"><strong>Exchange Listing</strong></p>
</div>
</div>
</div>
......
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare &bull; {{ listing.title }} &bull; Cancel Sale
SRCT Bookshare &bull; {{ listing.title }} &bull; Cancel Exchange
{% endblock %}
{% block content %}
......@@ -10,7 +10,7 @@ SRCT Bookshare &bull; {{ listing.title }} &bull; Cancel Sale
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Cancel Listing Sale</strong></p>
<p class="lead text-center"><strong>Cancel Listing Exchange</strong></p>
</div>
</div>
</div>
......
......@@ -30,10 +30,10 @@ urlpatterns = patterns('',
url(r'^listing/(?P<slug>[\w-]+)/edit/$',
EditListing.as_view(), name='edit_listing'),
url(r'^listing/(?P<slug>[\w-]+)/sell/$',
url(r'^listing/(?P<slug>[\w-]+)/exchange/$',
SellListing.as_view(), name='sell_listing'),
url(r'^listing/(?P<slug>[\w-]+)/unsell/$',
url(r'^listing/(?P<slug>[\w-]+)/unexchange/$',
UnSellListing.as_view(), name='unsell_listing'),
url(r'^listing/(?P<slug>[\w-]+)/cancel/$',
......
......@@ -321,8 +321,8 @@ class EditBid(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
if not(bidding_student == me):
return HttpResponseForbidden()
# if sold or cancelled, this page doesn't exist
if self.get_object().listing.sold or self.get_object().listing.cancelled:
# if exchanged or cancelled, this page doesn't exist
if self.get_object().listing.exchanged or self.get_object().listing.cancelled:
raise Http404
return context
......@@ -368,13 +368,13 @@ class SellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
today = date.today()
self.obj = self.get_object()
form.instance.sold = True
form.instance.exchanged = True
form.instance.date_closed = today
# sending email
# I'm still second guessing as to whether this should be in this method
text_email = get_template('email/sold.txt')
html_email = get_template('email/sold.html')
text_email = get_template('email/exchanged.txt')
html_email = get_template('email/exchanged.html')
email_context = Context({
'bidder_first_name': form.instance.winning_bid.bidder.user.first_name,
......@@ -434,13 +434,13 @@ class UnSellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
template_name = 'listing_unsell.html'
login_url = 'login'
form_valid_message = """Your sale has been successfully cancelled,
form_valid_message = """Your exchange has been successfully cancelled,
and your email successfully sent!"""
def form_valid(self, form):
self.obj = self.get_object()
text_email = get_template('email/unsold.txt')
html_email = get_template('email/unsold.html')
text_email = get_template('email/unexchanged.txt')
html_email = get_template('email/unexchanged.html')
email_context = Context({
'bidder_first_name': self.obj.winning_bid.bidder.user.first_name,
......@@ -465,7 +465,7 @@ class UnSellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
# this has to come after the email has been sent, otherwise these are
# cleaned out
form.instance.sold = False
form.instance.exchanged = False
form.instance.date_closed = None
form.instance.winning_bid = None
......@@ -597,7 +597,7 @@ class CreateRating(LoginRequiredMixin, CreateView):
context['my_form'] = form
return context
# no per-day limit because you can only rate listings you've been sold to
# no per-day limit because you can only rate listings you've exchanged
@ratelimit(key='user', rate='5/m', method='POST', block=True)
def post(self, request, *args, **kwargs):
return super(CreateRating, self).post(request, *args, **kwargs)
......
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