Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bookshare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
30
Issues
30
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SRCT
bookshare
Commits
22d76d3c
Commit
22d76d3c
authored
Aug 23, 2015
by
Daniel W Bond
Committed by
Mark Stenglein
Apr 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for new and old bids and listings
parent
4130c444
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
bookshare/core/views.py
bookshare/core/views.py
+10
-2
bookshare/trades/models.py
bookshare/trades/models.py
+10
-0
No files found.
bookshare/core/views.py
View file @
22d76d3c
...
...
@@ -22,6 +22,8 @@ class DetailStudent(LoginRequiredMixin, DetailView):
context
=
super
(
DetailStudent
,
self
).
get_context_data
(
**
kwargs
)
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
()
...
...
@@ -35,14 +37,20 @@ class DetailStudent(LoginRequiredMixin, DetailView):
else
:
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
[
'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
[
'proceeds'
]
=
total_proceeds
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
...
...
bookshare/trades/models.py
View file @
22d76d3c
...
...
@@ -116,6 +116,16 @@ class Listing(TimeStampedModel):
price
=
None
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
def
get_absolute_url
(
self
):
return
reverse
(
'detail_listing'
,
kwargs
=
{
'slug'
:
self
.
slug
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment