Browse Source

selector redirects to wip file describer page

main
crunk 6 months ago
parent
commit
ff8215a7de
  1. 22
      verse/describer/describe_files.py
  2. 2
      verse/describer/templates/describe.html
  3. 34
      verse/describer/templates/describe_files/describe.html
  4. 17
      verse/distribusikan/distribusiselector.py
  5. 7
      verse/distribusikan/templates/distribusikan/distribusiworkflow/selector.html
  6. 2
      verse/file_crawler.py
  7. 2
      verse/forms/selectorform.py
  8. 36
      verse/migrations/versions/8ede45e978d9_.py
  9. 2
      verse/models/distribusi_file_model.py
  10. 19
      verse/start.py

22
verse/describer/describe_files.py

@ -0,0 +1,22 @@
from flask import Blueprint, render_template
from models.distribusi_model import Distribusis
from models.distribusi_file_model import DistribusiFiles
describer = Blueprint(
"describer",
__name__,
template_folder="templates/describe_files",
static_folder="static",
)
@describer.route("/<string:distribusiname>")
def describe_distribusi_files(distribusiname):
distribusi = Distribusis.query.filter_by(
distribusiname=distribusiname
).first()
distribusi_files = DistribusiFiles.query.filter_by(
distribusi=distribusi.id
).all()
print(distribusi_files)
return render_template("describe.html", distribusi_files=distribusi_files)

2
verse/describer/templates/describe.html

@ -1,2 +0,0 @@
{% extends "base/base.html" %}
{% block main %}

34
verse/describer/templates/describe_files/describe.html

@ -0,0 +1,34 @@
{% extends "base/base.html" %}
{% block main %}
<div id="buttons">
{% if current_user.is_authenticated %}
<div class="distribusi">
<a href="/distribusi">
<input type="button" name="button" value="Distribusi"></input>
</a>
</div>
{% if adminuser %}
<div class="admin">
<a href="/admin">
<input type="button" name="button" value="Admin"></input>
</a>
</div>
{% endif %}
<div class="logout">
<a href="/logout">
<input type="button" name="button" value="Logout"></input>
</a>
</div>
{% endif %}
<div class="help">
<a href="/help">
<input type="button" name="button" value="Help"></input>
</a>
</div>
</div>
<div class="distribusi_files">
{% for file in distribusi_files %}
<p>{{file}}</p>
{% endfor%}
</div>
{% endblock %}

17
verse/distribusikan/distribusiselector.py

@ -1,7 +1,7 @@
import os
import shutil
from flask import flash, render_template
from flask import flash, render_template, redirect, url_for
from flask_login import current_user
from sqlalchemy.exc import (
DatabaseError,
@ -10,8 +10,9 @@ from sqlalchemy.exc import (
InvalidRequestError,
)
from app import db
from app import db, get_app
from distribusikan.distribusisinfo import DistribusisInfo
from describer.describe_files import describe_distribusi_files
from forms.distribusiform import DistribusiForm
from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm
@ -32,6 +33,8 @@ def DistribusiSelector():
if selectorform.validate_on_submit():
if selectorform.new.data:
SelectNewDistribusi()
if selectorform.describe.data:
return SelectDescribeDistribusi(selectorform.distribusis.data)
if selectorform.delete.data:
selectorform = DeleteDistribusi(selectorform.distribusis.data)
selectorform.distribusis.choices = (
@ -64,6 +67,16 @@ def SelectNewDistribusi():
SelectCurrentDistribusi("new")
def SelectDescribeDistribusi(distribusiname):
app = get_app
return redirect(
url_for(
"describer.describe_distribusi_files",
distribusiname=distribusiname,
)
)
def SelectUpdateDistribusi(distribusiname):
print(f"Update this distribusi {distribusiname}")
SelectCurrentDistribusi(distribusiname)

7
verse/distribusikan/templates/distribusikan/distribusiworkflow/selector.html

@ -18,6 +18,13 @@
{{ selectorform.update }}
</fieldset>
<hr>
<p>
Describe your distribusi files. Add description texts, tags for search
or add alt-text for images</p>
<fieldset class="button required multiselect">
{{ selectorform.describe }}
</fieldset>
<hr>
<p>
This will delete your distribusi site.
<strong> This action cannot be undone! </strong>

2
verse/file_crawler.py

@ -43,7 +43,7 @@ def _add_distribusi_file_to_db(distribusi, full_path, type):
app.logger.error("Something went wrong!")
except IntegrityError:
db.session.rollback()
app.logger.error("file %s already exists!", full_path)
app.logger.error("File %s already exists!", full_path)
except DataError:
db.session.rollback()
app.logger.error("%s Invalid Entry", full_path)

2
verse/forms/selectorform.py

@ -9,4 +9,6 @@ class SelectorForm(FlaskForm):
update = SubmitField("update")
describe = SubmitField("describe")
delete = SubmitField("delete")

36
verse/migrations/versions/8ede45e978d9_.py

@ -1,36 +0,0 @@
"""empty message
Revision ID: 8ede45e978d9
Revises:
Create Date: 2024-04-30 22:15:48.023060
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8ede45e978d9'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('distribusi_files', schema=None) as batch_op:
batch_op.alter_column('type',
existing_type=sa.VARCHAR(length=300),
nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('distribusi_files', schema=None) as batch_op:
batch_op.alter_column('type',
existing_type=sa.VARCHAR(length=300),
nullable=False)
# ### end Alembic commands ###

2
verse/models/distribusi_file_model.py

@ -15,4 +15,4 @@ class DistribusiFiles(db.Model):
description = db.Column(db.String(4096), nullable=True, unique=False)
def __repr__(self):
return "<Distribusi_File %r>" % self.distribusiname
return "<Distribusi_File %r>" % self.path

19
verse/start.py

@ -2,25 +2,17 @@
from datetime import timedelta
from flask import (
Blueprint,
redirect,
render_template,
send_from_directory,
session,
url_for,
)
from flask import (Blueprint, redirect, render_template, send_from_directory,
session, url_for)
from flask_login import current_user, login_required, logout_user
from flask_mail import Mail
from flask_wtf.csrf import CSRFError
# Interface! these are seperate files in main folder
from adminpage import AdminPage
from app import create_app, login_manager
from describer.describe_files import describer
from distribusikan.distribusikan import distribusikan
from distribusikan.distribusisinfo import DistribusisInfo
# Use upload form to populate filters
from forms.uploadform import UploadForm
from models.distribusi_model import Distribusis
from models.user_model import User
@ -31,11 +23,14 @@ from statuspengguna.registeruser import register_user
APP = create_app()
stash_page = Blueprint("stash_page", __name__, static_folder="stash")
APP.register_blueprint(stash_page)
APP.register_blueprint(describer, url_prefix="/describe")
APP.register_blueprint(login_section, url_prefix="/login")
APP.register_blueprint(register_user, url_prefix="/register")
APP.register_blueprint(forgot_password, url_prefix="/login/forgotpassword")
APP.register_blueprint(distribusikan)
APP.register_blueprint(stash_page)
@APP.before_request

Loading…
Cancel
Save