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