Skip to content

Commit 1da0204

Browse files
authored
Merge pull request #456 from NASA-IMPACT/454-add-link-to-filtered-test-server-on-the-collection-detail-page
Add feature to view a collection on the test server
2 parents c6b324d + 78ec9ea commit 1da0204

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

sde_collections/models/collection.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import json
2+
import urllib.parse
3+
14
from django.contrib.auth import get_user_model
25
from django.db import models
36
from slugify import slugify
@@ -91,6 +94,20 @@ class Meta:
9194
verbose_name = "Collection"
9295
verbose_name_plural = "Collections"
9396

97+
@property
98+
def server_url_test(self) -> str:
99+
base_url = "https://sciencediscoveryengine.test.nasa.gov"
100+
payload = {
101+
"name": "query-smd-primary",
102+
"scope": "All",
103+
"text": "",
104+
"advanced": {
105+
"collection": f"/SMD/{self.config_folder}/",
106+
},
107+
}
108+
encoded_payload = urllib.parse.quote(json.dumps(payload))
109+
return f"{base_url}/app/nasa-sba-smd/#/search?query={encoded_payload}"
110+
94111
@property
95112
def curation_status_button_color(self) -> str:
96113
color_choices = {

sde_indexing_helper/templates/sde_collections/collection_detail.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@
99
{% endblock stylesheets %}
1010
{% block content %}
1111
<br>
12-
<h1>{{ collection.name }}</h1>
12+
<div class="row">
13+
<div class="col-md-6">
14+
15+
<h1>{{ collection.name }}</h1>
16+
</div>
17+
<div class="col-md-6">
18+
19+
<a href="{{ collection.server_url_test }}" target="_blank" style="color:white"><button class="btn btn-primary btn-sm pull-right">View on test server</button></a>
20+
</div>
21+
</div>
1322
<table class="table table-striped">
1423
<tbody>
1524
<tr>

0 commit comments

Comments
 (0)