Skip to content

Commit

Permalink
Merge pull request #635 from NASA-IMPACT/634-webapp-modification-to-a…
Browse files Browse the repository at this point in the history
…ccess-lrm-dev-for-curated-urls

634 webapp modification to access lrm dev for curated urls
  • Loading branch information
bishwaspraveen authored Feb 27, 2024
2 parents 2821691 + e1efe74 commit 76abc6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions sde_collections/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def import_candidate_urls_lis_server(modeladmin, request, queryset):
import_candidate_urls_from_api_caller(modeladmin, request, queryset, "lis_server")


@admin.action(description="Import candidate URLs from LRM Dev Server")
def import_candidate_urls_lrm_dev_server(modeladmin, request, queryset):
import_candidate_urls_from_api_caller(modeladmin, request, queryset, "lrm_dev_server")


class ExportCsvMixin:
def export_as_csv(self, request, queryset):
meta = self.model._meta
Expand Down Expand Up @@ -198,6 +203,7 @@ class CollectionAdmin(admin.ModelAdmin, ExportCsvMixin, UpdateConfigMixin):
import_candidate_urls_secret_test,
import_candidate_urls_secret_production,
import_candidate_urls_lis_server,
import_candidate_urls_lrm_dev_server,
]
ordering = ("cleaning_order",)

Expand Down
11 changes: 8 additions & 3 deletions sde_collections/sinequa_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"query_name": "query-smd-primary",
"base_url": "http://sde-xli.nasa-impact.net",
},
"lrm_dev_server": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "http://sde-lrm.nasa-impact.net",
},
}


Expand All @@ -59,6 +64,8 @@ def process_response(self, url: str, payload: dict[str, Any]) -> Any:
def query(self, page: int, collection_config_folder: str = "") -> Any:
if self.server_name == "lis_server":
url = f"{self.base_url}/api/v1/search.query?Password=admin&User=admin"
elif self.server_name == "lrm_dev_server":
url = f"{self.base_url}/api/v1/search.query?Password=QDZ8ASZagUpRCHR&User=lrmdev"
else:
url = f"{self.base_url}/api/v1/search.query"
payload = {
Expand All @@ -73,9 +80,7 @@ def query(self, page: int, collection_config_folder: str = "") -> Any:
}

if collection_config_folder:
payload["query"]["advanced"][
"collection"
] = f"/SDE/{collection_config_folder}/"
payload["query"]["advanced"]["collection"] = f"/SDE/{collection_config_folder}/"

response = self.process_response(url, payload)

Expand Down

0 comments on commit 76abc6d

Please sign in to comment.