def get_django_recorder():
    try:
        import django
        from django.conf import settings
        from pyavatax.models import AvaTaxRecord
    except __HOLE__:
        return MockDjangoRecorder
    else:
        if hasattr(settings, 'NO_PYAVATAX_INTEGRATION') and settings.NO_PYAVATAX_INTEGRATION:
            return MockDjangoRecorder
        else:
            class RealDjangoRecorder(object):
                @staticmethod
                def failure(doc, response):
                    AvaTaxRecord.objects.create(doc_code=getattr(doc, 'DocCode', None), failure_details=response._details)

                @staticmethod
                def success(doc):
                    AvaTaxRecord.objects.filter(doc_code=getattr(doc, 'DocCode', None)).update(success_on=timezone.now())
            return RealDjangoRecorder
dataset/ETHPy150Open activefrequency/pyavatax/pyavatax/django_integration.py/get_django_recorder