Added the limitation so that the default currency and the currencies in use cannot be deleted.

This commit is contained in:
imacat committed 2023-03-22 00:37:39 +08:00
1 parent b60cc7902d
commit bbf3ee3320
4 files changed
+185 -120

No files matched your search

+3
View File
@@ -160,6 +160,9 @@ def delete_currency(currency: Currency) -> redirect:
:return: The redirection to the currency list on success, or the currency
detail on error.
"""
if not currency.can_delete:
flash(s(lazy_gettext("The currency cannot be deleted.")), "error")
return redirect(inherit_next(__get_detail_uri(currency)))
currency.delete()
db.session.commit()
flash(s(lazy_gettext("The currency is deleted successfully.")), "success")