From: Guillaume Pellerin Date: Tue, 26 Sep 2017 12:27:54 +0000 (+0200) Subject: Fix model listing for enumerations X-Git-Tag: 1.7.0~2^2~18 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=062931915b7824292f230ec1a2085e65b71025dd;p=telemeta.git Fix model listing for enumerations --- diff --git a/README.rst b/README.rst index 89cad744..4b37f95d 100644 --- a/README.rst +++ b/README.rst @@ -132,14 +132,14 @@ Install Thanks to Docker, Telemeta is now fully available as a docker composition ready to work. The docker based composition bundles some powerfull applications and modern frameworks out-of-the-box like: Python, Conda, Numpy, Jupyter, Gstreamer, Django, Celery, Haystack, ElasticSearch, MySQL, Redis, uWSGI, Nginx and many more. -* on **Linux**, first install `Git `_, `Docker engine `_ (>=1.9) and `docker-compose `_ (>=1.8) and open a terminal. -* on **MacOSX** or **Windows** install the `Docker Toolbox `_ and open a **Docker Quickstart Terminal**. +First, install `Docker `_ and `docker-compose `_ Then clone Telemeta:: git clone --recursive https://github.com/Parisson/Telemeta.git cd Telemeta - + docker-compose build + Start it up =========== diff --git a/telemeta/views/enum.py b/telemeta/views/enum.py index cb36814c..d1eb120c 100644 --- a/telemeta/views/enum.py +++ b/telemeta/views/enum.py @@ -60,29 +60,29 @@ class EnumView(object): model.admin = enu["admin"] def __get_enumerations_list(self): - from django.db.models import get_models - models = get_models(telemeta.models) + from django.apps import apps + app = apps.get_app_config('telemeta') + models = app.get_models() enumerations = [] for model in models: if issubclass(model, Enumeration): enumeration_property = EnumerationProperty.objects.get(enumeration_name=model._meta.model_name) if not enumeration_property.is_hidden and not enumeration_property.is_admin: enumerations.append({"name": model._meta.verbose_name, - "id": model._meta.model_name - }) - + "id": model._meta.model_name}) cmp = lambda obj1, obj2: unaccent_icmp(obj1['name'], obj2['name']) enumerations.sort(cmp) return enumerations def __get_enumeration(self, id): - from django.db.models import get_models - models = get_models(telemeta.models) - for model in models: - if model._meta.model_name == id: + from django.apps import apps + app = apps.get_app_config('telemeta') + models = app.get_models() + enumerations = [] + for model_name in models: + if model._meta.module_name == id: break - - if model._meta.model_name != id: + if model._meta.module_name != id: return None return model