Skip to content

Commit bb222c0

Browse files
authored
Merge branch 'dev' into 1182-ml-classification-queue
2 parents a646e32 + bfa1aa3 commit bb222c0

File tree

12 files changed

+130
-57
lines changed

12 files changed

+130
-57
lines changed

CHANGELOG.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ For each PR made, an entry should be added to this changelog. It should contain
1212
- etc.
1313

1414
## Changelog
15-
- 1182-ml-classification-queue
15+
16+
- 1209-bug-fix-document-type-creator-form
17+
- Description: The dropdown on the pattern creation form needs to be set as multi as the default option since this is why the doc type creator form is used for the majority of multi-URL pattern creations. This should be applied to doc types, division types, and titles as well.
1618
- Changes:
17-
- a new env value has been created called `INFERENCE_API_URL`
19+
- Set the default value for `match_pattern_type` in `BaseMatchPattern` class is set to `2`
20+
- Changed `test_create_simple_exclude_pattern` test within `TestDeltaExcludePatternBasics`
21+
- Changed `test_create_division_pattern` and `test_create_document_type_pattern_single` within `TestFieldModifierPatternBasics`
1822

1923
- 1052-update-cosmos-to-create-jobs-for-scrapers-and-indexers
2024
- Description: The original automation set up to generate the scrapers and indexers automatically based on a collection workflow status change needed to be updated to more accurately reflect the curation workflow. It would also be good to generate the jobs during this process to streamline the same.
@@ -104,3 +108,32 @@ For each PR made, an entry should be added to this changelog. It should contain
104108
- Added universal search functionality tests
105109
- Created search pane filter tests
106110
- Added pattern application form tests with validation checks
111+
112+
- 1101-bug-fix-quotes-not-escaped-in-titles
113+
- Description: Title rules that include single quotes show up correctly in the sinequa frontend (and the COSMOS api) but not in the delta urls page.
114+
- Changes:
115+
- Added `escapeHtml` function in the `delta_url_list.js` file to handle special character escaping correctly.
116+
- Called this function while retrieving the titles in `getGeneratedTitleColumn()` and `getCuratedGeneratedTitleColumn()` functions.
117+
118+
- 1240-fix-code-scanning-alert-inclusion-of-functionality-from-an-untrusted-source
119+
- Description: Ensured all external resources load securely by switching to HTTPS and adding Subresource Integrity (SRI) checks.
120+
- Changes:
121+
- Replaced protocol‑relative URLs with HTTPS.
122+
- Added SRI (integrity) and crossorigin attributes to external script tags.
123+
124+
- 1196-arrange-the-show-100-csv-customize-columns-boxes-to-be-in-one-line-on-the-delta-urls-page
125+
changelog-update-Issue-1001
126+
- Description: Formatting the buttons - 'Show 100','CSV' and 'Customize Columns' to be on a single line for an optimal use of space.
127+
- Changes:
128+
- Updated delta_url_list.css and delta_url_list.js files with necessary modifications
129+
130+
- 1246-minor-enhancement-document-type-pattern-form-require-document-type-or-show-appropriate-error
131+
- Description: In the Document Type Pattern Form, if the user does not select a Document Type while filling out the form, an appropriate error message is displayed.
132+
- Changes:
133+
- Added a JavaScript validation check on form submission to ensure the document type (stored in a hidden input) is not empty.
134+
- Display an error message and prevent form submission if the field is empty.
135+
136+
- 1249-add-https-link-to-cors_allowed_origins-for-sde-lrm
137+
- Description: The feedback form API was throwing CORS errors and to rectify that, we need to add the apt https link for sde-lrm.
138+
- Changes:
139+
- Added `https://sde-lrm.nasa-impact.net` to `CORS_ALLOWED_ORIGINS` in the base settings.

