Now tracking additional book details

This commit is contained in:
Raelon Masters
2020-06-12 12:55:11 -04:00
parent 9fdd7e25a0
commit 7d9c80f694
2 changed files with 82 additions and 2 deletions

View File

@@ -115,7 +115,23 @@ class Catalogue:
except IndexError:
# cover = self.extract_cover_html(book_zip, book)
cover = DuckDuckGo().image_result(title)
book_details = [title, author, cover, book["path"]]
description = soup.find("dc:description")
identifier = soup.find("dc:identifier")
publisher = soup.find("dc:identifier")
date = soup.find("dc:date")
rights = soup.find("dc:rights")
breakpoint()
book_details = [
title,
author,
cover,
book["path"],
description,
identifier,
publisher,
date,
rights,
]
return book_details
@staticmethod
@@ -128,7 +144,6 @@ class Catalogue:
cover_image = None
title = book.title().decode("utf-8")
author = book.author().decode("utf-8")
breakpoint()
# TODO some files are still passing encoded data for author.
return [title, author, cover_image, book.f.name]

View File

@@ -29,6 +29,11 @@ class Books(models.Model):
pages = models.IntegerField(null=True)
progress = models.IntegerField(null=True)
file_name = models.CharField(max_length=255, null=False)
description = models.TextField(null=True)
publisher = models.CharField(max_length=266, null=True)
date = models.DateField(null=True)
rights = models.CharField(max_length=255, null=True)
tags = models.CharField(max_length=255, null=True)
def generic_search(self, query):
try:
@@ -99,3 +104,63 @@ class Navigation(models.Model):
except Exception as e:
raise
return results
class Users(models.Model):
"""
pyShelfs User Database class
:param uname: User Name
:param fname: First Name
:param lname: Last Name
:param email: User Email Address
:param password: User Password
:param ulvl: User Level
"""
class Meta:
db_table = "users"
def __str__(self):
return self.title
uname = models.CharField(max_length=255)
fname = models.CharField(max_length=255, null=True)
lname = models.CharField(max_length=255, null=True)
email = models.CharField(max_length=255, null=True, editable=True)
password = models.CharField(max_length=255, null=True)
ulvl = models.IntegerField(null=True)
def generic_search(self, query):
try:
results = Users.objects.annotate(
search=SearchVector("uname", "email", "lname"),
).filter(search=query)
except Exception as e:
raise
return results
class Favorites(models.Model):
"""
pyShelfs User Database class
:param uname: User Name
:param fname: First Name
"""
class Meta:
db_table = "favorites"
def __str__(self):
return self.title
favorite = models.ManyToManyField(Books)
uname = models.ManyToManyField(Users)
def generic_search(self, query):
try:
results = Favorites.objects.annotate(search=SearchVector("uname"),).filter(
search=query
)
except Exception as e:
raise
return results