diff --git a/main.py b/main.py index c19f3e9..8ec06c5 100644 --- a/main.py +++ b/main.py @@ -28,6 +28,7 @@ Bootstrap(app) ################################# Now, import non-book classes ################################### from settings import Settings +from photos import Photos ####################################### GLOBALS ####################################### # allow jinja2 to call these python functions directly diff --git a/photos.py b/photos.py new file mode 100644 index 0000000..597beae --- /dev/null +++ b/photos.py @@ -0,0 +1,38 @@ +from wtforms import SubmitField, StringField, HiddenField, validators, Form +from flask_wtf import FlaskForm +from flask import request, render_template, redirect +from main import db, app, ma +from sqlalchemy import Sequence +from sqlalchemy.exc import SQLAlchemyError +from status import st, Status +import os +from os import path + +from settings import Settings + + +################################################################################ +# Class describing Author in the database, and via sqlalchemy, connected to the DB as well +################################################################################ +class Photos(db.Model): + id = db.Column(db.Integer, db.Sequence('photos_id_seq'), primary_key=True ) + name = db.Column(db.String, unique=True, nullable=True ) + + def __repr__(self): + return "".format(self.id, self.name ) + +################################################################################ +# /photos -> show photos from import_path(s) +################################################################################ +@app.route("/photos", methods=["GET"]) +def photos(): + sets = Settings.query.filter(Settings.name=="import_path").all() + paths= sets[0].value.split("#") + image_list="" + view_path="" + for p in paths: + if( path.exists( p ) ): + view_path = p + return render_template("photos.html", page_title='View Photos', view_path=view_path, alert=st.GetAlert(), message=st.GetMessage() ) + + diff --git a/templates/base.html b/templates/base.html index 4f4ace6..6ba75fd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -45,6 +45,7 @@