Skip to content

Instantly share code, notes, and snippets.

@dario61081
Created February 26, 2024 14:22
Show Gist options
  • Save dario61081/f810593eb5e12f36fc5e970aec0d2352 to your computer and use it in GitHub Desktop.
Save dario61081/f810593eb5e12f36fc5e970aec0d2352 to your computer and use it in GitHub Desktop.
mensajes del sistema
from flask import flash, session
from core.logs import logger
str_message_success = 'Operación ejecutada con exito'
str_message_error = 'Ha ocurrido un error al ejecutar la operación'
def success_message(msg: str = None):
"""Show positive flash message"""
if not msg:
msg = str_message_success
flash(msg, 'success')
logger.info(msg, user=session.get('username'), source="messages")
def error_message(msg: str = None):
"""Show negative flash message"""
if not msg:
msg = str_message_error
flash(msg, 'danger')
logger.error(msg, user=session.get('username'), source="messages")
def alert_message(msg: str = None):
"""Show alert flash message"""
flash(msg, 'warning')
logger.info(msg, user=session.get('username'), source="messages")
def info_message(msg: str = None):
"""Show message flash message"""
flash(msg, 'info')
logger.info(msg, user=session.get('username'), source="messages")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment