first pass at seeing if path exists
This commit is contained in:
1
main.py
1
main.py
@@ -28,6 +28,7 @@ Bootstrap(app)
|
|||||||
|
|
||||||
################################# Now, import non-book classes ###################################
|
################################# Now, import non-book classes ###################################
|
||||||
from settings import Settings
|
from settings import Settings
|
||||||
|
from photos import Photos
|
||||||
|
|
||||||
####################################### GLOBALS #######################################
|
####################################### GLOBALS #######################################
|
||||||
# allow jinja2 to call these python functions directly
|
# allow jinja2 to call these python functions directly
|
||||||
|
|||||||
38
photos.py
Normal file
38
photos.py
Normal file
@@ -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 "<id: {}, name: {}>".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() )
|
||||||
|
|
||||||
|
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
<div class="nav-item dropdown">
|
<div class="nav-item dropdown">
|
||||||
<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="PhotoMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Photos</a>
|
<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="PhotoMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Photos</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="PhotoMenu">
|
<div class="dropdown-menu" aria-labelledby="PhotoMenu">
|
||||||
|
<a class="dropdown-item" href="{{url_for('photos')}}">View...</a>
|
||||||
</div>
|
</div>
|
||||||
</div class="nav-item dropdown">
|
</div class="nav-item dropdown">
|
||||||
<div class="nav-item dropdown">
|
<div class="nav-item dropdown">
|
||||||
|
|||||||
13
templates/photos.html
Normal file
13
templates/photos.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{% extends "base.html" %} {% block main_content %}
|
||||||
|
<div class="container">
|
||||||
|
<h3 class="offset-lg-2">{{page_title}} -- {{view_path}}</h3>
|
||||||
|
<div class="row">
|
||||||
|
<table class="table table table-sm col-xl-12">
|
||||||
|
<thead><tr><th>Name</th></tr></thead><tbody>
|
||||||
|
{% for obj in objects %}
|
||||||
|
<tr><td>{{obj.name}}</td></td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody></table>
|
||||||
|
</div class="row">
|
||||||
|
</div class="container">
|
||||||
|
{% endblock main_content %}
|
||||||
Reference in New Issue
Block a user