# Path: zipfelchappe/app_settings.py
# USER_EMAIL_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_EMAIL_FIELD', 'email')
# 
# USER_FIRST_NAME_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_FIRST_NAME_FIELD', 'first_name')
# 
# USER_LAST_NAME_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_LAST_NAME_FIELD', 'last_name')


from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from .app_settings import (
    USER_EMAIL_FIELD, USER_FIRST_NAME_FIELD, USER_LAST_NAME_FIELD
)
    return mark_safe(format_string.format(*args_safe, **kwargs_safe))


def get_object_or_none(klass, *args, **kwargs):
    """
    Modelled after get_object_or_404
    """

    if isinstance(klass, models.query.QuerySet):
        queryset = klass
    elif isinstance(klass, models.manager.Manager):
        queryset = klass.all()
    else:
        queryset = klass._default_manager.all()

    try:
        return queryset.get(*args, **kwargs)
    except (queryset.model.DoesNotExist, ValueError):
        return None


def get_user_search_fields():
    ''' Get names of searchable fields on user model

    Due to custom user models the search_fields values for fields on the
    user model can't be set statically. This model returns the available
    fields on the model which can be used to dynamically generate
    search_fields values
    '''
    # get field names for user fields

# Path: zipfelchappe/app_settings.py
# USER_EMAIL_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_EMAIL_FIELD', 'email')
# 
# USER_FIRST_NAME_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_FIRST_NAME_FIELD', 'first_name')
# 
# USER_LAST_NAME_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_LAST_NAME_FIELD', 'last_name')


# Path: zipfelchappe/utils.py
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from .app_settings import (
    USER_EMAIL_FIELD, USER_FIRST_NAME_FIELD, USER_LAST_NAME_FIELD
)

    return mark_safe(format_string.format(*args_safe, **kwargs_safe))


def get_object_or_none(klass, *args, **kwargs):
    """
    Modelled after get_object_or_404
    """

    if isinstance(klass, models.query.QuerySet):
        queryset = klass
    elif isinstance(klass, models.manager.Manager):
        queryset = klass.all()
    else:
        queryset = klass._default_manager.all()

    try:
        return queryset.get(*args, **kwargs)
    except (queryset.model.DoesNotExist, ValueError):
        return None


def get_user_search_fields():
    ''' Get names of searchable fields on user model

    Due to custom user models the search_fields values for fields on the
    user model can't be set statically. This model returns the available
    fields on the model which can be used to dynamically generate
    search_fields values
    '''
    # get field names for user fields

    fields = [USER_EMAIL_FIELD, USER_FIRST_NAME_FIELD, USER_LAST_NAME_FIELD]