main #12
@ -8,7 +8,7 @@ bleach-allowlist==1.0.3
|
||||
blinker==1.7.0
|
||||
cffi
|
||||
click==8.1.7
|
||||
distribusi @ git+https://git.vvvvvvaria.org/crunk/distribusi@5934122c6ec1452d975b7cfe6582f9417fd5fdd0
|
||||
distribusi @ git+https://git.vvvvvvaria.org/crunk/distribusi@3eefd6e5ca7048555d441df8c6fbf4f2e255acac
|
||||
dnspython==2.1.0
|
||||
email-validator==1.1.3
|
||||
Flask==3.0.3
|
||||
|
@ -78,6 +78,7 @@ def describe_file(file_id):
|
||||
)
|
||||
save_described_file_to_db(describe_form, distribusi_file)
|
||||
add_alttext_to_file(describe_form, distribusi_file)
|
||||
add_description_to_file(describe_form, distribusi_file)
|
||||
distribusi = Distribusis.query.filter_by(
|
||||
id=distribusi_file.distribusi
|
||||
).first()
|
||||
@ -143,6 +144,17 @@ def add_alttext_to_file(describe_form, distribusi_file):
|
||||
if not describe_form.alttext.data:
|
||||
return
|
||||
filename_no_ext = os.path.splitext(distribusi_file.path)[0]
|
||||
with open(f'{filename_no_ext}_alttext.txt', 'w') as alttext_file:
|
||||
with open(f"{filename_no_ext}_alttext.txt", "w") as alttext_file:
|
||||
alttext_file.write(describe_form.alttext.data)
|
||||
return
|
||||
|
||||
|
||||
def add_description_to_file(describe_form, distribusi_file):
|
||||
if not describe_form.description.data:
|
||||
return
|
||||
filename_no_ext = os.path.splitext(distribusi_file.path)[0]
|
||||
with open(
|
||||
f"{filename_no_ext}_dv_description.txt", "w"
|
||||
) as description_file:
|
||||
description_file.write(describe_form.description.data)
|
||||
return
|
||||
|
@ -31,6 +31,10 @@ def _get_distribusi_from_path(path):
|
||||
def _add_distribusi_file_to_db(distribusi, full_path, type):
|
||||
app = get_app()
|
||||
app.logger.info(f"adding file to database: {full_path} type: {type}")
|
||||
distribusi_file = DistribusiFiles.query.filter_by(path=full_path).first()
|
||||
if distribusi_file is not None:
|
||||
app.logger.error(f"File already in database: {full_path}")
|
||||
return
|
||||
try:
|
||||
new_distribusi_file = DistribusiFiles(
|
||||
path=full_path,
|
||||
@ -63,6 +67,10 @@ def add_distribusi_files_to_db(path):
|
||||
for root, dirs, files in os.walk(path, topdown=True):
|
||||
files = list(filter(lambda f: not f.startswith("."), files))
|
||||
files = list(filter(lambda f: not f.endswith(".html"), files))
|
||||
files = list(filter(lambda f: not f.endswith("_thumbnail.jpg"), files))
|
||||
files = list(filter(lambda f: not f.endswith("_alttext.txt"), files))
|
||||
files = list(filter(lambda f: not f.endswith("_dv_description.txt"), files))
|
||||
|
||||
for file in files:
|
||||
full_path = os.path.join(root, file)
|
||||
distribusi_file = DistribusiFiles.query.filter_by(
|
||||
|
@ -42,7 +42,9 @@ def distribusi_selector():
|
||||
if selectorform.update.data:
|
||||
select_update_distribusi(selectorform.distribusis.data)
|
||||
current_distribusi = UserHelper.current_distribusi()
|
||||
uploadform = auto_fill_in_upload_form(uploadform, current_distribusi)
|
||||
uploadform = auto_fill_in_upload_form(
|
||||
uploadform, current_distribusi
|
||||
)
|
||||
|
||||
return render_distribusi_template(
|
||||
selectorform, uploadform, current_distribusi
|
||||
|
@ -14,17 +14,19 @@ config = context.config
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
fileConfig(config.config_file_name)
|
||||
logger = logging.getLogger('alembic.env')
|
||||
logger = logging.getLogger("alembic.env")
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
config.set_main_option(
|
||||
'sqlalchemy.url',
|
||||
str(current_app.extensions['migrate'].db.get_engine().url).replace(
|
||||
'%', '%%'))
|
||||
target_metadata = current_app.extensions['migrate'].db.metadata
|
||||
"sqlalchemy.url",
|
||||
str(current_app.extensions["migrate"].db.get_engine().url).replace(
|
||||
"%", "%%"
|
||||
),
|
||||
)
|
||||
target_metadata = current_app.extensions["migrate"].db.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
@ -65,20 +67,20 @@ def run_migrations_online():
|
||||
# when there are no changes to the schema
|
||||
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
|
||||
def process_revision_directives(context, revision, directives):
|
||||
if getattr(config.cmd_opts, 'autogenerate', False):
|
||||
if getattr(config.cmd_opts, "autogenerate", False):
|
||||
script = directives[0]
|
||||
if script.upgrade_ops.is_empty():
|
||||
directives[:] = []
|
||||
logger.info('No changes in schema detected.')
|
||||
logger.info("No changes in schema detected.")
|
||||
|
||||
connectable = current_app.extensions['migrate'].db.get_engine()
|
||||
connectable = current_app.extensions["migrate"].db.get_engine()
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
process_revision_directives=process_revision_directives,
|
||||
**current_app.extensions['migrate'].configure_args
|
||||
**current_app.extensions["migrate"].configure_args,
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
|
@ -76,7 +76,9 @@ class UserHelper:
|
||||
|
||||
def distribusi_limit_reached():
|
||||
user = User.query.filter_by(email=current_user.email).first()
|
||||
distribusiamount = len(DistribusisInfo.get_user_distribusis(user.email))
|
||||
distribusiamount = len(
|
||||
DistribusisInfo.get_user_distribusis(user.email)
|
||||
)
|
||||
if distribusiamount > 19:
|
||||
print("user already has 20 distribusis")
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user