Commit efbc767d8ec31f4706f627e4ec1ec3b8fbbb67a2

Authored by Macartur Sousa
1 parent a3ff3d5d

Fixed noosfero_data_api with empty json_data

Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing 1 changed file with 6 additions and 0 deletions   Show diff stats
colab/plugins/noosfero/data_importer.py
@@ -67,6 +67,9 @@ class NoosferoDataImporter(PluginDataImporter): @@ -67,6 +67,9 @@ class NoosferoDataImporter(PluginDataImporter):
67 def fetch_communities(self): 67 def fetch_communities(self):
68 json_data = self.get_json_data('/api/v1/communities', 1) 68 json_data = self.get_json_data('/api/v1/communities', 1)
69 69
  70 + if len(json_data) == 0:
  71 + return
  72 +
70 json_data = json_data['communities'] 73 json_data = json_data['communities']
71 for element in json_data: 74 for element in json_data:
72 community = NoosferoCommunity() 75 community = NoosferoCommunity()
@@ -82,6 +85,9 @@ class NoosferoDataImporter(PluginDataImporter): @@ -82,6 +85,9 @@ class NoosferoDataImporter(PluginDataImporter):
82 def fetch_articles(self): 85 def fetch_articles(self):
83 json_data = self.get_json_data('/api/v1/articles', 1) 86 json_data = self.get_json_data('/api/v1/articles', 1)
84 87
  88 + if len(json_data) == 0:
  89 + return
  90 +
85 json_data = json_data['articles'] 91 json_data = json_data['articles']
86 92
87 for element in json_data: 93 for element in json_data: