@receiver(activity_addfile)
def new_file(sender, instance, file, **kwargs):
    if instance._bmfmeta.has_logging:
        history = Activity(
            user=instance.modified_by,
            parent_ct=ContentType.objects.get_for_model(sender),
            parent_id=instance.pk,
            action=ACTION_FILE,
            text=json.dumps({
                'pk': file.pk,
                'size': file.size,
                'name': '%s' % file,
            }, cls=DjangoBMFEncoder),
        )
        history.save()
dataset/ETHPy150Open django-bmf/django-bmf/djangobmf/models/__init__.py/new_file/original