Skip to content

Commit

Permalink
Merge pull request #456 from NASA-IMPACT/454-add-link-to-filtered-tes…
Browse files Browse the repository at this point in the history
…t-server-on-the-collection-detail-page

Add feature to view a collection on the test server
  • Loading branch information
code-geek authored Oct 17, 2023
2 parents c6b324d + 78ec9ea commit 1da0204
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
17 changes: 17 additions & 0 deletions sde_collections/models/collection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json
import urllib.parse

from django.contrib.auth import get_user_model
from django.db import models
from slugify import slugify
Expand Down Expand Up @@ -91,6 +94,20 @@ class Meta:
verbose_name = "Collection"
verbose_name_plural = "Collections"

@property
def server_url_test(self) -> str:
base_url = "https://sciencediscoveryengine.test.nasa.gov"
payload = {
"name": "query-smd-primary",
"scope": "All",
"text": "",
"advanced": {
"collection": f"/SMD/{self.config_folder}/",
},
}
encoded_payload = urllib.parse.quote(json.dumps(payload))
return f"{base_url}/app/nasa-sba-smd/#/search?query={encoded_payload}"

@property
def curation_status_button_color(self) -> str:
color_choices = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
{% endblock stylesheets %}
{% block content %}
<br>
<h1>{{ collection.name }}</h1>
<div class="row">
<div class="col-md-6">

<h1>{{ collection.name }}</h1>
</div>
<div class="col-md-6">

<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>
</div>
</div>
<table class="table table-striped">
<tbody>
<tr>
Expand Down

0 comments on commit 1da0204

Please sign in to comment.