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
af415350
Commit
af415350
authored
Mar 29, 2015
by
Daniel W Bond
Browse files
templatetages to change isbn to book title
parent
dc48b2ec
Changes
8
Hide whitespace changes
Inline
Side-by-side
bookshare/core/templates/profile.html
View file @
af415350
...
...
@@ -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 • {{ 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 • {{ 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 • {{ 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 • {{ 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>
...
...
bookshare/lookouts/templates/delete_lookout.html
View file @
af415350
...
...
@@ -6,11 +6,13 @@ SRCT Bookshare • 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>
...
...
bookshare/lookouts/templates/detail_lookout.html
View file @
af415350
...
...
@@ -6,11 +6,13 @@ SRCT Bookshare • 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>
​
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>
...
...
bookshare/templates/index.html
View file @
af415350
...
...
@@ -18,6 +18,9 @@ SRCT Bookshare • 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 • 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 %}
...
...
bookshare/trades/templates/detail_listing.html
View file @
af415350
...
...
@@ -2,7 +2,7 @@
{% load thumbnail %}
{% block title %}
SRCT Bookshare
•
{{listing.title}}
SRCT Bookshare
•
{{
listing.title
}}
{% endblock %}
{% block content %}
...
...
bookshare/trades/templatetags/trades_extras.py
0 → 100644
View file @
af415350
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
bookshare/trades/templatetags/website_extras.py
deleted
100644 → 0
View file @
dc48b2ec
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."
bookshare/trades/views.py
View file @
af415350
...
...
@@ -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
...
...
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