config/settings/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
CORS_ALLOWED_ORIGINS = [
9494
"http://localhost:3000",
9595
"http://sde-lrm.nasa-impact.net",
96+
"https://sde-lrm.nasa-impact.net",
9697
"https://sde-qa.nasa-impact.net",
9798
"https://sciencediscoveryengine.test.nasa.gov",
9899
"https://sciencediscoveryengine.nasa.gov",

sde_collections/models/delta_patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MatchPatternTypeChoices(models.IntegerChoices):
3030
match_pattern = models.CharField(
3131
"Pattern", help_text="This pattern is compared against the URL of all documents in the collection"
3232
)
33-
match_pattern_type = models.IntegerField(choices=MatchPatternTypeChoices.choices, default=1)
33+
match_pattern_type = models.IntegerField(choices=MatchPatternTypeChoices.choices, default=2)
3434
delta_urls = models.ManyToManyField(
3535
"DeltaUrl",
3636
related_name="%(class)ss", # Makes delta_url.deltaincludepatterns.all()

sde_collections/tests/test_exclude_patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_create_simple_exclude_pattern(self):
5656
pattern = DeltaExcludePattern.objects.create(
5757
collection=self.collection, match_pattern="https://example.com/exclude-me", reason="Test exclusion"
5858
)
59-
assert pattern.match_pattern_type == DeltaExcludePattern.MatchPatternTypeChoices.INDIVIDUAL_URL
59+
assert pattern.match_pattern_type == DeltaExcludePattern.MatchPatternTypeChoices.MULTI_URL_PATTERN
6060

6161
def test_exclude_single_curated_url(self):
6262
"""Test excluding a single curated URL creates appropriate delta."""

sde_collections/tests/test_field_modifier_patterns.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def test_create_document_type_pattern_single(self):
4747
collection=self.collection,
4848
match_pattern="https://example.com/docs/guide.pdf",
4949
document_type=DocumentTypes.DOCUMENTATION,
50+
match_pattern_type=DeltaDocumentTypePattern.MatchPatternTypeChoices.INDIVIDUAL_URL,
5051
)
5152
assert pattern.match_pattern_type == DeltaDocumentTypePattern.MatchPatternTypeChoices.INDIVIDUAL_URL
5253
assert pattern.document_type == DocumentTypes.DOCUMENTATION
@@ -68,6 +69,7 @@ def test_create_division_pattern(self):
6869
collection=self.collection,
6970
match_pattern="https://example.com/helio/data.html",
7071
division=Divisions.HELIOPHYSICS,
72+
match_pattern_type=DeltaDivisionPattern.MatchPatternTypeChoices.INDIVIDUAL_URL,
7173
)
7274
assert pattern.match_pattern_type == DeltaDivisionPattern.MatchPatternTypeChoices.INDIVIDUAL_URL
7375
assert pattern.division == Divisions.HELIOPHYSICS

sde_indexing_helper/static/css/delta_url_list.css

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@
211211
}
212212

213213
.modalFooter {
214-
position: sticky;
215-
bottom: 0;
216214
position: sticky;
217215
bottom: 0;
218216
padding: 10px 0;
@@ -255,8 +253,6 @@
255253
font-weight: 500;
256254
}
257255

258-
259-
260256
.custom-select,
261257
.buttons-csv,
262258
.customizeColumns,
@@ -440,7 +436,6 @@ div.dt-buttons .btn.processing:after {
440436
}
441437

442438

443-
/* pagination position */
444439
div.dt-container div.dt-paging ul.pagination {
445440
position: absolute;
446441
right: 60px;
@@ -451,3 +446,31 @@ div.dt-container div.dt-paging ul.pagination {
451446
max-width: 100%;
452447
min-width: 100%;
453448
}
449+
450+
#delta_urls_table_wrapper .col-md {
451+
display: flex;
452+
justify-content: space-between;
453+
align-items: center;
454+
grid-auto-flow: row;
455+
position: relative;
456+
457+
.dt-info {
458+
position:absolute;
459+
left: 130px;
460+
top: 5px;
461+
}
462+
}
463+
464+
#curated_urls_table_wrapper .col-md {
465+
display: flex;
466+
justify-content: space-between;
467+
align-items: center;
468+
grid-auto-flow: row;
469+
position: relative;
470+
471+
.dt-info {
472+
position:absolute;
473+
left: 130px;
474+
top: 5px;
475+
}
476+
}

sde_indexing_helper/static/js/delta_url_list.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@ function initializeDataTable() {
114114
layout: {
115115
bottomEnd: "inputPaging",
116116
topEnd: null,
117-
topStart: {
118-
info: true,
117+
topStart: null,
118+
top: {
119119
pageLength: {
120120
menu: [
121121
[25, 50, 100, 500],
122122
["Show 25", "Show 50", "Show 100", "Show 500"],
123123
],
124124
},
125+
info:true,
125126
buttons: [
126127
{
127128
extend: "csv",
@@ -332,14 +333,15 @@ function initializeDataTable() {
332333
layout: {
333334
bottomEnd: "inputPaging",
334335
topEnd: null,
335-
topStart: {
336-
info: true,
336+
topStart: null,
337+
top: {
337338
pageLength: {
338339
menu: [
339340
[25, 50, 100, 500],
340341
["Show 25", "Show 50", "Show 100", "Show 500"],
341342
],
342343
},
344+
info:true,
343345
buttons: [
344346
{
345347
extend: "csv",
@@ -1208,12 +1210,22 @@ function getCuratedScrapedTitleColumn() {
12081210
};
12091211
}
12101212

1213+
function escapeHtml(str) {
1214+
if (!str) return '';
1215+
return str
1216+
.replace(/&/g, '&')
1217+
.replace(/</g, '&lt;')
1218+
.replace(/>/g, '&gt;')
1219+
.replace(/"/g, '&quot;')
1220+
.replace(/'/g, '&#39;');
1221+
}
1222+
12111223
function getGeneratedTitleColumn() {
12121224
return {
12131225
data: "generated_title",
12141226
width: "20%",
12151227
render: function (data, type, row) {
1216-
return `<input type="text" class="form-control individual_title_input whiteText" value='${data}' data-generated-title-id=${row["generated_title_id"]
1228+
return `<input type="text" class="form-control individual_title_input whiteText" value="${escapeHtml(data)}" data-generated-title-id=${row["generated_title_id"]
12171229
} data-match-pattern-type=${row["match_pattern_type"]
12181230
} data-delta-urls-count=${row["delta_urls_count"]
12191231
} data-url=${remove_protocol(row["url"])} />`;
@@ -1226,7 +1238,7 @@ function getCuratedGeneratedTitleColumn() {
12261238
data: "generated_title",
12271239
width: "20%",
12281240
render: function (data, type, row) {
1229-
return `<input type="text" class="form-control individual_title_input whiteText" value='${data}' data-generated-title-id=${row["generated_title_id"]
1241+
return `<input type="text" class="form-control individual_title_input whiteText" value="${escapeHtml(data)}" data-generated-title-id=${row["generated_title_id"]
12301242
} data-match-pattern-type=${row["match_pattern_type"]
12311243
} data-curated-urls-count=${row["curated_urls_count"]
12321244
} data-url=${remove_protocol(row["url"])} />`;
@@ -2065,6 +2077,12 @@ $("#document_type_pattern_form").on("submit", function (e) {
20652077
inputs[field.name] = field.value;
20662078
});
20672079

2080+
// Validate that the document_type_pattern field is not empty
2081+
if (!inputs.document_type_pattern) {
2082+
toastr.error("Please select a Document Type");
2083+
return; // Prevent form submission
2084+
}
2085+
20682086
postDocumentTypePatterns(
20692087
inputs.match_pattern,
20702088
inputs.match_pattern_type,

sde_indexing_helper/templates/includes/scripts.html

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,14 @@
3838
<script src="{% static 'js/plugins/nouislider.min.js' %}"
3939
type="text/javascript"></script>
4040
<!-- Include a polyfill for ES6 Promises (optional) for IE11, UC Browser and Android browser support SweetAlert -->
41-
<script src="//cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"
42-
type="text/javascript"></script>
43-
<script src="//cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"
44-
type="text/javascript"></script>
45-
<script src="//unpkg.com/[email protected]"
46-
integrity="sha384-KReoNuwj58fe4zgWyjj5a1HrvXYPBeV0a3bNPVjK7n5FdsGC41fHRx6sq5tONeP0"
47-
crossorigin="anonymous"
48-
type="text/javascript"></script>
49-
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"
50-
integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw=="
51-
crossorigin="anonymous"
52-
referrerpolicy="no-referrer"></script>
41+
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"
42+
type="text/javascript" integrity="sha384-Ltf3zlo018jgSFarBV4ZXF8GxwymfafIj3qWz3rrjhL8hTVd2XzglHH+BCuIKnbk" crossorigin="anonymous"></script>
43+
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"
44+
type="text/javascript" integrity="sha384-eITc5AorI6xzkW7XunGaNrcA0l6qrU/kA/mOhLQOC5thAzlHSClQTOecyzGK6QXK" crossorigin="anonymous"></script>
45+
<script src="https://unpkg.com/[email protected]"
46+
type="text/javascript" integrity="sha384-KReoNuwj58fe4zgWyjj5a1HrvXYPBeV0a3bNPVjK7n5FdsGC41fHRx6sq5tONeP0" crossorigin="anonymous"></script>
47+
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"
48+
type="text/javascript" integrity="sha384-Si3HKTyQYGU+NC4aAF3ThcOSvK+ZQiyEKlYyfjiIFKMqsnCmfHjGa1VK1kYP9UdS" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
5349
<!-- Library for adding dinamically elements -->
5450
<script src="{% static 'js/plugins/arrive.min.js' %}" type="text/javascript"></script>
5551
<!-- Chartist JS -->

sde_indexing_helper/templates/sde_collections/collection_detail.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
{% block stylesheets %}
99
{{ block.super }}
1010
<link rel="stylesheet" href="{% static 'css/collection_detail.css' %}">
11-
<link href="//cdn.datatables.net/v/bs4/jszip-3.10.1/dt-2.0.5/af-2.7.0/b-3.0.2/b-colvis-3.0.2/b-html5-3.0.2/b-print-3.0.2/cr-2.0.1/fc-5.0.0/fh-4.0.1/kt-2.12.0/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.1/sp-2.3.1/sl-2.0.1/datatables.min.css" rel="stylesheet">
11+
<link href="https://cdn.datatables.net/v/bs4/jszip-3.10.1/dt-2.0.5/af-2.7.0/b-3.0.2/b-colvis-3.0.2/b-html5-3.0.2/b-print-3.0.2/cr-2.0.1/fc-5.0.0/fh-4.0.1/kt-2.12.0/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.1/sp-2.3.1/sl-2.0.1/datatables.min.css" rel="stylesheet">
1212
{% endblock stylesheets %}
1313
{% block javascripts %}
1414
{{ block.super }}
15-
<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
16-
<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
17-
<script src="//cdn.datatables.net/v/bs4/jszip-3.10.1/dt-2.0.5/af-2.7.0/b-3.0.2/b-colvis-3.0.2/b-html5-3.0.2/b-print-3.0.2/cr-2.0.1/fc-5.0.0/fh-4.0.1/kt-2.12.0/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.1/sp-2.3.1/sl-2.0.1/datatables.min.js"></script>
18-
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js"></script>
19-
<script src="https://cdn.datatables.net/plug-ins/2.0.8/features/inputPaging/dist/dataTables.inputPaging.min.js"></script>
15+
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js" integrity="sha384-VFQrHzqBh5qiJIU0uGU5CIW3+OWpdGGJM9LBnGbuIH2mkICcFZ7lPd/AAtI7SNf7" crossorigin="anonymous"></script>
16+
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js" integrity="sha384-/RlQG9uf0M2vcTw3CX7fbqgbj/h8wKxw7C3zu9/GxcBPRKOEcESxaxufwRXqzq6n" crossorigin="anonymous"></script>
17+
<script src="https://cdn.datatables.net/v/bs4/jszip-3.10.1/dt-2.0.5/af-2.7.0/b-3.0.2/b-colvis-3.0.2/b-html5-3.0.2/b-print-3.0.2/cr-2.0.1/fc-5.0.0/fh-4.0.1/kt-2.12.0/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.1/sp-2.3.1/sl-2.0.1/datatables.min.js" integrity="sha384-hYG8UYaiy9eSRy58/jaXhT3suoM1QfgYThNxzYEE1y+ijcFXuwMaNt1zr1ERbrIM" crossorigin="anonymous"></script>
18+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js" integrity="sha384-Ct2s0NBxEbvJlnXHOZJheqOGKjX3Q4ewsYoJZYnLz/teMXnlGhim5o9305EkvlsN" crossorigin="anonymous"></script>
19+
<script src="https://cdn.datatables.net/plug-ins/2.0.8/features/inputPaging/dist/dataTables.inputPaging.min.js" integrity="sha384-mKZ8fubNsDhTYk1d7pc3PkY4PtNykywmSWAs9uCX02tybo9mFN0D842g4XkshSF/" crossorigin="anonymous"></script>
2020
<script src="{% static 'js/collection_detail.js' %}"></script>
2121
<script src="{% static 'js/core/bootstrap.min.js' %}"></script>
2222
{% endblock javascripts %}

sde_indexing_helper/templates/sde_collections/collection_list.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% block stylesheets %}
66
{% load humanize %}
77
{{ block.super }}
8-
<link href="//cdn.datatables.net/v/bs4/jszip-3.10.1/dt-2.0.5/af-2.7.0/b-3.0.2/b-colvis-3.0.2/b-html5-3.0.2/b-print-3.0.2/cr-2.0.1/fc-5.0.0/fh-4.0.1/kt-2.12.0/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.1/sp-2.3.1/sl-2.0.1/datatables.min.css" rel="stylesheet">
8+
<link href="https://cdn.datatables.net/v/bs4/jszip-3.10.1/dt-2.0.5/af-2.7.0/b-3.0.2/b-colvis-3.0.2/b-html5-3.0.2/b-print-3.0.2/cr-2.0.1/fc-5.0.0/fh-4.0.1/kt-2.12.0/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.1/sp-2.3.1/sl-2.0.1/datatables.min.css" rel="stylesheet">
99
<link rel="stylesheet" href="{% static 'css/collections_list.css' %}">
1010
{% endblock stylesheets %}
1111
{% block content %}
@@ -278,9 +278,9 @@ <h5 class="modalTitle whiteText" id="hideShowColumnsModalTitle">Customize Column
278278
</div>
279279
{% endblock content %}
280280
{% block javascripts %}
281-
<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
282-
<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
283-
<script src="//cdn.datatables.net/v/bs4/jszip-3.10.1/dt-2.0.5/af-2.7.0/b-3.0.2/b-colvis-3.0.2/b-html5-3.0.2/b-print-3.0.2/cr-2.0.1/fc-5.0.0/fh-4.0.1/kt-2.12.0/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.1/sp-2.3.1/sl-2.0.1/datatables.min.js"></script>
281+
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js" integrity="sha384-VFQrHzqBh5qiJIU0uGU5CIW3+OWpdGGJM9LBnGbuIH2mkICcFZ7lPd/AAtI7SNf7" crossorigin="anonymous"></script>
282+
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js" integrity="sha384-/RlQG9uf0M2vcTw3CX7fbqgbj/h8wKxw7C3zu9/GxcBPRKOEcESxaxufwRXqzq6n" crossorigin="anonymous"></script>
283+
<script src="https://cdn.datatables.net/v/bs4/jszip-3.10.1/dt-2.0.5/af-2.7.0/b-3.0.2/b-colvis-3.0.2/b-html5-3.0.2/b-print-3.0.2/cr-2.0.1/fc-5.0.0/fh-4.0.1/kt-2.12.0/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.1/sp-2.3.1/sl-2.0.1/datatables.min.js" integrity="sha384-hYG8UYaiy9eSRy58/jaXhT3suoM1QfgYThNxzYEE1y+ijcFXuwMaNt1zr1ERbrIM" crossorigin="anonymous"></script>
284284
<script src="{% static 'js/collection_list.js' %}"></script>
285285
<script src="{% static 'js/project.js' %}"></script>
286286
{% endblock javascripts %}

0 commit comments

Comments
 (0)