ui gets v# from config

This commit is contained in:
th3r00t
2020-02-05 13:11:46 -05:00
parent 34e1228e81
commit 15e4960e33
8 changed files with 114 additions and 12 deletions

View File

@@ -0,0 +1,25 @@
# Generated by Django 3.0.2 on 2020-02-04 20:22
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('interface', '0003_auto_20200101_0447'),
]
operations = [
migrations.CreateModel(
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')),
],
options={
'db_table': 'collections',
},
),
]

View File

@@ -30,6 +30,15 @@ class Books(models.Model):
progress = models.IntegerField(null=True)
file_name = models.CharField(max_length=255, null=False)
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)
def get_absolute_url(self):
"""Returns the url to access a particular instance of MyModelName."""
return reverse("model-detail-view", args=[str(self.id)])

View File

@@ -18,7 +18,7 @@
<div id="app">
<div class="app_header" >
<div class="app_hdr">
<h1 class="app_hdr shadow">pyShelf 0.4.1</h1>
<h1 class="app_hdr shadow">pyShelf {{Version}}</h1>
</div>
<div class="app_slogan">
<h3 class="app_slogan shadow">"An elegant tool... for a more civilized age."</h3>

View File

@@ -18,7 +18,7 @@
<div id="app">
<div class="app_header" >
<div class="app_hdr">
<h1 class="app_hdr shadow">pyShelf 0.4.1</h1>
<h1 class="app_hdr shadow">pyShelf {{Version}}</h1>
</div>
<div class="app_slogan">
<h3 class="app_slogan shadow">"An elegant tool... for a more civilized age."</h3>

View File

@@ -6,17 +6,22 @@ from django.db import models
from django.http import JsonResponse
from django.shortcuts import HttpResponse, render #render_to_response
from django.utils.text import slugify
from pathlib import Path
from .models import Books
from backend.lib.config import Config
config = Config(Path('../'))
def index(request):
"""
Return template index
"""
_set = 1
return render(
request, "index.html", {"Books": book_set(20, _set), "Set": str(_set)}
request, "index.html", {
"Books": book_set(20, _set),
"Set": str(_set),
"Version": config.VERSION
}
)
@@ -29,7 +34,11 @@ def next_page(request, bookset):
except Exception:
_set = 1
return render(
request, "index.html", {"Books": book_set(None, _set), "Set": str(_set)}
request, "index.html", {
"Books": book_set(None, _set),
"Set": str(_set),
"Version": config.VERSION
}
)
@@ -46,7 +55,11 @@ def prev_page(request, bookset):
except Exception:
_set = 1
return render(
request, "index.html", {"Books": book_set(None, _set), "Set": str(_set)}
request, "index.html", {
"Books": book_set(None, _set),
"Set": str(_set),
"Version": config.VERSION
}
)
@@ -56,7 +69,10 @@ def search(request, query=None, _set=1, _limit=None):
"""
_set = int(_set)
if query is None:
return render(request, "index.html", {"Books": None})
return render(request, "index.html", {
"Books": None,
"Version": config.VERSION
})
if _limit is None:
_limit = 20 ## TODO set to user defaults
if _set < 1:
@@ -69,7 +85,13 @@ def search(request, query=None, _set=1, _limit=None):
return render(
request,
"search.html",
{"Books": _r, "Query": query, "Set": _set, "len_results": search_len},
{
"Books": _r,
"Query": query,
"Set": _set,
"len_results": search_len,
"Version": config.VERSION
},
)