From 1d48facbafdf1b5b0e19c788d883424bd65a38be Mon Sep 17 00:00:00 2001 From: Kipchirchir Sigei Date: Wed, 22 Jan 2025 15:35:47 +0300 Subject: [PATCH] Fix ona sync logic Signed-off-by: Kipchirchir Sigei --- afpolgis.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/afpolgis.py b/afpolgis.py index 571689b..0504728 100644 --- a/afpolgis.py +++ b/afpolgis.py @@ -2344,6 +2344,8 @@ def ona_fetch_data_sync_enabled(self): self.dlg.onaOkButton.setEnabled(False) api_url = self.dlg.onadata_api_url.text() formID = self.dlg.comboOnaForms.currentData() + form_str = self.dlg.comboOnaForms.currentText() + cleaned_form_str = "_".join(form_str.split(" ")) username = self.dlg.onadata_username.text() password = self.dlg.onaMLineEdit.text() page_size = int(self.dlg.onaPageSize.value()) @@ -2381,8 +2383,11 @@ def ona_fetch_data_sync_enabled(self): if formID: if hasattr(self, "vlayers"): - if self.vlayers.get(f"{formID}_{geo_field}"): - self.vlayers[f"{formID}_{geo_field}"]["syncData"] = True + if self.vlayers.get(f"{cleaned_form_str}_{geo_field}"): + self.vlayers[f"{cleaned_form_str}_{geo_field}"] = { + "syncData": True, + "vlayer": self.vlayers.get(f"{cleaned_form_str}_{geo_field}").get("vlayer") + } self.ona_worker = OnaRequestThread( url, @@ -3057,8 +3062,6 @@ def load_data_to_qgis(self, geojson_data, formID, geo_field): and self.vlayers.get(layer_name).get("syncData") and existing_layer ): - if self.vlayers.get(layer_name): - self.vlayers[layer_name] = {"syncData": True, "vlayer": vlayer} self.update_layer_data(layer_name, geojson_data, vlayer) elif ( not self.vlayers.get(layer_name)