From 05fdff650fee475effc59c1a1ed449bf60ca5e26 Mon Sep 17 00:00:00 2001 From: Pierre Romera Date: Mon, 3 Feb 2014 12:18:36 +0100 Subject: [PATCH 1/3] Debug test --- app/detective/admin.py | 2 +- app/detective/models.py | 2 +- app/detective/register.py | 4 ++-- app/detective/tests/api.py | 1 - app/detective/topics/common/summary.py | 6 +++--- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/detective/admin.py b/app/detective/admin.py index dc1bd7bd..241317af 100644 --- a/app/detective/admin.py +++ b/app/detective/admin.py @@ -58,7 +58,7 @@ def formfield_for_choice_field(self, db_field, request, **kwargs): # Get the current topic with the ID set into the parent form topic = Topic.objects.get(id=request.topic_id) # Get the topic's models - models = utils.get_topic_models(topic) + models = topic.get_models() for model in models: model_name = getattr(model._meta, "verbose_name").title() subset = [] diff --git a/app/detective/models.py b/app/detective/models.py index 3ba17cd7..82e5b099 100644 --- a/app/detective/models.py +++ b/app/detective/models.py @@ -177,7 +177,7 @@ def clean(self): def field(self): field = None if self.name: - topic_models = utils.get_topic_models(self.topic) + topic_models = self.topic.get_models() for model in topic_models: # Retreive every relationship field for this model for f in utils.get_model_fields(model): diff --git a/app/detective/register.py b/app/detective/register.py index ed148231..ccce79a2 100644 --- a/app/detective/register.py +++ b/app/detective/register.py @@ -45,9 +45,9 @@ def default_rules(topic): # ModelRules is a singleton that record every model rules rules = ModelRules() # We cant import this early to avoid bi-directional dependancies - from app.detective.utils import get_topic_models, import_class + from app.detective.utils import import_class # Get all registered models - models = get_topic_models(topic) + models = Topic.objects.get(module=topic).get_models() # Set "is_searchable" to true on every model with a name for model in models: # If the current model has a name diff --git a/app/detective/tests/api.py b/app/detective/tests/api.py index c23327bc..4cc092a3 100644 --- a/app/detective/tests/api.py +++ b/app/detective/tests/api.py @@ -764,5 +764,4 @@ def test_topic_has_summary_syntax_from_ontology(self): def test_topic_has_summary_syntax_from_file(self): resp = self.api_client.get('/api/energy/v1/summary/syntax/', format='json', authentication=self.get_super_credentials()) - print resp.content self.assertValidJSONResponse(resp) \ No newline at end of file diff --git a/app/detective/topics/common/summary.py b/app/detective/topics/common/summary.py index 6c4caefc..5d87d892 100644 --- a/app/detective/topics/common/summary.py +++ b/app/detective/topics/common/summary.py @@ -146,7 +146,7 @@ def summary_forms(self, bundle, request): rulesManager = topics_rules() # Fetch every registered model # to print out its rules - for model in utils.get_topic_models(self.topic.module): + for model in self.topic.get_models(): name = model.__name__.lower() rules = rulesManager.model(model).all() fields = utils.get_model_fields(model) @@ -384,7 +384,7 @@ def search(self, query): def rdf_search(self, subject, predicate, obj): obj = obj["name"] if "name" in obj else obj # retrieve all models in current topic - all_models = dict((model.__name__, model) for model in utils.get_topic_models(self.topic.module)) + all_models = dict((model.__name__, model) for model in self.topic.get_models()) # If the received obj describe a literal value if self.is_registered_literal(predicate["name"]): # Get the field name into the database @@ -434,7 +434,7 @@ def rdf_search(self, subject, predicate, obj): def get_models_output(self): # Select only some atribute output = lambda m: {'name': m.__name__, 'label': m._meta.verbose_name.title()} - return [ output(m) for m in utils.get_topic_models(self.topic.module) ] + return [ output(m) for m in self.topic.get_models() ] def get_relationship_search(self): isRelationship = lambda t: t.type == "relationship" From a7f8733667d058d40922b95696084b41602d0ab1 Mon Sep 17 00:00:00 2001 From: Pierre Romera Date: Mon, 3 Feb 2014 12:53:28 +0100 Subject: [PATCH 2/3] Reduce bower dependancies for sizes optimisation --- app/detective/templates/home.dj.html | 12 ++++++------ bower.json | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/detective/templates/home.dj.html b/app/detective/templates/home.dj.html index 173efd21..9a0655b6 100644 --- a/app/detective/templates/home.dj.html +++ b/app/detective/templates/home.dj.html @@ -13,8 +13,8 @@ {% compress js %} - - + + @@ -24,10 +24,10 @@ {% endcompress %} - - - - + + + + diff --git a/bower.json b/bower.json index 8888bbb3..fbfea5b0 100644 --- a/bower.json +++ b/bower.json @@ -5,15 +5,15 @@ "angular-elastic": "2.2.0", "angular-ui-bootstrap-bower": "0.6.0", "bootstrap": "3.0.0", - "chroma-js": "0.5.2", + "chroma-js": "https://raw.github.com/gka/chroma.js/7b06f8df0e95450fa6ed9266c3cc3efbf3e53fc9/chroma.min.js", "jquery.scrollTo": "1.4.6", "js-md5": "1.0.3", "modernizr": "2.6.2", "raphael": "2.1.2", "typeahead.js": "0.9.3", "underscore": "1.5.2", - "unstable-angular-complete": "1.1.5", - "kartograph.js": "git://github.com/kartograph/kartograph.js", + "angular-all-unstable": "1.1.5", + "kartograph.js": "https://raw.github.com/kartograph/kartograph.js/3d89db48d9e1ea020972e8fb9566bea1dc8aa495/kartograph-0.8.2.min.js", "jquery": "1.9.1", "ng-file-upload": "~1.2.3", "ngprogress-lite": "~1.0.4", From 347a1a1e1f1a4a8999dcf60a19fd428ccf624e7b Mon Sep 17 00:00:00 2001 From: Pierre Romera Date: Mon, 3 Feb 2014 12:54:35 +0100 Subject: [PATCH 3/3] Bumped version --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index fbfea5b0..96eabdc2 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "detective", - "version": "1.2.2", + "version": "1.2.3", "dependencies": { "angular-elastic": "2.2.0", "angular-ui-bootstrap-bower": "0.6.0",