Commit 22d76d3c authored by Daniel W Bond's avatar Daniel W Bond Committed by Mark Stenglein
Browse files

added support for new and old bids and listings

parent 4130c444
...@@ -22,6 +22,8 @@ class DetailStudent(LoginRequiredMixin, DetailView): ...@@ -22,6 +22,8 @@ class DetailStudent(LoginRequiredMixin, DetailView):
context = super(DetailStudent, self).get_context_data(**kwargs) context = super(DetailStudent, self).get_context_data(**kwargs)
student_listings = Listing.objects.filter(poster=self.get_object().pk) student_listings = Listing.objects.filter(poster=self.get_object().pk)
new_student_listings = [li for li in student_listings if not li.old()]
old_student_listings = [li for li in student_listings if li.old()]
total_exchanges = student_listings.filter(exchanged=True).count() total_exchanges = student_listings.filter(exchanged=True).count()
...@@ -35,14 +37,20 @@ class DetailStudent(LoginRequiredMixin, DetailView): ...@@ -35,14 +37,20 @@ class DetailStudent(LoginRequiredMixin, DetailView):
else: else:
average_stars = None average_stars = None
student_bids = Bid.objects.filter(bidder=self.get_object())
new_bids = [bid for bid in student_bids if not bid.listing.old()]
old_bids = [bid for bid in student_bids if bid.listing.old()]
context['avg_stars'] = average_stars context['avg_stars'] = average_stars
context['listings'] = student_listings context['new_listings'] = new_student_listings
context['old_listings'] = old_student_listings
context['lookouts'] = Lookout.objects.filter(owner=self.get_object()) context['lookouts'] = Lookout.objects.filter(owner=self.get_object())
context['proceeds'] = total_proceeds context['proceeds'] = total_proceeds
context['exchanges'] = total_exchanges context['exchanges'] = total_exchanges
context['bids'] = Bid.objects.filter(bidder=self.get_object()) context['new_bids'] = new_bids
context['old_bids'] = old_bids
return context return context
......
...@@ -116,6 +116,16 @@ class Listing(TimeStampedModel): ...@@ -116,6 +116,16 @@ class Listing(TimeStampedModel):
price = None price = None
return price return price
def old(self):
today = date.today()
# listing last created + six months
created_plus_six = self.created.date() + relativedelta(months=6)
if today < created_plus_six:
return False
else:
return True
# retrieve url for object # retrieve url for object
def get_absolute_url(self): def get_absolute_url(self):
return reverse('detail_listing', kwargs={'slug': self.slug}) return reverse('detail_listing', kwargs={'slug': self.slug})
......
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