use new base_path Setting, but have not tested use of absolute paths instead of relative paths, also need better tooltips for the paths -- AND, still have odd trailing slash due to SymLinkName, etc. being too complex
This commit is contained in:
52
settings.py
52
settings.py
@@ -26,6 +26,7 @@ class AIModel(db.Model):
|
||||
################################################################################
|
||||
class Settings(db.Model):
|
||||
id = db.Column(db.Integer, db.Sequence('settings_id_seq'), primary_key=True )
|
||||
base_path = db.Column(db.String)
|
||||
import_path = db.Column(db.String)
|
||||
storage_path = db.Column(db.String)
|
||||
recycle_bin_path = db.Column(db.String)
|
||||
@@ -52,6 +53,7 @@ settings_schema = SettingsSchema(many=True)
|
||||
################################################################################
|
||||
class SettingsForm(FlaskForm):
|
||||
id = HiddenField()
|
||||
base_path = StringField('Base Path to use below (optional):', [validators.DataRequired()])
|
||||
import_path = StringField('Path(s) to import from:', [validators.DataRequired()])
|
||||
storage_path = StringField('Path to store sorted images to:', [validators.DataRequired()])
|
||||
recycle_bin_path = StringField('Path to temporarily store deleted images in:', [validators.DataRequired()])
|
||||
@@ -92,3 +94,53 @@ def settings():
|
||||
else:
|
||||
form = SettingsForm( obj=Settings.query.first() )
|
||||
return render_template("settings.html", form=form, page_title = page_title)
|
||||
|
||||
##############################################################################
|
||||
# SettingsRBPath(): return modified array of paths (take each path in
|
||||
# recycle_bin_path and add base_path if needed)
|
||||
##############################################################################
|
||||
def SettingsRBPath():
|
||||
settings = Settings.query.first()
|
||||
if settings == None:
|
||||
print("Cannot create file data with no settings / recycle bin path is missing")
|
||||
return
|
||||
# path setting is an absolute path, just use it, otherwise prepend base_path first
|
||||
if settings.recycle_bin_path[0] == '/':
|
||||
path = settings.recycle_bin_path
|
||||
else:
|
||||
path = settings.base_path+settings.recycle_bin_path
|
||||
return path
|
||||
|
||||
##############################################################################
|
||||
# SettingsSPath(): return modified array of paths (take each path in
|
||||
# storage_path and add base_path if needed)
|
||||
##############################################################################
|
||||
def SettingsSPath():
|
||||
paths=[]
|
||||
settings = Settings.query.first()
|
||||
if settings == None:
|
||||
print("Cannot create file data with no settings / storage path is missing")
|
||||
return
|
||||
for p in settings.storage_path.split("#"):
|
||||
if p[0] == '/':
|
||||
paths.append(p)
|
||||
else:
|
||||
paths.append(settings.base_path+p)
|
||||
return paths
|
||||
|
||||
##############################################################################
|
||||
# SettingsIPath(): return modified array of paths (take each path in
|
||||
# import_path and add base_path if needed)
|
||||
##############################################################################
|
||||
def SettingsIPath():
|
||||
paths=[]
|
||||
settings = Settings.query.first()
|
||||
if settings == None:
|
||||
print ("Cannot create file data with no settings / import path is missing")
|
||||
return
|
||||
for p in settings.import_path.split("#"):
|
||||
if p[0] == '/':
|
||||
paths.append(p)
|
||||
else:
|
||||
paths.append(settings.base_path+p)
|
||||
return paths
|
||||
|
||||
Reference in New Issue
Block a user