"""
Template tags for notifications
"""
from django import template

register = template.Library()


@register.filter
def get_attr(obj, field_name):
    """
    Get attribute from object by string name.
    Usage: {{ settings|get_attr:"explanation_requested_email" }}
    """
    try:
        return getattr(obj, field_name, False)
    except:
        return False
