Merge pull request #20 from th3r00t/master

Master
This commit is contained in:
th3r00t
2019-12-05 00:33:27 -05:00
committed by GitHub
6 changed files with 45 additions and 3 deletions

5
README.md vendored
View File

@@ -1,4 +1,7 @@
# pyShelf 0.2.0
# pyShelf 0.2.1
## Patch Notes.
* fixed missing src/interface/models.py. thanks to u/thelastpenguin212
* Removed un necessary data files from repo
<p align="center"><b>A simple terminal based ebook server</b></p>
<a href="https://asciinema.org/a/M739CljirFAf9nzeNyNO0113a" target="_blank"><img src="https://asciinema.org/a/M739CljirFAf9nzeNyNO0113a.svg" /></a>

1
data/shelf.json vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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