Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
bookshare
Commits
9ade2ffe
Commit
9ade2ffe
authored
Mar 12, 2015
by
Daniel W Bond
Browse files
added links to student profile page
parent
f30c7d85
Changes
2
Show whitespace changes
Inline
Side-by-side
bookshare/core/templates/profile.html
View file @
9ade2ffe
...
...
@@ -51,29 +51,29 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }}
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered table-hover"
>
<thead>
<th
class=
"col-md-1 text-center"
>
ISBN
</th>
<th
class=
"col-md-9 text-center"
>
Title
</th>
<th
class=
"col-md-1 text-center"
>
Price
</th>
<th
class=
"col-md-1 text-center"
>
<th
class=
"col-md-1 text-center"
>
<h4>
ISBN
</h4>
</th>
<th
class=
"col-md-9 text-center"
>
<h4>
Title
</
h4></
th>
<th
class=
"col-md-1 text-center"
>
<h4>
Price
</
h4></
th>
<th
class=
"col-md-1 text-center"
>
<h4>
{% if student.user == request.user %}
Action
{% else %}
Status
{% endif %}
</th>
{% endif %}
</
h4></
th>
</thead>
{% for listing in listings %}
<tbody>
<tr>
<td
class=
"text-center"
>
{{ listing.isbn }}
</td>
<td
class=
"text-center"
><a
href=
"{{ listing.get_absolute_url }}"
>
{{ listing.title }}
</a></td>
<td
class=
"text-center"
>
<td
class=
"text-center"
>
<h5>
{{ listing.isbn }}
</
h5></
td>
<td
class=
"text-center"
><
h5><
a
href=
"{{ listing.get_absolute_url }}"
>
{{ listing.title }}
</
h5></
a></td>
<td
class=
"text-center"
>
<h5>
{% if listing.sold %}
${{ listing.finalPrice }}
{% else %}
${{ listing.price }}
{% endif %}
</td>
<td
class=
"text-center"
>
</h5>
</td>
<td
class=
"text-center"
>
<h5>
{% if listing.sold %}
<span
class=
"label label-danger"
>
Sold
</span>
{% elif not listing.active %}
...
...
@@ -81,22 +81,22 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }}
{% else %}
{% if student.user == request.user %}
{% if listing.active %}
<a
href=
"
#"
>
Close
</a>
<a
href=
"
{% url 'close_listing' listing.slug %}"
>
Mark Sold
</a>
{% else %}
<a
href=
"
#
"
>
Reopen
</a>
<a
href=
"
{% url 'update_listing' listing.slug %}
"
>
Reopen
</a>
{% endif %}
{% else %}
<span
class=
"label label-success"
>
Active
</span>
{% endif %}
{% endif %}
</td>
</h5>
</td>
</tr>
</tbody>
{% endfor %}
</table>
{% if student.user == request.user %}
<strong>
Total Sales:
</strong>
8
|
<strong>
Total Proceeds:
</strong>
$
1335
<strong>
Total Sales:
</strong>
{{ sales }}
|
<strong>
Total Proceeds:
</strong>
$
{{ proceeds }}
{% endif %}
</div>
{% else %}
...
...
@@ -120,23 +120,29 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }}
<legend><h3>
Lookouts
<small>
(
<a
href=
"{% url 'create_lookout' %}"
>
Create
</a>
)
</small></h3></legend>
</div>
</div>
{% endif %}
{% if lookouts %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered table-hover"
>
<thead>
<th
class=
"col-md-1 text-center"
>
ISBN
</th>
<th
class=
"col-md-1
0"
>
Title
</th>
<th
class=
"col-md-1
"
>
Action
</th>
<th
class=
"col-md-1 text-center"
>
<h4>
ISBN
</h4>
</th>
<th
class=
"col-md-1
text-center"
><h4>
Title
</h4>
</th>
<th
class=
"col-md-1
text-center"
><h4
>
Action
</
h4></
th>
</thead>
<tbody>
{% for lookout in lookouts %}
<tr>
<td
class=
"text-center"
>
{{ lookout.isbn }}
</td>
<td
class=
"text-center"
>
A Title
</td>
<td
class=
"text-center"
><a
href=
"
#
"
>
Delete
</a></td>
<td
class=
"text-center"
>
<h5>
{{ lookout.isbn }}
</
h5></
td>
<td
class=
"text-center"
>
<h5>
ISBN templatetag filter still unverified
</h5>
</td>
<td
class=
"text-center"
><
h5><
a
href=
"
{% url 'delete_lookout' lookout.slug %}
"
>
Delete
</a></
h5></
td>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
...
...
bookshare/core/views.py
View file @
9ade2ffe
...
...
@@ -76,11 +76,33 @@ class DetailStudent(LoginRequiredMixin, DetailView):
model
=
Student
def
get_context_data
(
self
,
**
kwargs
):
def
total_sales
(
listings
):
sales
=
0
for
listing
in
listings
:
if
listing
.
sold
:
sales
=
sales
+
1
return
sales
def
total_proceeds
(
listings
):
proceeds
=
0
for
listing
in
listings
:
if
listing
.
sold
:
proceeds
=
proceeds
+
listing
.
finalPrice
return
proceeds
student_listings
=
Listing
.
objects
.
filter
(
seller
=
self
.
get_object
().
pk
)
context
=
super
(
DetailStudent
,
self
).
get_context_data
(
**
kwargs
)
#context['listings'] = Listing.objects.filter(seller='2')
context
[
'listings'
]
=
Listing
.
objects
.
filter
(
seller
=
self
.
get_object
().
pk
)
context
[
'listings'
]
=
student_listings
context
[
'me'
]
=
self
.
get_object
().
pk
context
[
'lookouts'
]
=
Lookout
.
objects
.
filter
(
owner
=
self
.
get_object
().
user
)
context
[
'proceeds'
]
=
total_proceeds
(
student_listings
)
context
[
'sales'
]
=
total_sales
(
student_listings
)
return
context
login_url
=
'/'
...
...
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