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
cd5f5879
Commit
cd5f5879
authored
Feb 16, 2015
by
Daniel W Bond
Browse files
student settings page substantially implemented
parent
f231ab3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
bookshare/core/templates/profile.html
View file @
cd5f5879
...
...
@@ -9,13 +9,6 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }}
{% load gravatar %}
<script>
function
insert_target
(
source
,
target
){
var
element
=
document
.
getElementById
(
source
);
element
.
setAttribute
(
"
value
"
,
target
);
}
</script>
<div
class=
"page-header"
id=
"banner"
>
<legend>
<div
class=
"row"
>
...
...
@@ -45,252 +38,106 @@ function insert_target( source, target ){
</legend>
</div>
{% comment %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
{% if s
ell
er == request.user
.seller
%}
<h3>
Listings (
<a
href=
"{%url 'create_listing'%}"
>
Create
</a>
)
</
h3
>
{% if s
tudent.us
er == request.user %}
<legend>
<h3>
Listings
<small>
(
<a
href=
"{%
url 'create_listing'
%}"
>
Create
</a>
)
</
small></h3></legend
>
{% else %}
<h3>
Listings
</h3>
{% endif %}
{% if listings %}
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered"
>
<thead>
<th
class=
"col-md-1 text-center"
>
ISBN
</th>
<th
class=
"col-md-9"
>
Title
</th>
<th
class=
"col-md-1 text-center"
>
Price
</th>
<th
class=
"col-md-1 text-center"
>
{% if seller.user = request.user %}
Action
<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"
>
{% if student.user == request.user %}
Action
{% else %}
Status
{% endif %}
</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"
>
{% if listing.sold %}
${{ listing.finalPrice }}
{% else %}
Status
${{ listing.price }}
{% endif %}
</th>
</thead>
{% for listing in listings %}
<tr>
<td
class=
"text-center"
>
{{ listing.ISBN }}
</td>
<td>
{% if listing.active %}
<a
href=
"{{ listing.get_absolute_url }}"
>
{{ listing.title }}
</a>
{% else %}
{{ listing.title }}
{% endif %}
</td>
<td
class=
"text-center"
>
{% if listing.sold %}
${{ listing.finalPrice }}
{% elif not listing.active %}
$0
{% else %}
${{ listing.price }}
{% endif %}
</td>
<td
class=
"text-center"
>
{% if listing.sold %}
<span
class=
"label label-danger"
>
Sold
</span>
{% elif not listing.active %}
<span
class=
"label label-default"
>
Closed
</span>
{% else %}
{% if seller.user = request.user %}
<a
href=
"#"
onclick=
"insert_target('{{close_form.book_id.id_for_label}}', '{{ listing.pk }}');"
data-toggle=
"modal"
data-target=
"#CloseConfirm"
>
Close
</a>
/
<a
href=
"#"
onclick=
"insert_target('{{FinalPrice_form.book_id.id_for_label}}', '{{ listing.pk }}');"
data-toggle=
"modal"
data-target=
"#FinalPrice"
>
Sold
</a>
</td>
<td
class=
"text-center"
>
{% if listing.sold %}
<span
class=
"label label-danger"
>
Sold
</span>
{% elif not listing.active %}
<span
class=
"label label-default"
>
Closed
</span>
{% else %}
{% if student.user == request.user %}
{% if listing.active %}
<a
href=
"#"
>
Close
</a>
{% else %}
<
span
class=
"label label-success"
>
Unsold
</span
>
<
a
href=
"#"
>
Reopen
</a
>
{% endif %}
{% else %}
<span
class=
"label label-success"
>
Active
</span>
{% endif %}
</td>
</tr>
{% endfor %}
{% if seller.user = request.user %}
<tr>
<td
class=
"text-center"
>
-
</td>
<td
class=
"text-right"
><strong>
Total Proceeds:
</strong></td>
<td
class=
"text-center"
>
${{ total_sold }}
</td>
<td
class=
"text-center"
>
-
</td>
{% endif %}
</td>
</tr>
{% endif %}
</table>
</div>
</tbody>
{% endfor %}
</table>
{% if student.user == request.user %}
<strong>
Total Sales:
</strong>
8 |
<strong>
Total Proceeds:
</strong>
$1335
{% endif %}
</div>
{% else %}
{% if s
eller
.user = request.user %}
{% if s
tudent
.user =
=
request.user %}
You don't
{% else %}
{{ s
eller
.user.first_name }}
{{ seller.user.last_name }}
doesn't
{{ s
tudent
.user.first_name }} doesn't
{% endif %}
have any listings posted yet.
{% if student.user == request.user %}
Consider listings your textbooks on SRCT Bookshare.
{% endif %}
{% endif %}
</div>
</div>
{% if seller.user = request.user %}
<hr/>
{% if student.user == request.user %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h3>
Your Lookouts (
<a
data-toggle=
"modal"
data-target=
"#CreateLookout"
href=
"#"
>
Create
</a>
)
</h3>
{% if lookouts %}
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered"
>
<thead>
<th
class=
"col-md-1 text-center"
>
ISBN
</th>
<th
class=
"col-md-10"
>
Title
</th>
<th
class=
"col-md-1 text-center"
>
Action
</th>
</thead>
{% for lookout in lookouts %}
<tr>
<td
class=
"text-center"
>
{{lookout.ISBN}}
</td>
<td>
{{lookout.ISBN|get_isbn_data:"title"}}
</td>
<td
class=
"text-center"
>
<a
href=
"#"
onclick=
"insert_target('{{DeleteLookout_form.lookout_id.id_for_label}}', '{{ lookout.pk }}');"
data-toggle=
"modal"
data-target=
"#DeleteLookout"
>
Delete
</a>
</td>
</tr>
{% endfor %}
<legend><h3>
Lookouts
<small>
(
<a
href=
"{% url 'create_lookout' %}"
>
Create
</a>
)
</small></h3></legend>
</div>
</div>
</table>
</div>
{% else %}
You don't have any lookouts set yet.
{% endif %}
<div
class=
"row"
>
<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-10"
>
Title
</th>
<th
class=
"col-md-1"
>
Action
</th>
</thead>
{% 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>
{% endfor %}
</table>
</div>
</div>
{% endif %}
<!-- Final Price Modal -->
<div
class=
"modal fade"
id=
"FinalPrice"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"FinalPriceLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<form
class=
"form-horizontal"
id=
"FinalPriceForm"
method=
"post"
action=
""
role=
"form"
>
{%csrf_token%}
{{FinalPrice_form.book_id}}
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
id=
"FinalPriceLabel"
>
Final Selling Price
</h4>
</div>
<div
class=
"modal-body"
>
<div
class=
"form-group{%if FinalPrice_form.final_price.errors%} has-error{%endif%}"
>
<label
class=
"col-lg-3 control-label"
for=
"{{FinalPrice_form.final_price.id_for_label}}"
>
{{FinalPrice_form.final_price.label}}
</label>
<div
class=
"col-lg-9"
>
<div
class=
"input-group"
>
<span
class=
"input-group-addon"
>
$
</span>
{{FinalPrice_form.final_price}}
</div>
</div>
<span
class=
"help-block col-lg-9 col-lg-offset-3"
>
Enter the final price you sold your book for (optional).
</span>
</div>
</div>
<div
class=
"modal-footer"
>
<a
class=
"btn btn-default btn-sm"
data-dismiss=
"modal"
>
Close
</a>
<input
type=
"submit"
class=
"btn btn-primary btn-sm"
value=
"Mark as Sold"
name=
"sold"
/>
</div>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- Close Confirm Modal -->
<div
class=
"modal fade"
id=
"CloseConfirm"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"CloseConfirmLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<form
class=
"form-horizontal"
id=
"CloseConfirmForm"
method=
"post"
action=
""
role=
"form"
>
{%csrf_token%}
{{ close_form.book_id }}
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
id=
"CloseConfirmLabel"
>
Confirm Listing Closure
</h4>
</div>
<div
class=
"modal-body text-center"
>
Are you sure? This action cannot be undone!
</div>
<div
class=
"modal-footer"
>
<button
class=
"btn btn-default btn-sm"
data-dismiss=
"modal"
>
Cancel
</button>
<input
type=
"submit"
class=
"btn btn-primary btn-sm"
value=
"Close Listing"
name=
"closed"
/>
</div>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- Delete Lookout Modal -->
<div
class=
"modal fade"
id=
"DeleteLookout"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"DeleteLookoutLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<form
class=
"form-horizontal"
id=
"DeleteLookoutForm"
method=
"post"
action=
""
role=
"form"
>
{%csrf_token%}
{{ DeleteLookout_form.lookout_id }}
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
id=
"DeleteLookoutLabel"
>
Confirm Lookout Deletion
</h4>
</div>
<div
class=
"modal-body text-center"
>
Are you sure? This action cannot be undone!
</div>
<div
class=
"modal-footer"
>
<button
class=
"btn btn-default btn-sm"
data-dismiss=
"modal"
>
Cancel
</button>
<input
type=
"submit"
class=
"btn btn-primary btn-sm"
value=
"Delete Lookout"
name=
"lookout"
/>
</div>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
{% include 'create_lookout_modal.html' %}
{% endcomment %}
{% endblock %}
bookshare/core/views.py
View file @
cd5f5879
...
...
@@ -4,8 +4,8 @@ from django.views.generic import DetailView
from
braces.views
import
LoginRequiredMixin
from
core.models
import
Student
# stuff copied out of the website views
from
lookouts.models
import
Lookout
from
trades.models
import
Listing
# seller's rating
"""def ratingsAverage(seller):
...
...
@@ -27,8 +27,6 @@ def privacy_opt_out(request):
},
)
# USER home page -- rewrite as user homepage
#@login_required
def
index
(
request
):
lookout_form
=
LookoutForm
()
...
...
@@ -66,15 +64,6 @@ def index(request):
# previews to fill in rows first, rather than columns.
rows
=
int
(
math
.
ceil
(
len
(
listings
)
/
3.0
))
or
1
if
request
.
method
==
'POST'
:
lookout_form
=
LookoutForm
(
request
.
POST
)
if
lookout_form
.
is_valid
():
lookout
=
lookout_form
.
save
(
commit
=
False
)
lookout
.
ISBN
=
lookout
.
ISBN
.
strip
()
lookout
.
owner
=
request
.
user
.
seller
lookout
.
save
()
return
redirect
(
'homepage'
)
return
render
(
request
,
'index.html'
,
{
'listings'
:
listings
,
'rows'
:
rows
,
...
...
@@ -85,6 +74,15 @@ def index(request):
# User profile page
class
DetailStudent
(
LoginRequiredMixin
,
DetailView
):
model
=
Student
def
get_context_data
(
self
,
**
kwargs
):
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
[
'me'
]
=
self
.
get_object
().
pk
context
[
'lookouts'
]
=
Lookout
.
objects
.
filter
(
owner
=
self
.
get_object
().
user
)
return
context
login_url
=
'/'
# manage all listings -- close your listings, delete your listings, see your bids, remove your bids, close your bids, etc -- on both sides of the transactions, and the ratings
...
...
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