made basic newest/oldest week/month/year part of gui actually retreive what we want, and have a title per grouping, but the grouping title is hard-coded for now, will need more data to do a better test, also hacky submit button for now until I decide how to enact the gui change requested

This commit is contained in:
2021-01-30 23:26:52 +11:00
parent 98d4c7d43e
commit 2db7f59a40
3 changed files with 57 additions and 16 deletions

View File

@@ -70,7 +70,6 @@ class File(db.Model):
__tablename__ = "file"
eid = db.Column(db.Integer, db.ForeignKey("entry.id"), primary_key=True )
size_mb = db.Column(db.Integer, unique=False, nullable=False)
hash = db.Column(db.Integer, unique=True, nullable=True)
thumbnail = db.Column(db.String, unique=False, nullable=True)
hash = db.Column(db.Integer)
year = db.Column(db.Integer)
@@ -79,7 +78,7 @@ class File(db.Model):
woy = db.Column(db.Integer)
def __repr__(self):
return "<eid: {}, size_mb={}, hash={}>".format(self.eid, self.size_mb, self.hash )
return f"<eid: {self.eid}, size_mb={self.size_mb}, hash={self.hash}, year={self.year}, month={self.month}, day={self.day}, woy={self.woy}>"
class FileType(db.Model):
__tablename__ = "file_type"
@@ -100,19 +99,41 @@ def file_list():
################################################################################
# /files -> show thumbnail view of files from import_path(s)
################################################################################
@app.route("/files", methods=["GET"])
@app.route("/files", methods=["GET", "POST"])
def files():
order_by="asc"
grouping="day"
which="week"
if which == "week":
noo="Oldest"
grouping="Day"
which="Week"
if request.method=="POST":
noo=request.form['noo']
which=request.form['which']
grouping=request.form['grouping']
print( f"noo={noo}, which={which}, grouping={grouping}")
entries=[]
if noo == "Oldest":
year=File.query.order_by(File.year).first()
month=File.query.filter(File.year==year.year).order_by(File.month).first()
woy=File.query.filter(File.year==year.year).order_by(File.woy).first()
if order_by == "desc":
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.woy==woy.woy).order_by(Entry.name.desc()).all()
else:
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.woy==woy.woy).order_by(Entry.name.desc()).all()
return render_template("files.html", page_title='View Files', entry_data=entries )
if which == "Week":
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.woy==woy.woy).order_by(Entry.name).all()
elif which == "month":
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.month==month.month).order_by(Entry.name).all()
elif which == "Year":
entries=Entry.query.join(File).filter(File.year==year.year).order_by(Entry.name).all()
else:
year=File.query.order_by(File.year.desc()).first()
month=File.query.filter(File.year==year.year).order_by(File.month.desc()).first()
woy=File.query.filter(File.year==year.year).order_by(File.woy.desc()).first()
if which == "Week":
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.woy==woy.woy).order_by(Entry.name).all()
elif which == "Month":
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.month==month.month).order_by(Entry.name).all()
elif which == "Year":
entries=Entry.query.join(File).filter(File.year==year.year).order_by(Entry.name).all()
return render_template("files.html", page_title='View Files', entry_data=entries, grouping=grouping, which=which )
################################################################################
# /search -> show thumbnail view of files from import_path(s)