diff --git a/cps/db.py b/cps/db.py index 86b7c92f..a354626b 100755 --- a/cps/db.py +++ b/cps/db.py @@ -76,6 +76,40 @@ for row in cc: cc_classes[row.id] = type('Custom_Column_' + str(row.id), (Base,), ccdict) +class Identifiers(Base): + __tablename__ = 'identifiers' + + id = Column(Integer, primary_key=True) + type = Column(String) + val = Column(String) + book = Column(Integer, ForeignKey('books.id')) + + def __init__(self, val, type, book): + self.val = val + self.type = type + self.book = book + + def formatType(self): + if self.type == "amazon": + return u"Amazon" + elif self.type == "isbn": + return u"ISBN" + elif self.type == "doi": + return u"DOI" + else: + return self.type + + def __repr__(self): + if self.type == "amazon": + return u"https://amzn.com/{0}".format(self.val) + elif self.type == "isbn": + return u"http://http://www.worldcat.org/isbn/{0}".format(self.val) + elif self.type == "doi": + return u"http://dx.doi.org/{0}".format(self.val) + else: + return u"" + + class Comments(Base): __tablename__ = 'comments' @@ -203,7 +237,8 @@ class Books(Base): series = relationship('Series', secondary=books_series_link, backref='books') ratings = relationship('Ratings', secondary=books_ratings_link, backref='books') languages = relationship('Languages', secondary=books_languages_link, backref='books') - + identifiers=relationship('Identifiers', backref='books') + def __init__(self, title, sort, author_sort, timestamp, pubdate, series_index, last_modified, path, has_cover, authors, tags): self.title = title self.sort = sort diff --git a/cps/static/css/style.css b/cps/static/css/style.css index 630767f7..5548739e 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -27,6 +27,7 @@ a{color: #45b29d}a:hover{color: #444;} span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: text-top;} .book-meta {padding-bottom: 20px;} .book-meta .tags a {display: inline;} +.book-meta .identifiers a {display: inline;} .container-fluid .single .cover img { border: 1px solid #fff; /*border-radius: 7px;*/ diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 16d66151..2cb6f198 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -46,6 +46,17 @@ {% endif %} + {% if entry.identifiers|length > 0 %} +