working file desriber
This commit is contained in:
parent
b71a694777
commit
90d4251fd9
@ -84,33 +84,29 @@ def get_distribusi_file_forms(distribusi_id):
|
||||
|
||||
|
||||
def save_described_file_to_db(describe_form, distribusi_file):
|
||||
if describe_form.validate_on_submit():
|
||||
try:
|
||||
if describe_form.description.data:
|
||||
distribusi_file.description = describe_form.description
|
||||
if describe_form.alttext.data:
|
||||
distribusi_file.alttext = describe_form.alttext
|
||||
if describe_form.searchtags.data:
|
||||
distribusi_file.tags = describe_form.searchtags
|
||||
db.session.add(distribusi_file)
|
||||
db.session.commit()
|
||||
except (InvalidRequestError, IntegrityError):
|
||||
db.session.rollback()
|
||||
describe_form.save.errors.append("Something went wrong!")
|
||||
flash("Something went wrong!", "danger")
|
||||
except DataError:
|
||||
db.session.rollback()
|
||||
describe_form.save.errors.append("Invalid Entry")
|
||||
flash("Invalid Entry", "warning")
|
||||
except InterfaceError:
|
||||
db.session.rollback()
|
||||
describe_form.save.errors.append(
|
||||
"Error connecting to the database"
|
||||
)
|
||||
flash("Error connecting to the database", "danger")
|
||||
except DatabaseError:
|
||||
db.session.rollback()
|
||||
describe_form.save.errors.append(
|
||||
"Error connecting to the database"
|
||||
)
|
||||
flash("Error connecting to the database", "danger")
|
||||
try:
|
||||
if describe_form.description.data:
|
||||
print(distribusi_file.id)
|
||||
distribusi_file.description = describe_form.description.data
|
||||
if describe_form.alttext.data:
|
||||
distribusi_file.alttext = describe_form.alttext.data
|
||||
if describe_form.searchtags.data:
|
||||
distribusi_file.tags = describe_form.searchtags.data
|
||||
db.session.add(distribusi_file)
|
||||
db.session.commit()
|
||||
except (InvalidRequestError, IntegrityError):
|
||||
db.session.rollback()
|
||||
describe_form.save.errors.append("Something went wrong!")
|
||||
flash("Something went wrong!", "danger")
|
||||
except DataError:
|
||||
db.session.rollback()
|
||||
describe_form.save.errors.append("Invalid Entry")
|
||||
flash("Invalid Entry", "warning")
|
||||
except InterfaceError:
|
||||
db.session.rollback()
|
||||
describe_form.save.errors.append("Error connecting to the database")
|
||||
flash("Error connecting to the database", "danger")
|
||||
except DatabaseError:
|
||||
db.session.rollback()
|
||||
describe_form.save.errors.append("Error connecting to the database")
|
||||
flash("Error connecting to the database", "danger")
|
||||
|
Loading…
Reference in New Issue
Block a user