fixed BUGs 22 and 23 - both relate to the HTML forms being different for the search and viewing data, so changing one when the other was set, did not pass the values through, e.g. search term not there when you change a viewing option, or after searching, it did not know the grouping options. Fixed from the search side by showing a label of what you are searching for and storing it statically in the viewing form. Sorted by jscript onSubmit func to take 5 viewing options and store the last value in hidden inputs in the search form

This commit is contained in:
2021-02-21 15:40:47 +11:00
parent e13f44810d
commit 7fd6a2eddb
4 changed files with 70 additions and 25 deletions

View File

@@ -88,19 +88,7 @@ class FileType(db.Model):
def __repr__(self):
return "<id: {}, name={}>".format(self.id, self.name )
################################################################################
# /file_list -> show detailed file list of files from import_path(s)
################################################################################
@app.route("/file_list", methods=["GET"])
def file_list():
return render_template("file_list.html", page_title='View Files (details)', entry_data=Entry.query.order_by(Entry.name).all())
################################################################################
# /files -> show thumbnail view of files from import_path(s)
################################################################################
@app.route("/files", methods=["GET", "POST"])
def files():
def ViewingOptions( request ):
noo="Oldest"
grouping="Day"
how_many="50"
@@ -120,6 +108,22 @@ def files():
if 'next' in request.form:
offset += int(how_many)
return noo, grouping, how_many, offset, size
################################################################################
# /file_list -> show detailed file list of files from import_path(s)
################################################################################
@app.route("/file_list", methods=["GET"])
def file_list():
return render_template("file_list.html", page_title='View Files (details)', entry_data=Entry.query.order_by(Entry.name).all())
################################################################################
# /files -> show thumbnail view of files from import_path(s)
################################################################################
@app.route("/files", methods=["GET", "POST"])
def files():
noo, grouping, how_many, offset, size = ViewingOptions( request )
entries=[]
if noo == "Oldest":
entries=Entry.query.join(File).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
@@ -127,17 +131,21 @@ def files():
entries=Entry.query.join(File).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
return render_template("files.html", page_title='View Files', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size )
################################################################################
# /search -> show thumbnail view of files from import_path(s)
################################################################################
@app.route("/search", methods=["GET","POST"])
def search():
file_data=Entry.query.filter(Entry.name.ilike(f"%{request.form['term']}%")).all()
ai_data=Entry.query.join(File).join(FileRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(FileRefimgLink.matched==True).filter(Person.tag.ilike(f"%{request.form['term']}%")).all()
noo, grouping, how_many, offset, size = ViewingOptions( request )
file_data=Entry.query.join(File).filter(Entry.name.ilike(f"%{request.form['term']}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
ai_data=Entry.query.join(File).join(FileRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(FileRefimgLink.matched==True).filter(Person.tag.ilike(f"%{request.form['term']}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
all_entries = file_data + ai_data
return render_template("files.html", page_title='View Files', entry_data=all_entries)
return render_template("files.html", page_title='View Files', search_term=request.form['term'], entry_data=all_entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size )
################################################################################
# /files/scannow -> allows us to force a check for new files