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

templatetages to change isbn to book title

parent dc48b2ec
......@@ -9,6 +9,8 @@ SRCT Bookshare • {{ student.user.first_name }} {{ student.user.last_name }}
{% load gravatar %}
{% load trades_extras %}
<div class="page-header" id="banner">
<legend>
<div class="row">
......@@ -19,6 +21,7 @@ SRCT Bookshare &bull; {{ student.user.first_name }} {{ student.user.last_name }}
<h2><strong>{{ student.user.first_name }} {{ student.user.last_name }}</strong></h2>
</div>
<div class="col-lg-2 col-md-3">
{% comment %}
{% if student.rating %}
<h3><a href="#students-ratings-history">
<i class="fa fa-star"></i>
......@@ -28,8 +31,9 @@ SRCT Bookshare &bull; {{ student.user.first_name }} {{ student.user.last_name }}
<i class="fa fa-star-o"></i>
</h3></a>
{% else %}
<!-- <em>{{ student.user.first_name }} has no ratings yet.</em> -->
<em>{{ student.user.first_name }} has no ratings yet.</em>
{% endif %}
{% endcomment %}
</div>
<div class="col-md-2">
<h3><a href="mailto:{{ student.user.email }}"><i class="fa fa-envelope"></i> {{ student.user.username }}</a></h3>
......@@ -51,8 +55,8 @@ SRCT Bookshare &bull; {{ 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"><h4>ISBN</h4></th>
<th class="col-md-9 text-center"><h4>Title</h4></th>
<th class="col-md-2 text-center"><h4>ISBN</h4></th>
<th class="col-md-8 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 %}
......@@ -131,15 +135,15 @@ SRCT Bookshare &bull; {{ 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"><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>
<th class="col-md-2 text-center"><h4>ISBN</h4></th>
<th class="col-md-8 text-center"><h4>Title</h4></th>
<th class="col-md-2 text-center"><h4>Action</h4></th>
</thead>
<tbody>
{% for lookout in lookouts %}
<tr>
<td class="text-center"><h5><a href="{{ lookout.get_absolute_url }}">{{ lookout.isbn }}</a></h5></td>
<!-- <td class="text-center"><h5>ISBN templatetag filter still unverified</h5></td> -->
<td class="text-center"><h5>{{ lookout.isbn }}</h5></td>
<td class="text-center"><h5><a href="{{ lookout.get_absolute_url }}">{{ lookout.isbn|isbn_name }}<a/></h5></td>
<td class="text-center"><h5><a href="{% url 'delete_lookout' lookout.slug %}">Delete</a></h5></td>
{% endfor %}
</tbody>
......
......@@ -6,11 +6,13 @@ SRCT Bookshare &bull; Delete Lookout
{% block content %}
{% load trades_extras %}
<hr />
<div class="row text-center">
<form action="" method="post">{% csrf_token %}
<h3>Are you sure you want to delete your lookout for ISBN {{ lookout.isbn }}?</h3>
<h3>Are you sure you want to delete your lookout for <em>{{ lookout.isbn|isbn_name }}</em>?</h3>
<input type="submit" value="Confirm" class="btn btn-danger btn-sm" />
</form>
</div>
......
......@@ -6,11 +6,13 @@ SRCT Bookshare &bull; Lookouts
{% block content %}
{% load trades_extras %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-sm-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead"><strong>Your lookout for ISBN {{ lookout.isbn }}.</strong></p>
<p class="lead"><strong>Your lookout for <em>{{ lookout.isbn|isbn_name }}</em>.</strong></p>
<a href="{% url 'delete_lookout' lookout.slug %}"><button type="button" class="btn btn-danger btn-xs">Delete this Lookout</button></a>
</div>
</div>
......
......@@ -18,6 +18,9 @@ SRCT Bookshare &bull; Homepage
</div>
</div>
{% if user.is_authenticated %}
{% load trades_extras %}
<legend class="text-center"><strong>Lookouts</strong></legend>
{% if lookouts %}
<div class="row">
......@@ -31,7 +34,7 @@ SRCT Bookshare &bull; Homepage
tag when the loop ends a column.
{% endcomment %}
{% for lookout in lookouts %}
<legend><a href="{{ lookout.get_absolute_url }}">{{ lookout.isbn }}</a></legend>
<legend><a href="{{ lookout.get_absolute_url }}">{{ lookout.isbn|isbn_name }}</a></legend>
{% for listing in lookout.get_listings %}
{% if forloop.counter|add:-1|divisibleby:rows %}
......
......@@ -2,7 +2,7 @@
{% load thumbnail %}
{% block title %}
SRCT Bookshare &bull; {{listing.title}}
SRCT Bookshare &bull; {{ listing.title }}
{% endblock %}
{% block content %}
......
from django import template
from trades.views import ISBNMetadata
register = template.Library()
@register.filter(name='isbn_name')
def isbn_name(isbn):
# numbers starting with 0 throw "SyntaxError: invalid token"
isbn_str = str(isbn)
data = ISBNMetadata(isbn)
if data is not None:
return data['title']
else:
return isbn
from django import template
from website.views import ISBNMetadata
register = template.Library()
@register.filter
def get_isbn_data( isbn, field ):
data = ISBNMetadata( isbn )
if data:
return data.get(field)
else:
return "No data found."
......@@ -13,6 +13,7 @@ import requests
# pulls worldcat metadata from ISBNs
def ISBNMetadata(standardISBN):
# passing in numbers starting with 0 throws "SyntaxError: invalid token"
url = "http://xisbn.worldcat.org/webservices/xid/isbn/" + str(standardISBN) + "?method=getMetadata&format=json&fl=title,year,author,ed"
metadata = requests.get(url)
# format into a dictionary
......
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