Hotfix 0.2.1 Missing Models.py

This commit is contained in:
Mike Young
2019-12-05 00:24:41 -05:00
parent 2c6ff458fd
commit 92b13fb833
5 changed files with 45 additions and 2 deletions

0
src/data/shelf.json vendored
View File

BIN
src/db.sqlite3 vendored

Binary file not shown.

41
src/interface/models.py Executable file
View File

@@ -0,0 +1,41 @@
from django.contrib.postgres.search import SearchVector
from django.db import models
# Create your models here.
class Books(models.Model):
"""
pyShelfs Book Database class
:param title: Book title
:param author: Author
:param categories: Categories <-- Not implemented
:param cover: Cover image BinaryField
:param pages: # of pages <-- Not implemented
:param progress: Reader percentage <-- Not implented
:param file_name: Path to book
"""
class Meta:
db_table = "books"
def __str__(self):
return self.title
title = models.CharField(max_length=255)
author = models.CharField(max_length=255, null=True)
categories = models.CharField(max_length=255, null=True)
cover = models.BinaryField(null=True, editable=True)
pages = models.IntegerField(null=True)
progress = models.IntegerField(null=True)
file_name = models.CharField(max_length=255, null=False)
def get_absolute_url(self):
"""Returns the url to access a particular instance of MyModelName."""
return reverse("model-detail-view", args=[str(self.id)])
def generic_search(self, query):
results = Books.objects.annotate(
search=SearchVector("author", "title", "file_name")
).filter(str(query))
return results