working file desriber

This commit is contained in:
crunk 2024-06-02 21:49:27 +02:00
parent b71a694777
commit 90d4251fd9

View File

@ -84,33 +84,29 @@ def get_distribusi_file_forms(distribusi_id):
def save_described_file_to_db(describe_form, distribusi_file): def save_described_file_to_db(describe_form, distribusi_file):
if describe_form.validate_on_submit(): try:
try: if describe_form.description.data:
if describe_form.description.data: print(distribusi_file.id)
distribusi_file.description = describe_form.description distribusi_file.description = describe_form.description.data
if describe_form.alttext.data: if describe_form.alttext.data:
distribusi_file.alttext = describe_form.alttext distribusi_file.alttext = describe_form.alttext.data
if describe_form.searchtags.data: if describe_form.searchtags.data:
distribusi_file.tags = describe_form.searchtags distribusi_file.tags = describe_form.searchtags.data
db.session.add(distribusi_file) db.session.add(distribusi_file)
db.session.commit() db.session.commit()
except (InvalidRequestError, IntegrityError): except (InvalidRequestError, IntegrityError):
db.session.rollback() db.session.rollback()
describe_form.save.errors.append("Something went wrong!") describe_form.save.errors.append("Something went wrong!")
flash("Something went wrong!", "danger") flash("Something went wrong!", "danger")
except DataError: except DataError:
db.session.rollback() db.session.rollback()
describe_form.save.errors.append("Invalid Entry") describe_form.save.errors.append("Invalid Entry")
flash("Invalid Entry", "warning") flash("Invalid Entry", "warning")
except InterfaceError: except InterfaceError:
db.session.rollback() db.session.rollback()
describe_form.save.errors.append( describe_form.save.errors.append("Error connecting to the database")
"Error connecting to the database" flash("Error connecting to the database", "danger")
) except DatabaseError:
flash("Error connecting to the database", "danger") db.session.rollback()
except DatabaseError: describe_form.save.errors.append("Error connecting to the database")
db.session.rollback() flash("Error connecting to the database", "danger")
describe_form.save.errors.append(
"Error connecting to the database"
)
flash("Error connecting to the database", "danger")