Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CatalogItem:
- """
- Decorator class, collect all catalog modules and his item classes in cls.REGISTRY
- """
- REGISTRY = {}
- def __init__(self, name):
- self.verbose_name = name
- def __call__(self, cls):
- self.register(cls)
- return cls
- def register(self, cls):
- """
- Register item modules and its item classes.
- :param cls: Class object
- :return:
- """
- module_name, module = self.register_module(cls)
- self.__class__.REGISTRY[module_name] = self.register_item(module, cls)
- @CatalogItem('Куплю квартиру')
- class FlatBuy(BaseAd):
- building_type = BuildingTypeField(choices=BuildingTypeField.get_choices_for_model_field())
Add Comment
Please, Sign In to add comment