Collections, and installer patches
0
src/__init__.py
Normal file → Executable file
0
src/backend/empty_bookshelf.sql
vendored
Normal file → Executable file
0
src/backend/lib/display.py
Normal file → Executable file
@@ -1,10 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
import sqlite3
|
||||
import psycopg2
|
||||
from psycopg2 import Error
|
||||
from .config import Config
|
||||
|
||||
# db_pointer = Config().catalogue_db
|
||||
|
||||
|
||||
class Storage:
|
||||
@@ -29,7 +24,6 @@ class Storage:
|
||||
try:
|
||||
self.cursor.execute(_q)
|
||||
except Exception as e:
|
||||
breakpoint()
|
||||
if e.pgcode == "42501":
|
||||
_q = """ALTER TABLE public.books OWNER to pyshelf;"""
|
||||
self.close()
|
||||
@@ -102,24 +96,29 @@ class Storage:
|
||||
return True
|
||||
|
||||
def make_collections(self):
|
||||
_q = "SELECT id,file_name FROM books"
|
||||
_q = "SELECT id,file_name FROM books"
|
||||
self.cursor.execute(_q)
|
||||
_set = self.cursor.fetchall()
|
||||
for book in _set:
|
||||
path = self.config.book_path+'/'
|
||||
path = self.config.book_path + "/"
|
||||
_collections = []
|
||||
_pathing = book[1].split(path)[1].split('/')
|
||||
_pathing.pop(0);_pathing.pop(-1)
|
||||
_pathing = book[1].split(path)[1].split("/")
|
||||
_pathing.pop(0)
|
||||
_pathing.pop(-1)
|
||||
for _p in _pathing:
|
||||
_s = _p.replace("'","")
|
||||
_s = _p.replace("'", "")
|
||||
_q_x = """
|
||||
SELECT id FROM collections where collection='%s' AND book_id_id=%s
|
||||
"""%(_s,book[0])
|
||||
""" % (
|
||||
_s,
|
||||
book[0],
|
||||
)
|
||||
try:
|
||||
self.cursor.execute(_q_x)
|
||||
if len(self.cursor.fetchall()) < 1:
|
||||
self.cursor.execute(
|
||||
"""INSERT INTO collections (collection, book_id_id) VALUES ('%s',%s)"""%(_s,book[0])
|
||||
"""INSERT INTO collections (collection, book_id_id) VALUES ('%s',%s)"""
|
||||
% (_s, book[0])
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
@@ -33,7 +33,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
SECRET_KEY = "@(9b9jslgg41u1u=mr)-2*-n2x0vef0zsy39*z@sz18&tvow18"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG = TEMPLATE_DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = CONFIG.allowed_hosts
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@ urlpatterns = [
|
||||
path("search/", views.search, name="search"),
|
||||
path("search/<query>", views.search, name="search"),
|
||||
path("search/<query>/<_set>", views.search, name="search"),
|
||||
path(
|
||||
"show_collection/<_collection>/<_colset>",
|
||||
views.show_collection,
|
||||
name="show_collection",
|
||||
),
|
||||
]
|
||||
if settings.DEBUG:
|
||||
import debug_toolbar
|
||||
|
||||
0
src/interface/migrations/0001_initial.py
Normal file → Executable file
0
src/interface/migrations/0002_auto_20200101_0445.py
Normal file → Executable file
0
src/interface/migrations/0003_auto_20200101_0447.py
Normal file → Executable file
30
src/interface/migrations/0004_collections.py
Normal file → Executable file
@@ -1,25 +1,37 @@
|
||||
# Generated by Django 3.0.2 on 2020-02-04 20:22
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('interface', '0003_auto_20200101_0447'),
|
||||
("interface", "0003_auto_20200101_0447"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Collections',
|
||||
name="Collections",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('collection', models.CharField(max_length=255)),
|
||||
('book_id', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='interface.Books')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("collection", models.CharField(max_length=255)),
|
||||
(
|
||||
"book_id",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to="interface.Books",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'db_table': 'collections',
|
||||
},
|
||||
options={"db_table": "collections",},
|
||||
),
|
||||
]
|
||||
|
||||
@@ -30,12 +30,14 @@ class Books(models.Model):
|
||||
progress = models.IntegerField(null=True)
|
||||
file_name = models.CharField(max_length=255, null=False)
|
||||
|
||||
class Collections(models.Model):
|
||||
|
||||
class Collections(models.Model):
|
||||
class Meta:
|
||||
db_table = "collections"
|
||||
|
||||
def __str__(self):
|
||||
return self.collection
|
||||
|
||||
collection = models.CharField(max_length=255)
|
||||
book_id = models.ForeignKey(Books, on_delete=models.PROTECT)
|
||||
|
||||
@@ -45,9 +47,9 @@ class Collections(models.Model):
|
||||
|
||||
def generic_search(self, query):
|
||||
try:
|
||||
results = Books.objects.annotate(
|
||||
search=SearchVector("author", "title", "file_name"),
|
||||
).filter(search=query)
|
||||
results = Books.objects.annotate(search=SearchVector("collection"),).filter(
|
||||
search=query
|
||||
)
|
||||
except Exception as e:
|
||||
raise
|
||||
return results
|
||||
|
||||
0
src/interface/static/admin/css/autocomplete.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/base.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/changelists.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/dashboard.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/fonts.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/forms.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/login.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/responsive.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/responsive_rtl.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/rtl.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/vendor/select2/LICENSE-SELECT2.md
vendored
Normal file → Executable file
0
src/interface/static/admin/css/vendor/select2/select2.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/vendor/select2/select2.min.css
vendored
Normal file → Executable file
0
src/interface/static/admin/css/widgets.css
vendored
Normal file → Executable file
0
src/interface/static/admin/fonts/LICENSE.txt
vendored
Normal file → Executable file
0
src/interface/static/admin/fonts/README.txt
vendored
Normal file → Executable file
0
src/interface/static/admin/fonts/Roboto-Bold-webfont.woff
vendored
Normal file → Executable file
0
src/interface/static/admin/fonts/Roboto-Light-webfont.woff
vendored
Normal file → Executable file
0
src/interface/static/admin/fonts/Roboto-Regular-webfont.woff
vendored
Normal file → Executable file
0
src/interface/static/admin/img/LICENSE
vendored
Normal file → Executable file
0
src/interface/static/admin/img/README.txt
vendored
Normal file → Executable file
0
src/interface/static/admin/img/calendar-icons.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
src/interface/static/admin/img/gis/move_vertex_off.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
src/interface/static/admin/img/gis/move_vertex_on.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
src/interface/static/admin/img/icon-addlink.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
0
src/interface/static/admin/img/icon-alert.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 504 B After Width: | Height: | Size: 504 B |
0
src/interface/static/admin/img/icon-calendar.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
src/interface/static/admin/img/icon-changelink.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 380 B |
0
src/interface/static/admin/img/icon-clock.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 677 B After Width: | Height: | Size: 677 B |
0
src/interface/static/admin/img/icon-deletelink.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 392 B |
0
src/interface/static/admin/img/icon-no.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 560 B |
0
src/interface/static/admin/img/icon-unknown-alt.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
0
src/interface/static/admin/img/icon-unknown.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
0
src/interface/static/admin/img/icon-viewlink.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 581 B After Width: | Height: | Size: 581 B |
0
src/interface/static/admin/img/icon-yes.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 436 B |
0
src/interface/static/admin/img/inline-delete.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 560 B |
0
src/interface/static/admin/img/search.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
0
src/interface/static/admin/img/selector-icons.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
0
src/interface/static/admin/img/sorting-icons.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
src/interface/static/admin/img/tooltag-add.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
0
src/interface/static/admin/img/tooltag-arrowright.svg
vendored
Normal file → Executable file
|
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 280 B |