django-eav2/eav/decorators.py
2018-06-03 15:42:16 +02:00

26 lines
686 B
Python

'''
Decorators.
This module contains pure wrapper functions used as decorators.
Functions in this module should be simple and not involve complex logic.
'''
def register_eav(**kwargs):
'''
Registers the given model(s) classes and wrapped Model class with
django-eav::
@register_eav
class Author(models.Model):
pass
'''
from . import register
from django.db.models import Model
def _model_eav_wrapper(model_class):
if not issubclass(model_class, Model):
raise ValueError('Wrapped class must subclass Model.')
register(model_class, **kwargs)
return model_class
return _model_eav_wrapper