main #12

Merged
crunk merged 49 commits from Toolsheds/distribusi-verse:main into main 2024-07-03 13:48:57 +02:00
10 changed files with 89 additions and 54 deletions
Showing only changes of commit ff8215a7de - Show all commits

View File

@ -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)

View File

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

View File

@ -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 %}

View File

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

View File

@ -18,6 +18,13 @@
{{ selectorform.update }} {{ selectorform.update }}
</fieldset> </fieldset>
<hr> <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> <p>
This will delete your distribusi site. This will delete your distribusi site.
<strong> This action cannot be undone! </strong> <strong> This action cannot be undone! </strong>

View File

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

View File

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

View File

@ -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 ###

View File

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

View File

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