mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Now tracking additional book details
This commit is contained in:
@@ -115,7 +115,23 @@ class Catalogue:
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
# cover = self.extract_cover_html(book_zip, book)
|
# cover = self.extract_cover_html(book_zip, book)
|
||||||
cover = DuckDuckGo().image_result(title)
|
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
|
return book_details
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -128,7 +144,6 @@ class Catalogue:
|
|||||||
cover_image = None
|
cover_image = None
|
||||||
title = book.title().decode("utf-8")
|
title = book.title().decode("utf-8")
|
||||||
author = book.author().decode("utf-8")
|
author = book.author().decode("utf-8")
|
||||||
breakpoint()
|
|
||||||
# TODO some files are still passing encoded data for author.
|
# TODO some files are still passing encoded data for author.
|
||||||
return [title, author, cover_image, book.f.name]
|
return [title, author, cover_image, book.f.name]
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ class Books(models.Model):
|
|||||||
pages = models.IntegerField(null=True)
|
pages = models.IntegerField(null=True)
|
||||||
progress = models.IntegerField(null=True)
|
progress = models.IntegerField(null=True)
|
||||||
file_name = models.CharField(max_length=255, null=False)
|
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):
|
def generic_search(self, query):
|
||||||
try:
|
try:
|
||||||
@@ -99,3 +104,63 @@ class Navigation(models.Model):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise
|
raise
|
||||||
return results
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user