Commit 9ade2ffe authored by Daniel W Bond's avatar Daniel W Bond
Browse files

added links to student profile page

parent f30c7d85
...@@ -51,29 +51,29 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }} ...@@ -51,29 +51,29 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }}
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered table-hover"> <table class="table table-bordered table-hover">
<thead> <thead>
<th class="col-md-1 text-center">ISBN</th> <th class="col-md-1 text-center"><h4>ISBN</h4></th>
<th class="col-md-9 text-center">Title</th> <th class="col-md-9 text-center"><h4>Title</h4></th>
<th class="col-md-1 text-center">Price</th> <th class="col-md-1 text-center"><h4>Price</h4></th>
<th class="col-md-1 text-center"> <th class="col-md-1 text-center"><h4>
{% if student.user == request.user %} {% if student.user == request.user %}
Action Action
{% else %} {% else %}
Status Status
{% endif %}</th> {% endif %}</h4></th>
</thead> </thead>
{% for listing in listings %} {% for listing in listings %}
<tbody> <tbody>
<tr> <tr>
<td class="text-center">{{ listing.isbn }}</td> <td class="text-center"><h5>{{ listing.isbn }}</h5></td>
<td class="text-center"><a href="{{ listing.get_absolute_url }}">{{ listing.title }}</a></td> <td class="text-center"><h5><a href="{{ listing.get_absolute_url }}">{{ listing.title }}</h5></a></td>
<td class="text-center"> <td class="text-center"><h5>
{% if listing.sold %} {% if listing.sold %}
${{ listing.finalPrice }} ${{ listing.finalPrice }}
{% else %} {% else %}
${{ listing.price }} ${{ listing.price }}
{% endif %} {% endif %}
</td> </h5></td>
<td class="text-center"> <td class="text-center"><h5>
{% if listing.sold %} {% if listing.sold %}
<span class="label label-danger">Sold</span> <span class="label label-danger">Sold</span>
{% elif not listing.active %} {% elif not listing.active %}
...@@ -81,22 +81,22 @@ SRCT Bookshare &bull; {{ student.user.first_name }} {{ student.user.last_name }} ...@@ -81,22 +81,22 @@ SRCT Bookshare &bull; {{ student.user.first_name }} {{ student.user.last_name }}
{% else %} {% else %}
{% if student.user == request.user %} {% if student.user == request.user %}
{% if listing.active %} {% if listing.active %}
<a href="#">Close</a> <a href="{% url 'close_listing' listing.slug %}">Mark Sold</a>
{% else %} {% else %}
<a href="#">Reopen</a> <a href="{% url 'update_listing' listing.slug %}">Reopen</a>
{% endif %} {% endif %}
{% else %} {% else %}
<span class="label label-success">Active</span> <span class="label label-success">Active</span>
{% endif %} {% endif %}
{% endif %} {% endif %}
</td> </h5></td>
</tr> </tr>
</tbody> </tbody>
{% endfor %} {% endfor %}
</table> </table>
{% if student.user == request.user %} {% if student.user == request.user %}
<strong>Total Sales:</strong> 8 | <strong>Total Sales:</strong> {{ sales }} |
<strong>Total Proceeds:</strong> $1335 <strong>Total Proceeds:</strong> ${{ proceeds }}
{% endif %} {% endif %}
</div> </div>
{% else %} {% else %}
...@@ -120,22 +120,28 @@ SRCT Bookshare &bull; {{ student.user.first_name }} {{ student.user.last_name }} ...@@ -120,22 +120,28 @@ SRCT Bookshare &bull; {{ student.user.first_name }} {{ student.user.last_name }}
<legend><h3>Lookouts <small>(<a href="{% url 'create_lookout' %}">Create</a>)</small></h3></legend> <legend><h3>Lookouts <small>(<a href="{% url 'create_lookout' %}">Create</a>)</small></h3></legend>
</div> </div>
</div> </div>
{% endif %}
{% if lookouts %}
<div class="row"> <div class="row">
<div class="table-responsive"> <div class="col-md-12">
<table class="table table-bordered table-hover"> <div class="table-responsive">
<thead> <table class="table table-bordered table-hover">
<th class="col-md-1 text-center">ISBN</th> <thead>
<th class="col-md-10">Title</th> <th class="col-md-1 text-center"><h4>ISBN</h4></th>
<th class="col-md-1">Action</th> <th class="col-md-1 text-center"><h4>Title</h4></th>
</thead> <th class="col-md-1 text-center"><h4>Action</h4></th>
{% for lookout in lookouts %} </thead>
<tr> <tbody>
<td class="text-center">{{ lookout.isbn }}</td> {% for lookout in lookouts %}
<td class="text-center">A Title</td> <tr>
<td class="text-center"><a href="#">Delete</a></td> <td class="text-center"><h5>{{ lookout.isbn }}</h5></td>
{% endfor %} <td class="text-center"><h5>ISBN templatetag filter still unverified</h5></td>
</table> <td class="text-center"><h5><a href="{% url 'delete_lookout' lookout.slug %}">Delete</a></h5></td>
{% endfor %}
</tbody>
</table>
</div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
......
...@@ -76,11 +76,33 @@ class DetailStudent(LoginRequiredMixin, DetailView): ...@@ -76,11 +76,33 @@ class DetailStudent(LoginRequiredMixin, DetailView):
model = Student model = Student
def get_context_data(self, **kwargs): 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 = super(DetailStudent, self).get_context_data(**kwargs)
#context['listings'] = Listing.objects.filter(seller='2') #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['me'] = self.get_object().pk
context['lookouts'] = Lookout.objects.filter(owner=self.get_object().user) context['lookouts'] = Lookout.objects.filter(owner=self.get_object().user)
context['proceeds'] = total_proceeds(student_listings)
context['sales'] = total_sales(student_listings)
return context return context
login_url = '/' login_url = '/'
......
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