Commit cd5f5879 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

student settings page substantially implemented

parent f231ab3b
...@@ -9,13 +9,6 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }} ...@@ -9,13 +9,6 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }}
{% load gravatar %} {% load gravatar %}
<script>
function insert_target( source, target ){
var element = document.getElementById( source );
element.setAttribute("value", target);
}
</script>
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<legend> <legend>
<div class="row"> <div class="row">
...@@ -45,252 +38,106 @@ function insert_target( source, target ){ ...@@ -45,252 +38,106 @@ function insert_target( source, target ){
</legend> </legend>
</div> </div>
{% comment %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{% if seller == request.user.seller %} {% if student.user == request.user %}
<h3>Listings (<a href="{%url 'create_listing'%}">Create</a>)</h3> <legend><h3>Listings <small>(<a href="{% url 'create_listing' %}">Create</a>)</small></h3></legend>
{% else %} {% else %}
<h3>Listings</h3> <h3>Listings</h3>
{% endif %} {% endif %}
{% if listings %} {% if listings %}
<div class="table-responsive">
<div class="table-responsive"> <table class="table table-bordered table-hover">
<table class="table table-bordered"> <thead>
<th class="col-md-1 text-center">ISBN</th>
<thead> <th class="col-md-9 text-center">Title</th>
<th class="col-md-1 text-center">ISBN</th> <th class="col-md-1 text-center">Price</th>
<th class="col-md-9">Title</th> <th class="col-md-1 text-center">
<th class="col-md-1 text-center">Price</th> {% if student.user == request.user %}
<th class="col-md-1 text-center"> Action
{% if seller.user = request.user %} {% else %}
Action 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 %} {% else %}
Status ${{ listing.price }}
{% endif %} {% endif %}
</th> </td>
</thead> <td class="text-center">
{% if listing.sold %}
{% for listing in listings %} <span class="label label-danger">Sold</span>
<tr> {% elif not listing.active %}
<td class="text-center">{{ listing.ISBN }}</td> <span class="label label-default">Closed</span>
{% else %}
<td> {% if student.user == request.user %}
{% if listing.active %} {% if listing.active %}
<a href="{{ listing.get_absolute_url }}">{{ listing.title }}</a> <a href="#">Close</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>
{% else %} {% else %}
<span class="label label-success">Unsold</span> <a href="#">Reopen</a>
{% endif %} {% endif %}
{% else %}
<span class="label label-success">Active</span>
{% endif %} {% endif %}
</td> {% 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>
</tr> </tr>
{% endif %} </tbody>
{% endfor %}
</table> </table>
</div> {% if student.user == request.user %}
<strong>Total Sales:</strong> 8 |
<strong>Total Proceeds:</strong> $1335
{% endif %}
</div>
{% else %} {% else %}
{% if seller.user = request.user %} {% if student.user == request.user %}
You don't You don't
{% else %} {% else %}
{{ seller.user.first_name }} {{ seller.user.last_name }} doesn't {{ student.user.first_name }} doesn't
{% endif %} {% endif %}
have any listings posted yet. have any listings posted yet.
{% if student.user == request.user %}
Consider listings your textbooks on SRCT Bookshare.
{% endif %}
{% endif %} {% endif %}
</div> </div>
</div> </div>
{% if seller.user = request.user %}
<hr/>
{% if student.user == request.user %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h3>Your Lookouts (<a data-toggle="modal" data-target="#CreateLookout" <legend><h3>Lookouts <small>(<a href="{% url 'create_lookout' %}">Create</a>)</small></h3></legend>
href="#">Create</a>)</h3> </div>
{% if lookouts %} </div>
<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 %}
</table> <div class="row">
</div> <div class="table-responsive">
{% else %} <table class="table table-bordered table-hover">
You don't have any lookouts set yet. <thead>
{% endif %} <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>
</div> </div>
{% endif %} {% 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">&times;</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">&times;</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">&times;</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 %} {% endblock %}
...@@ -4,8 +4,8 @@ from django.views.generic import DetailView ...@@ -4,8 +4,8 @@ from django.views.generic import DetailView
from braces.views import LoginRequiredMixin from braces.views import LoginRequiredMixin
from core.models import Student from core.models import Student
from lookouts.models import Lookout
# stuff copied out of the website views from trades.models import Listing
# seller's rating # seller's rating
"""def ratingsAverage(seller): """def ratingsAverage(seller):
...@@ -27,8 +27,6 @@ def privacy_opt_out(request): ...@@ -27,8 +27,6 @@ def privacy_opt_out(request):
}, },
) )
# USER home page -- rewrite as user homepage
#@login_required
def index(request): def index(request):
lookout_form = LookoutForm() lookout_form = LookoutForm()
...@@ -66,15 +64,6 @@ def index(request): ...@@ -66,15 +64,6 @@ def index(request):
# previews to fill in rows first, rather than columns. # previews to fill in rows first, rather than columns.
rows = int(math.ceil( len(listings) / 3.0 )) or 1 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', { return render(request, 'index.html', {
'listings' : listings, 'listings' : listings,
'rows' : rows, 'rows' : rows,
...@@ -85,6 +74,15 @@ def index(request): ...@@ -85,6 +74,15 @@ def index(request):
# User profile page # User profile page
class DetailStudent(LoginRequiredMixin, DetailView): class DetailStudent(LoginRequiredMixin, DetailView):
model = Student 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 = '/' 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 # 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
......
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