From ccc8085aaf7a875436a968fa71dd0ae403c6a565 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Mon, 11 Jan 2021 11:00:31 +1100 Subject: [PATCH] changed Photo class and DB table to be Files, also reflected through templates/files* - files.html is not used yet --- photos.py => files.py | 23 +++++++++---------- main.py | 2 +- templates/base.html | 6 ++--- templates/{photos.html => file_list.html} | 0 templates/files.html | 27 +++++++++++++++++++++++ 5 files changed, 42 insertions(+), 16 deletions(-) rename photos.py => files.py (83%) rename templates/{photos.html => file_list.html} (100%) create mode 100644 templates/files.html diff --git a/photos.py b/files.py similarity index 83% rename from photos.py rename to files.py index 0943b43..5e6da68 100644 --- a/photos.py +++ b/files.py @@ -63,12 +63,10 @@ def getExif(file): return fthumbnail ################################################################################ -# Class describing Photos in the database, and via sqlalchemy, connected to the DB as well +# Class describing Files in the database, and via sqlalchemy, connected to the DB as well ################################################################################ - -# photos might not be the best name... more than just photos live in this class currently -class Photos(db.Model): - id = db.Column(db.Integer, db.Sequence('photos_id_seq'), primary_key=True ) +class Files(db.Model): + id = db.Column(db.Integer, db.Sequence('files_id_seq'), primary_key=True ) name = db.Column(db.String, unique=True, nullable=False ) type = db.Column(db.String, unique=False, nullable=False) size_mb = db.Column(db.Integer, unique=False, nullable=False) @@ -80,10 +78,10 @@ class Photos(db.Model): return "".format(self.id, self.name ) ################################################################################ -# /photos -> show photos from import_path(s) +# /file_list -> show files from import_path(s) ################################################################################ -@app.route("/photos", methods=["GET"]) -def photos(): +@app.route("/file_list", methods=["GET"]) +def file_list(): sets = Settings.query.filter(Settings.name=="import_path").all() paths= sets[0].value.split("#") file_list=[] @@ -123,13 +121,14 @@ def photos(): fsize = round(os.stat(file).st_size/(1024*1024)) fname=file.replace(p, "") -# tmp_photo=Photos( name=fname, type=ftype, size_mb=fsize, hash=fhash ) -# db.session.add(tmp_photo) - view_list.append( Photos( name=fname, type=ftype, size_mb=fsize, hash=fhash, thumbnail=fthumbnail )) +# tmp_files=Files( name=fname, type=ftype, size_mb=fsize, hash=fhash ) +# db.session.add(tmp_files) + view_list.append( Files( name=fname, type=ftype, size_mb=fsize, hash=fhash, thumbnail=fthumbnail )) # db.session.commit() - return render_template("photos.html", page_title='View Photos', view_path=view_path, file_list=view_list, symlink=symlink, alert=st.GetAlert(), message=st.GetMessage() ) + return render_template("file_list.html", page_title='View Files (details)', view_path=view_path, file_list=view_list, symlink=symlink, alert=st.GetAlert(), message=st.GetMessage() ) + @app.route("/static/") def custom_static(filename): diff --git a/main.py b/main.py index 8ec06c5..748240f 100644 --- a/main.py +++ b/main.py @@ -28,7 +28,7 @@ Bootstrap(app) ################################# Now, import non-book classes ################################### from settings import Settings -from photos import Photos +from files import Files ####################################### GLOBALS ####################################### # allow jinja2 to call these python functions directly diff --git a/templates/base.html b/templates/base.html index 6ba75fd..910e735 100644 --- a/templates/base.html +++ b/templates/base.html @@ -43,9 +43,9 @@