Commit b5cf5dcc authored by Daniel W Bond's avatar Daniel W Bond

improved variable name seller --> poster

parent 1a9d8079
......@@ -83,7 +83,7 @@ SRCT Bookshare • {{ student.user.get_full_name }}
{% 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 Exchange</a>)</small>
<small>(<a href="{% url 'unexchange_listing' listing.slug %}">Cancel Exchange</a>)</small>
{% endif %}
{% elif listing.cancelled %}
<span class="label label-default"><strong>Cancelled</strong></span>
......
......@@ -18,13 +18,13 @@ class DetailStudent(LoginRequiredMixin, DetailView):
def get_context_data(self, **kwargs):
context = super(DetailStudent, self).get_context_data(**kwargs)
student_listings = Listing.objects.filter(seller=self.get_object().pk)
student_listings = Listing.objects.filter(poster=self.get_object().pk)
total_exchanges = student_listings.filter(exchanged=True).count()
total_proceeds = Bid.objects.filter(listing__seller__user=self.get_object()).filter(listing__exchanged=True).aggregate(Sum('price'))['price__sum']
total_proceeds = Bid.objects.filter(listing__poster__user=self.get_object()).filter(listing__exchanged=True).aggregate(Sum('price'))['price__sum']
student_ratings = Rating.objects.filter(listing__seller__user=self.get_object())
student_ratings = Rating.objects.filter(listing__poster__user=self.get_object())
if student_ratings:
student_stars = [int(rating.stars) for rating in student_ratings]
print student_stars
......@@ -53,7 +53,7 @@ class StudentRatings(LoginRequiredMixin, DetailView):
def get_context_data(self, **kwargs):
context = super(StudentRatings, self).get_context_data(**kwargs)
student_ratings = Rating.objects.filter(listing__seller__user=self.get_object())
student_ratings = Rating.objects.filter(listing__poster__user=self.get_object())
# copied code!
if student_ratings:
......
......@@ -17,7 +17,7 @@ class ListingAdmin(admin.ModelAdmin):
'year', 'edition', 'condition', 'description',
'price', 'exchanged', 'cancelled', 'winning_bid',
'date_closed')
list_filter = ('created', 'modified', 'seller', 'condition',
list_filter = ('created', 'modified', 'poster', 'condition',
'price', 'cancelled')
# expand this later
......
......@@ -114,7 +114,7 @@ class FlagForm(forms.ModelForm):
#class EditListingForm( forms.ModelForm ):
class SellListingForm(forms.ModelForm):
class ExchangeListingForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
......@@ -126,7 +126,7 @@ class SellListingForm(forms.ModelForm):
'winning_bid',
HTML("""<hr/ >"""),
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 picked your bid for {{ listing.title }} on SRCT Bookshare. They're the cc'ed email address-- {{ listing.seller.user.email }}.</p><p>Watch your email to arrange all the final touches to get your book.</p></em>"""),
HTML("""<div class="well"><em><p>Hey there!</p><p>Poster {{ listing.poster.user.get_full_name }} has picked your bid for {{ listing.title }} on SRCT Bookshare. They're the cc'ed email address-- {{ listing.poster.user.email }}.</p><p>Watch your email to arrange all the final touches to get your book.</p></em>"""),
Field('email_message',
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>"""),
......@@ -140,7 +140,7 @@ class SellListingForm(forms.ModelForm):
),
)
super(SellListingForm, self).__init__(*args, **kwargs)
super(ExchangeListingForm, self).__init__(*args, **kwargs)
self.fields['email_message'].label = "Custom Message"
self.fields['winning_bid'].required = True
self.fields['email_message'].initial = ''
......@@ -149,7 +149,7 @@ class SellListingForm(forms.ModelForm):
model = Listing
class UnSellListingForm(forms.ModelForm):
class UnExchangeListingForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
......@@ -159,7 +159,7 @@ class UnSellListingForm(forms.ModelForm):
self.helper.layout = Layout(
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>"""),
HTML("""<div class="well"><em><p>Hey there!</p><p>Poster {{ listing.poster.user.get_full_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.poster.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 exchange my textbook to someone else. :-/'),
HTML("""<em><p>Thanks for using SRCT Bookshare!</p><p>Mason SRCT</p></em></div>"""),
HTML("""<hr/ >"""),
......@@ -172,7 +172,7 @@ class UnSellListingForm(forms.ModelForm):
),
)
super(UnSellListingForm, self).__init__(*args, **kwargs)
super(UnExchangeListingForm, self).__init__(*args, **kwargs)
self.fields['email_message'].label = "Custom Message"
self.fields['email_message'].initial = ''
......
......@@ -40,7 +40,7 @@ class Listing(TimeStampedModel):
(AC_NOT_INCLUDED, 'Access Code NOT Included'),
)
seller = models.ForeignKey(Student)
poster = models.ForeignKey(Student)
title = models.CharField(max_length=200)
author = models.CharField(max_length=200)
......@@ -73,7 +73,7 @@ class Listing(TimeStampedModel):
email_message = models.TextField(blank=True, max_length=2000)
# future feature: tell sellers what price their book has been getting
# future feature: tell posters 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 exchanged
......@@ -88,7 +88,7 @@ class Listing(TimeStampedModel):
modified_plus_month = self.modified.date() + relativedelta(months=1)
# last login + two weeks
last_login_plus_two_weeks = self.seller.last_login.date() +\
last_login_plus_two_weeks = self.poster.last_login.date() +\
relativedelta(weeks=2)
last_poked = ((today > created_plus_month) or (today > modified_plus_month))
......@@ -118,7 +118,7 @@ class Listing(TimeStampedModel):
return '%s : %s' % (self.isbn, self.title)
class Meta:
# unique_together = (("ISBN", "seller"),)
# unique_together = (("ISBN", "poster"),)
ordering = ['isbn', 'title']
......@@ -198,7 +198,7 @@ class Rating(TimeStampedModel):
def __unicode__(self):
return "%s's review of %s" % (self.rater.user.username,
self.listing.seller.user.username)
self.listing.poster.user.username)
class Meta:
ordering = ['rater', 'listing', 'created']
......@@ -10,7 +10,7 @@ SRCT Bookshare &bull; {{ listing.title }} | Flag
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Flag {{ listing.seller.user.first_name }} {{ listing.seller.user.last_name }}'s Listing <em>{{ listing.title }}</em></strong></p>
<p class="lead text-center"><strong>Flag {{ listing.poster.user.get_full_name }}'s Listing <em>{{ listing.title }}</em></strong></p>
</div>
</div>
</div>
......
......@@ -10,7 +10,7 @@ SRCT Bookshare &bull; {{ listing.title }} | Rate
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Rate Your Experience with {{ listing.seller.user.get_full_name}}'s Listing <em>{{ listing.title }}</em></strong></p>
<p class="lead text-center"><strong>Rate Your Experience with {{ listing.poster.user.get_full_name}}'s Listing <em>{{ listing.title }}</em></strong></p>
</div>
</div>
</div>
......
......@@ -10,7 +10,7 @@ SRCT Bookshare &bull; {{ flag.listing.title }} &bull; Remove Flag
<div class="row text-center">
<form action="" method="post">{% csrf_token %}
<h3>Are you sure you want to remove your flag for {{ flag.listing.seller.user.get_full_name }}'s listing <em>{{ flag.listing.title }}</em>?</h3>
<h3>Are you sure you want to remove your flag for {{ flag.listing.poster.user.get_full_name }}'s listing <em>{{ flag.listing.title }}</em>?</h3>
<input type="submit" value="Confirm" class="btn btn-danger btn-sm" />
<input type="submit" value="Never Mind" class="btn btn-default btn-sm" onclick="history.back()" />
</form>
......
......@@ -10,7 +10,7 @@ SRCT Bookshare &bull; {{ flag.listing.title }} &bull; Delete Review
<div class="row text-center">
<form action="" method="post">{% csrf_token %}
<h3>Are you sure you want to remove your review for {{ rating.listing.seller.user.get_full_name }}'s listing <em>{{ rating.listing.title }}</em>?</h3>
<h3>Are you sure you want to remove your review for {{ rating.listing.poster.user.get_full_name }}'s listing <em>{{ rating.listing.title }}</em>?</h3>
<input type="submit" value="Confirm" class="btn btn-danger btn-sm" />
<input type="submit" value="Never Mind" class="btn btn-default btn-sm" onclick="history.back()" />
</form>
......
......@@ -72,9 +72,9 @@ SRCT Bookshare &bull; {{ listing.title }}
<div class="alert alert-success text-center">
<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 exchange.</strong>
<strong><a href="{% url 'edit_rating' listing.slug rating.slug %}">Edit</a> <a href="{% url 'ratings' listing.poster.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>
<strong>Rate your experience with {{ listing.poster.user.first_name }} <a href="{% url 'create_rating' listing.slug %}">here</a>.</strong>
{% endif %}
{% else %}
<div class="alert alert-danger text-center">
......@@ -147,8 +147,8 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
<div class="col-md-4 col-sm-6 col-xs-6 text-right">
<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 %}
<h4><small>Posted by</small><a href="{% url 'profile' listing.poster.user.username %}"> {{ listing.poster.user.get_full_name }}</a>
{% if request.user == listing.poster.user %}
(Me)
{% endif %}</h4>
</div>
......@@ -164,7 +164,7 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
<div class="col-md-5 text-right small-text-center">
{% if request.user == listing.seller.user %}
{% if request.user == listing.poster.user %}
{% else %}
{% if can_flag %}
<h5><a href="{% url 'create_flag' listing.slug %}"><span class="label label-danger"><i class="fa fa-flag fa-fw fa-lg"></i> Flag</span></a></h5>
......@@ -195,17 +195,17 @@ SRCT Bookshare &bull; {{ listing.title }}
</div>
<div class="row text-center">
{% if request.user == listing.seller.user %}
{% if request.user == listing.poster.user %}
<div class="col-md-6 col-md-offset-3">
<h3>
{% if bid_count > 0 %}
{% if not listing.exchanged and not listing.cancelled %}
<span class="label label-default">
<a href="{% url 'sell_listing' listing.slug %}">Exchange</a>
<a href="{% url 'exchange_listing' listing.slug %}">Exchange</a>
</a></span>
{% elif not listing.cancelled %}
<span class="label label-default">
<a href="{% url 'unsell_listing' listing.slug %}">Cancel Sale</a>
<a href="{% url 'unexchange_listing' listing.slug %}">Cancel Sale</a>
</span>
{% endif %}
{% endif %}
......
......@@ -13,14 +13,14 @@
<p>Great news!</p>
<p>Seller <strong>{{ seller_name }}</strong> has picked your ${{ bid_num }}
<p>Poster <strong>{{ poster_name }}</strong> has picked your ${{ bid_num }}
bid for <strong><em>{{ listing_title }}</em></strong> on
<a href="http://bookshare.srct.gmu.edu/">SRCT Bookshare</a>.
They're the cc'ed email address-- <strong>{{ seller_email }}</strong>. Watch
They're the cc'ed email address-- <strong>{{ poster_email }}</strong>. Watch
your email to arrange all the final touches to get your book.</p>
<p><em>Seller message</em>: {{ email_message }}</p>
<p><em>Poster message</em>: {{ email_message }}</p>
<p>Thanks for using SRCT Bookshare! :-)</p>
......
......@@ -2,12 +2,12 @@ Hey there, {{ bidder_first_name }}!
Great news!
Seller {{ seller_name }} has picked your ${{ bid_num }} bid for
Poster {{ poster_name }} has picked your ${{ bid_num }} bid for
{{ listing_title }} on SRCT Bookshare. They're the cc'ed email address--
{{ seller_email }}. Watch your email to arrange all the final touches to get
{{ poster_email }}. Watch your email to arrange all the final touches to get
your book.
Seller message: {{ email_message }}
Poster message: {{ email_message }}
Thanks for using SRCT Bookshare! :-)
......
......@@ -11,17 +11,17 @@
<body>
<p>Hey there, <strong>{{ bidder_first_name }}</strong>!
<p>Seller <strong>{{ seller_name }}</strong> has cancelled your
<p>Poster <strong>{{ poster_name }}</strong> has cancelled your
${{ bid_num }} bid for <em>{{ listing_title }}</em> on
<a href="http://bookshare.srct.gmu.edu/">SRCT Bookshare</a>.
<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, they're the cc'ed email
address-- {{ seller_email }}. Contact them ASAP to clear up any confusion.)</p>
address-- {{ poster_email }}. Contact them ASAP to clear up any confusion.)</p>
<p><em>Seller message</em>: {{ email_message }}</p>
<p><em>Poster message</em>: {{ email_message }}</p>
<p>Thanks for using SRCT Bookshare!</p>
......
Hey there, {{ bidder_first_name }}!
Seller {{ seller_name }} has cancelled your ${{ bid_num }} bid for
Poster {{ poster_name }} has cancelled your ${{ bid_num }} bid for
{{ listing_title }} on SRCT Bookshare.
We certainly hope that this doesn't come as a shock. :-P
(If you don't know why you're getting this email, they're the cc'ed email
address-- {{ seller_email }}. Contact them ASAP to clear up any confusion.)
address-- {{ poster_email }}. Contact them ASAP to clear up any confusion.)
Seller message: {{ email_message }}
Poster message: {{ email_message }}
Thanks for using SRCT Bookshare!
......
......@@ -18,9 +18,9 @@
<div class="row">
<div class="col-md-8">
<h4><small>Seller</small>
<a href="{{ listing.seller.get_absolute_url }}">
{{ listing.seller.user.get_full_name }}
<h4><small>Poster</small>
<a href="{{ listing.poster.get_absolute_url }}">
{{ listing.poster.user.get_full_name }}
</a>
</h4>
</div>
......
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare &bull; {{ listing.title }} &bull; Exchange
{% endblock %}
{% block content %}
<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>Exchange Listing</strong></p>
</div>
</div>
</div>
{% load crispy_forms_tags %}
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-md-10 col-md-offset-1">
{% crispy my_form %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
......@@ -37,7 +37,7 @@ SRCT Bookshare &bull; Search Listings
<td class="col-md-5"><h4><strong>Title</strong></h4></td>
<td class="col-md-2"><h4><strong>Author</strong></h4></td>
<td class="col-md-1"><h4><strong>Course</strong></h4></td>
<td class="col-md-2"><h4><strong>Seller</strong></h4></td>
<td class="col-md-2"><h4><strong>Poster</strong></h4></td>
<td class="col-md-1"><h4><strong>Price</strong></h4></td>
</thead>
{% endif %}
......@@ -58,8 +58,8 @@ SRCT Bookshare &bull; Search Listings
</td>
<td class="text-center">
<h5>
<a href="{{ result.object.seller.get_absolute_url }}">
{{ result.object.seller.user.first_name }} {{ result.object.seller.user.last_name }}
<a href="{{ result.object.poster.get_absolute_url }}">
{{ result.object.poster.user.first_name }} {{ result.object.poster.user.last_name }}
</a>
</h5>
</td>
......
......@@ -3,8 +3,8 @@ from django.conf.urls import patterns, url
from django.views.decorators.cache import cache_page
# imports from your apps
from .views import ListListings, CreateListing, ListingPage,\
CreateFlag, DeleteFlag, EditListing, SellListing,\
UnSellListing, CancelListing, ReopenListing, CreateRating,\
CreateFlag, DeleteFlag, EditListing, ExchangeListing,\
UnExchangeListing, CancelListing, ReopenListing, CreateRating,\
EditRating, DeleteRating, EditBid
......@@ -31,10 +31,10 @@ urlpatterns = patterns('',
EditListing.as_view(), name='edit_listing'),
url(r'^listing/(?P<slug>[\w-]+)/exchange/$',
SellListing.as_view(), name='sell_listing'),
ExchangeListing.as_view(), name='exchange_listing'),
url(r'^listing/(?P<slug>[\w-]+)/unexchange/$',
UnSellListing.as_view(), name='unsell_listing'),
UnExchangeListing.as_view(), name='unexchange_listing'),
url(r'^listing/(?P<slug>[\w-]+)/cancel/$',
CancelListing.as_view(), name='cancel_listing'),
......
......@@ -20,8 +20,8 @@ from braces.views import FormValidMessageMixin
from ratelimit.decorators import ratelimit
# imports from your apps
from .models import Listing, Bid, Flag, Rating
from .forms import ListingForm, BidForm, FlagForm, SellListingForm,\
UnSellListingForm, RatingForm
from .forms import ListingForm, BidForm, FlagForm, ExchangeListingForm,\
UnExchangeListingForm, RatingForm
from core.models import Student
......@@ -98,7 +98,7 @@ class CreateListing(LoginRequiredMixin, FormValidMessageMixin, CreateView):
def form_valid(self, form):
me = Student.objects.get(user=self.request.user)
form.instance.seller = me
form.instance.poster = me
image_name = form.instance.photo.name
user_image = Image.open(form.instance.photo)
......@@ -240,10 +240,10 @@ class CreateFlag(LoginRequiredMixin, CreateView):
# [u'', u'share', u'listing', u'C1s3oD', u'flag']
selected_listing = Listing.objects.get(slug=listing_slug)
selling_student = selected_listing.seller
posting_student = selected_listing.poster
# you can't flag your own listing
if (selling_student == me):
if (posting_student == me):
return HttpResponseForbidden()
# can only create a flag if you haven't previously created one
......@@ -345,20 +345,19 @@ class EditListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
context = super(EditListing, self).get_context_data(**kwargs)
me = Student.objects.get(user=self.request.user)
selling_student = self.get_object().seller
posting_student = self.get_object().poster
if not(selling_student == me):
if not(posting_student == me):
return HttpResponseForbidden()
return context
class SellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
class ExchangeListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
model = Listing
fields = ['email_message', 'winning_bid', ]
template_suffix_name = '_sell'
context_object_name = 'listing'
template_name = 'listing_sell.html'
template_name = 'listing_exchange.html'
login_url = 'login'
form_valid_message = "Your email was successfully sent!"
......@@ -378,16 +377,16 @@ class SellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
email_context = Context({
'bidder_first_name': form.instance.winning_bid.bidder.user.first_name,
'seller_name': self.obj.seller.user.get_full_name(),
'poster_name': self.obj.poster.user.get_full_name(),
'bid_num': form.instance.winning_bid.price,
'listing_title': self.obj.title,
'seller_email': self.obj.seller.user.email,
'poster_email': self.obj.poster.user.email,
'email_message': form.instance.email_message, })
subject, from_email, to, cc = ('Your bid has been selected on Bookshare!',
'no-reply@bookshare.srct.io',
# form.instance.winning_bid.bidder.user.email,
# self.obj.seller.user.email)
# self.obj.poster.user.email)
'success@simulator.amazonses.com',
'success@simulator.amazonses.com')
text_content = text_email.render(email_context)
......@@ -397,15 +396,15 @@ class SellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
msg.attach_alternative(html_content, "text/html")
msg.send()
return super(SellListing, self).form_valid(form)
return super(ExchangeListing, self).form_valid(form)
def get_context_data(self, **kwargs):
context = super(SellListing, self).get_context_data(**kwargs)
context = super(ExchangeListing, self).get_context_data(**kwargs)
me = Student.objects.get(user=self.request.user)
selling_student = self.get_object().seller
posting_student = self.get_object().poster
if not(selling_student == me):
if not(posting_student == me):
return HttpResponseForbidden()
bid_count = Bid.objects.filter(listing=self.get_object).count()
......@@ -413,7 +412,7 @@ class SellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
# because the page shouldn't exist in this scenario
raise Http404
form = SellListingForm()
form = ExchangeListingForm()
form.fields['winning_bid'].queryset = Bid.objects.filter(listing=self.get_object())
context['my_form'] = form
......@@ -423,15 +422,14 @@ class SellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
@ratelimit(key='user', rate='5/m', method='POST', block=True)
@ratelimit(key='user', rate='50/d', method='POST', block=True)
def post(self, request, *args, **kwargs):
return super(SellListing, self).post(request, *args, **kwargs)
return super(ExchangeListing, self).post(request, *args, **kwargs)
class UnSellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
class UnExchangeListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
model = Listing
fields = ['email_message', ]
template_suffix_name = '_unsell'
context_object_name = 'listing'
template_name = 'listing_unsell.html'
template_name = 'listing_unexchange.html'
login_url = 'login'
form_valid_message = """Your exchange has been successfully cancelled,
......@@ -444,16 +442,16 @@ class UnSellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
email_context = Context({
'bidder_first_name': self.obj.winning_bid.bidder.user.first_name,
'seller_name': self.obj.seller.user.get_full_name(),
'poster_name': self.obj.poster.user.get_full_name(),
'bid_num': self.obj.winning_bid.price,
'listing_title': self.obj.title,
'seller_email': self.obj.seller.user.email,
'seller_email': form.instance.email_message, })
'poster_email': self.obj.poster.user.email,
'poster_email': form.instance.email_message, })
subject, from_email, to, cc = ('Your transaction has been cancelled on Bookshare',
'no-reply@bookshare.srct.io',
# self.obj.winning_bid.bidder.user.email,
# self.obj.seller.user.email)
# self.obj.poster.user.email)
'success@simulator.amazonses.com',
'success@simulator.amazonses.com')
text_content = text_email.render(email_context)
......@@ -469,18 +467,18 @@ class UnSellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
form.instance.date_closed = None
form.instance.winning_bid = None
return super(UnSellListing, self).form_valid(form)
return super(UnExchangeListing, self).form_valid(form)
def get_context_data(self, **kwargs):
context = super(UnSellListing, self).get_context_data(**kwargs)
context = super(UnExchangeListing, self).get_context_data(**kwargs)
me = Student.objects.get(user=self.request.user)
selling_student = self.get_object().seller
posting_student = self.get_object().poster
if not(selling_student == me):
if not(posting_student == me):
return HttpResponseForbidden()
form = UnSellListingForm()
form = UnExchangeListingForm()
context['my_form'] = form
return context
......@@ -488,7 +486,7 @@ class UnSellListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
@ratelimit(key='user', rate='5/m', method='POST', block=True)
@ratelimit(key='user', rate='50/d', method='POST', block=True)
def post(self, request, *args, **kwargs):
return super(UnSellListing, self).post(request, *args, **kwargs)
return super(UnExchangeListing, self).post(request, *args, **kwargs)
class CancelListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
......@@ -512,9 +510,9 @@ class CancelListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
context = super(CancelListing, self).get_context_data(**kwargs)
me = Student.objects.get(user=self.request.user)
selling_student = self.get_object().seller
posting_student = self.get_object().poster
if not(selling_student == me):
if not(posting_student == me):
return HttpResponseForbidden()
return context
......@@ -539,9 +537,9 @@ class ReopenListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
context = super(ReopenListing, self).get_context_data(**kwargs)
me = Student.objects.get(user=self.request.user)
selling_student = self.get_object().seller
posting_student = self.get_object().poster
if not(selling_student == me):
if not(posting_student == me):
return HttpResponseForbidden()
return context
......@@ -568,7 +566,7 @@ class CreateRating(LoginRequiredMixin, CreateView):
def get_success_url(self):
return reverse('ratings',
kwargs={'slug': self.object.listing.seller.slug})
kwargs={'slug': self.object.listing.poster.slug})
def get_context_data(self, **kwargs):
context = super(CreateRating, self).get_context_data(**kwargs)
......@@ -616,7 +614,7 @@ class EditRating(LoginRequiredMixin, UpdateView):
def get_success_url(self):
return reverse('ratings',
kwargs={'slug': self.object.listing.seller.slug})
kwargs={'slug': self.object.listing.poster.slug})
def get_context_data(self, **kwargs):
context = super(EditRating, self).get_context_data(**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