From dc1571bcfb7be7c2f5aa6e8ba9016a1cabe46a59 Mon Sep 17 00:00:00 2001 From: MassiveAtoms Date: Wed, 15 Jul 2020 00:34:44 -0300 Subject: [PATCH] added identifier option to search --- CalibreWebCompanion/db.sqlite3 | Bin 131072 -> 131072 bytes .../library/__pycache__/forms.cpython-38.pyc | Bin 1285 -> 1358 bytes .../library/__pycache__/models.cpython-38.pyc | Bin 10751 -> 10781 bytes .../library/__pycache__/views.cpython-38.pyc | Bin 6072 -> 6165 bytes CalibreWebCompanion/library/forms.py | 2 +- CalibreWebCompanion/library/models.py | 2 +- .../library/templates/search.html | 2 ++ CalibreWebCompanion/library/views.py | 5 ++++- 8 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CalibreWebCompanion/db.sqlite3 b/CalibreWebCompanion/db.sqlite3 index d5c379a4f18ea19dfe752a7977998fc61166cdd1..67f7a6598a53e9af389770b6ee0070a2f05203fc 100644 GIT binary patch delta 239 zcmZo@;Am*zm>|vQI#I@%(RE|Ol6YoTZlBHU39j54P1dZezAdbdmQ@yc7N!*$Ny(LY zC8Y)_1?lE_=_Zy&WtAD`iJ9ryn_uOzG74HM7#Ld_T3VSH=$RT=m>O7a?#iiR=3(Xc zVBp`*@4cgWME3vy delta 239 zcmZo@;Am*zm>|vQG*QNx(P?ACl6Ynop03U839j543=E8RzAdbd*%l_|#u>$C#ub%? z6~!f$#wp3B8Rcb(mWie5Rr#qon_uOzG74HK7#Ud^m|7Vd>zP{`TN;^c?#iiR=3(K_ zW#He=e}_Mpf6``w0t1_lOIf=1@l$0`V#AdECKGd3_VX}&do`>pwmS^>-~{H@#B nKQPAgD+7&_H!?6X&^0jEHNtQNs~oc<*Hu%FD~e00ev`eDSOkc{eheP28_8lFFRLlERk4p2FPA6vdvx5zL^;Iq{8^ zL6w?kN@`w7W?E)yk%nimlb?=)dwza;PO5HZijG2JZemq_oGT&k;PR&Uxk_DN- zQd*o^w36`_XMB8ePGWI!d^}Vy$Q1d>cbSd-&@5&GY2$LuP0Y-316f-HGPFnrtR5uA i3pFV@H75sV8rV6?ASEJ`<5(&MAl?P>p$>h{A_o9NN?2q7 delta 292 zcmX@d)yl;i%FD~e00e4UeDUlPc{eg@Ox&-|mckaypvgY*mld<0Ci~ae1bs=9OfoWu_JtsQ?WsQUwueKw@&7u;%1Y&ZCnj X@{3JUXJs^)Y{=!tD73kPt6d%d@B<&- delta 114 zcmbOm@;{h2l$V!_0SK-c@x}LT`>lFYQs)S}53L^UVpaUPw_p)ST~I@zDgjf;a32$?uoip(c3 PP!Rzd$+>wCSE4)swDKLa diff --git a/CalibreWebCompanion/library/__pycache__/views.cpython-38.pyc b/CalibreWebCompanion/library/__pycache__/views.cpython-38.pyc index f897e15b81500fb3374fcd3a74fa184b85858a4c..d6d40ff4f1a2e755bf61f3242ef7f118a13b2a50 100644 GIT binary patch literal 6165 zcmd5=NpBp-74GV7Rt|@YL{So{eHqyrIg#Te2BXlXVkwDCE211L4F>JzRCCzF?&(o= zQ_EzO3kBFnpa21KGXh9Q{fzvLzT}XT&$;=Me6M;oawtkRgTOPW*HvF_uj+mE>UDoQ zHkMcL`{$#Q{f{X{`4<(2e>w__NYUSzqHu*XUkRAS80A%84KzzbUgNs22Zm(?rey{h zD-&d`Y>=~ZLEg#-1*;Ggtzs}{jRhsE6pUNrvcKV%g9&Rw_BZ{>V9J^brmbmNm+=n; zx~0o});}D~STi!8^N$3x)~w9u{iDG#>zK?J{Nur#HOCZpju-jZQ)Qc3^Ss2zpDNag z8wxM;iKhymaJ9zCZOu9bWRgz-nF4Ye$QdBh{1A{sUF0l~!+ZwFOcyx^1ikW+@B;w;3nq9Vhmh^`t~_+T@nk+)Q$}x7K_w+Hggp-F50of$EWwm9lZ#QI_@V zPV6N4UviA-t$T9*>6>xfy5mNzuo<~`T}0|(2e4kiZ}}7o5s@nt2A}A`mqy5-UIi8I1HlI z>u$6ehpp9M%a1)D8@J{7c1whH;RFGSt4ogWtqJ$?iYp$tqF4OPUBiaAoF>+}N(~(G z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&fB$}lO$$v;pR zy5u|2s0n=3^qhVj;l}wh@bSCzheY0_W&1XVkUjIK6#M_52YFP`w~f8z-6)NCxYuCK z-!Lj>&6UwD{v^u$ndaLAW&Vosqm-F{rDWrL$&wr@kl&pzB=197v(Fbo_RN<8Lbaa> zS?D$4e?*qAF;z^K%iH$%lbG@snrshD`3J_2GG%UevBqgKh?#e%2?_gmTCh(OLYB)5 zQHeL4X3bv+@KG?Vw!=Vuow4%?e4jp4Ng5@mDN|9DvZl&^E1Kr0K^ZtD4t>m$Maq;5 zpGaofz&Alz0vx5tod`DECv3!$}W{Hf4Qnfx_fohXd4M zdWR0`V^cJ@L(2jeRbM)xF9SJ4VjQ9D6it-Bn|#xu*8zE&piJ-GO}({CdM#9MgOXmw zh|RV$8tv^+Ohf>hTArYh(iha#MMHk+_UhLQ4LI&T?iZ SKV?o$B4v^2UznOgD*PAS-Sl?= diff --git a/CalibreWebCompanion/library/forms.py b/CalibreWebCompanion/library/forms.py index 319166a..7a28e4c 100644 --- a/CalibreWebCompanion/library/forms.py +++ b/CalibreWebCompanion/library/forms.py @@ -6,7 +6,7 @@ from django.contrib.auth.models import User class SearchForm(forms.Form): title = forms.CharField(label="Title", max_length=200) author = forms.CharField(label='Author', max_length=100) - # identifier = forms.CharField(label='Identifier(ISBN, Google-id, amazon id)', max_length=20) + identifier = forms.CharField(label='Identifier(ISBN, Google-id, amazon id)', max_length=20) diff --git a/CalibreWebCompanion/library/models.py b/CalibreWebCompanion/library/models.py index 0635566..0943333 100644 --- a/CalibreWebCompanion/library/models.py +++ b/CalibreWebCompanion/library/models.py @@ -57,7 +57,7 @@ class Data(models.Model): class Identifier(models.Model): - book = models.IntegerField() + book = models.ForeignKey("Book", db_column="book", on_delete=models.CASCADE) type = models.TextField() val = models.TextField() diff --git a/CalibreWebCompanion/library/templates/search.html b/CalibreWebCompanion/library/templates/search.html index ba0aad0..7fa03f0 100644 --- a/CalibreWebCompanion/library/templates/search.html +++ b/CalibreWebCompanion/library/templates/search.html @@ -8,6 +8,8 @@ + + diff --git a/CalibreWebCompanion/library/views.py b/CalibreWebCompanion/library/views.py index bcfaa30..23a0c49 100644 --- a/CalibreWebCompanion/library/views.py +++ b/CalibreWebCompanion/library/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render from django.views import generic -from .models import Author, Book, Comment, Rating, BookAuthorLink, Publisher, Tag, BookTagLink, BookRatingLink, Data +from .models import Author, Book, Comment, Rating, BookAuthorLink, Publisher, Tag, BookTagLink, BookRatingLink, Data, Identifier from django.http import HttpResponseRedirect from .forms import SearchForm, UserCreationForm from django.db import models @@ -40,11 +40,14 @@ class ResultsView(generic.ListView): # no clue if this is secure. def get_queryset(self): # new title = self.request.GET.get('title') author = self.request.GET.get('author') + identifier = self.request.GET.get("identifier") books = Book.objects.prefetch_related("tags", "ratings") if title: books =books.filter(sort__icontains=title) if author: books = books.filter(author_sort__icontains=author) + if identifier: + books = books.filter(identifier__val=identifier) return books