From 098727f2825a4b91f360b9664b00e49f728093fb Mon Sep 17 00:00:00 2001 From: crunk Date: Sun, 23 Jun 2024 18:24:05 +0200 Subject: [PATCH] redistribusi work in progress --- verse/describer/describe_files.py | 19 ++++++++++++------- verse/distribusikan/distribusi_workflow.py | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/verse/describer/describe_files.py b/verse/describer/describe_files.py index a3106ee..30d0131 100644 --- a/verse/describer/describe_files.py +++ b/verse/describer/describe_files.py @@ -1,3 +1,4 @@ +import os from flask import ( Blueprint, render_template, @@ -20,6 +21,7 @@ from models.distribusi_model import Distribusis from models.distribusi_file_model import DistribusiFiles from describer.forms.describe_files_form import DescribeFilesForm from describer.forms.redistribusi_form import ReDistribusiForm +from distribusikan.distribusi_workflow import run_distribusi, get_css_file describer = Blueprint( "describer", @@ -47,19 +49,22 @@ def show_distribusi_files(distribusiname): ) -@describer.route("/redistribusi/") +@describer.route("/redistribusi/", methods=["POST"]) @login_required def re_distribusi_files(distribusiname): distribusi = Distribusis.query.filter_by( distribusiname=distribusiname ).first() redistribusi_form = ReDistribusiForm() - distribusi_file_forms = get_distribusi_file_forms(distribusi.id) - return render_template( - "describe.html", - distribusiname=distribusiname, - redistribusi_form=redistribusi_form, - distribusi_file_forms=distribusi_file_forms, + if redistribusi_form.validate_on_submit(): + userfolder = os.path.join("stash", distribusi.distribusiname) + cssfile = get_css_file(distribusi) + run_distribusi(userfolder, cssfile) + return redirect( + url_for( + "describer.show_distribusi_files", + distribusiname=distribusi.distribusiname, + ) ) diff --git a/verse/distribusikan/distribusi_workflow.py b/verse/distribusikan/distribusi_workflow.py index 43b6666..d7a524e 100644 --- a/verse/distribusikan/distribusi_workflow.py +++ b/verse/distribusikan/distribusi_workflow.py @@ -96,6 +96,7 @@ def get_css_file(distribusi): def run_distribusi(userfolder, cssfile): + print(f"Run distribusi on this folder: {userfolder} with css:{cssfile}") parser = build_argparser() args = parser.parse_args(["-t", "--menu-with-index", "-s", cssfile]) distribusify(args, userfolder)