Commit 15542c2f authored by Jan Čermák's avatar Jan Čermák

messages convenience functions used instead of add_message

parent 8cb3f0fd
...@@ -81,9 +81,9 @@ class ConfigPageMixin(object): ...@@ -81,9 +81,9 @@ class ConfigPageMixin(object):
if no_messages: if no_messages:
return result return result
if result: if result:
messages.add_message(_("Configuration was successfully saved."), messages.SUCCESS) messages.success(_("Configuration was successfully saved."))
else: else:
messages.add_message(_("There were some errors in your input."), messages.WARNING) messages.warning(_("There were some errors in your input."))
return result return result
...@@ -138,9 +138,9 @@ class MaintenanceConfigPage(ConfigPageMixin, MaintenanceHandler): ...@@ -138,9 +138,9 @@ class MaintenanceConfigPage(ConfigPageMixin, MaintenanceHandler):
result = False result = False
try: try:
result = super(MaintenanceConfigPage, self).save(no_messages=True, *args, **kwargs) result = super(MaintenanceConfigPage, self).save(no_messages=True, *args, **kwargs)
messages.add_message(_("Configuration was successfully restored."), messages.SUCCESS) messages.success(_("Configuration was successfully restored."))
except ConfigRestoreError: except ConfigRestoreError:
messages.add_message(_("Configuration could not be loaded, backup file is probably corrupted."), messages.ERROR) messages.error(_("Configuration could not be loaded, backup file is probably corrupted."))
logger.exception("Error when restoring backup.") logger.exception("Error when restoring backup.")
return result return result
...@@ -225,7 +225,7 @@ def config_page_post(page_name): ...@@ -225,7 +225,7 @@ def config_page_post(page_name):
bottle.redirect(request.fullpath) bottle.redirect(request.fullpath)
except TypeError: except TypeError:
# raised by Validator - could happen when the form is posted with wrong fields # raised by Validator - could happen when the form is posted with wrong fields
messages.add_message(_("Configuration could not be saved due to an internal error."), messages.ERROR) messages.error(_("Configuration could not be saved due to an internal error."))
logger.exception("Error when saving form.") logger.exception("Error when saving form.")
logger.warning("Form not saved.") logger.warning("Form not saved.")
return config_page.render(config_pages=config_page_map.display_names(), return config_page.render(config_pages=config_page_map.display_names(),
......
...@@ -333,9 +333,9 @@ def step_post(number=1): ...@@ -333,9 +333,9 @@ def step_post(number=1):
bottle.redirect(reverse("wizard_step", number=int(number) + 1)) bottle.redirect(reverse("wizard_step", number=int(number) + 1))
except TypeError: except TypeError:
# raised by Validator - could happen when the form is posted with wrong fields # raised by Validator - could happen when the form is posted with wrong fields
messages.add_message(_("Configuration could not be saved due to an internal error."), messages.ERROR) messages.error(_("Configuration could not be saved due to an internal error."))
logger.exception("Error when saving form.") logger.exception("Error when saving form.")
messages.add_message(_("There were some errors in your input."), messages.ERROR) messages.warning(_("There were some errors in your input."))
logger.warning("Form not saved.") logger.warning("Form not saved.")
return wiz.render(stepnumber=number) return wiz.render(stepnumber=number)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment