-def _ct_model_name(model):
- opts = model._meta
- while opts.proxy:
- model = opts.proxy_for_model
- opts = model._meta
- return opts.object_name.lower()
+_value_models = {}
+_value_models_ct_pks = []
+
+
+def register_value_model(model):
+ if issubclass(model, models.Model):
+ if model not in _value_models:
+ _value_models[model] = ContentType.objects.get_for_model(model)
+ _value_models_ct_pks.append(_value_models[model].pk)
+ else:
+ raise TypeError('philo.models.register_value_model only accepts subclasses of django.db.models.Model')
+
+
+def unregister_value_model(model):
+ if issubclass(model, models.Model):
+ if model in _value_models:
+ _value_models_ct_pks.remove(_value_models[model].pk)
+ del _value_models[model]
+ else:
+ raise TypeError('philo.models.unregister_value_model only accepts subclasses of django.db.models.Model')