Skip to content

Commit 46e0715

Browse files
Merge pull request #882 from NASA-IMPACT/dev-enhanced-merged
Recent changes to the dev-enhanced-merged branch
2 parents 02814cf + 97c76ac commit 46e0715

File tree

11 files changed

+184
-105
lines changed

11 files changed

+184
-105
lines changed

config/settings/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,7 @@
339339
SINEQUA_CONFIGS_REPO_DEV_BRANCH = env("SINEQUA_CONFIGS_REPO_DEV_BRANCH")
340340
SINEQUA_CONFIGS_REPO_WEBAPP_PR_BRANCH = env("SINEQUA_CONFIGS_REPO_WEBAPP_PR_BRANCH")
341341
SLACK_WEBHOOK_URL = env("SLACK_WEBHOOK_URL")
342+
XLI_USER = env("XLI_USER")
343+
XLI_PASSWORD = env("XLI_PASSWORD")
344+
LRM_USER = env("LRM_USER")
345+
LRM_PASSWORD = env("LRM_PASSWORD")
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Generated by Django 4.2.9 on 2024-06-24 16:31
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("sde_collections", "0055_alter_workflowhistory_old_status_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="candidateurl",
15+
name="document_type",
16+
field=models.IntegerField(
17+
choices=[
18+
(1, "Images"),
19+
(2, "Data"),
20+
(3, "Documentation"),
21+
(4, "Software and Tools"),
22+
(5, "Missions and Instruments"),
23+
],
24+
null=True,
25+
),
26+
),
27+
migrations.AlterField(
28+
model_name="collection",
29+
name="document_type",
30+
field=models.IntegerField(
31+
choices=[
32+
(1, "Images"),
33+
(2, "Data"),
34+
(3, "Documentation"),
35+
(4, "Software and Tools"),
36+
(5, "Missions and Instruments"),
37+
],
38+
default=3,
39+
),
40+
),
41+
migrations.AlterField(
42+
model_name="documenttypepattern",
43+
name="document_type",
44+
field=models.IntegerField(
45+
choices=[
46+
(1, "Images"),
47+
(2, "Data"),
48+
(3, "Documentation"),
49+
(4, "Software and Tools"),
50+
(5, "Missions and Instruments"),
51+
]
52+
),
53+
),
54+
]

sde_collections/models/collection_choice_fields.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class DocumentTypes(models.IntegerChoices):
3030
DOCUMENTATION = 3, "Documentation"
3131
SOFTWARETOOLS = 4, "Software and Tools"
3232
MISSIONSINSTRUMENTS = 5, "Missions and Instruments"
33-
TRAININGANDEDUCATION = 6, "Training and Education"
3433

3534
@classmethod
3635
def lookup_by_text(cls, text: str) -> int | None:

sde_collections/models/pattern.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
from django.apps import apps
44
from django.core.exceptions import ValidationError
5-
from django.db import models, transaction
6-
from django.db.models.signals import post_save
7-
from django.dispatch import receiver
8-
9-
from sde_collections.tasks import resolve_title_pattern
5+
from django.db import models
106

117
from ..utils.title_resolver import (
128
is_valid_fstring,
@@ -175,10 +171,8 @@ def apply(self) -> None:
175171
"title": candidate_url.scraped_title,
176172
"collection": self.collection.name,
177173
}
178-
179174
try:
180-
# generated_title = resolve_title(self.title_pattern, context)
181-
generated_title = self.title_pattern
175+
generated_title = resolve_title(self.title_pattern, context)
182176

183177
# check to see if the candidate url has an existing resolved title and delete it
184178
ResolvedTitle.objects.filter(candidate_url=candidate_url).delete()
@@ -190,6 +184,7 @@ def apply(self) -> None:
190184

191185
candidate_url.generated_title = generated_title
192186
candidate_url.save()
187+
updated_urls.append(candidate_url)
193188

194189
except (ValueError, ValidationError) as e:
195190
message = str(e)
@@ -210,7 +205,15 @@ def apply(self) -> None:
210205
TitlePatternCandidateURL.objects.bulk_create(pattern_url_associations, ignore_conflicts=True)
211206

212207
def unapply(self) -> None:
213-
self.candidate_urls.update(generated_title="")
208+
candidate_urls = self.candidate_urls.all()
209+
for candidate_url in candidate_urls:
210+
candidate_url.generated_title = ""
211+
candidate_url.save()
212+
self.candidate_urls.clear()
213+
214+
def delete(self, *args, **kwargs):
215+
self.unapply()
216+
super().delete(*args, **kwargs)
214217

215218
class Meta:
216219
"""Meta definition for TitlePattern."""

sde_collections/sinequa_api.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import requests
44
import urllib3
5+
from django.conf import settings
56

67
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
78

@@ -50,6 +51,10 @@ def __init__(self, server_name: str) -> None:
5051
self.app_name: str = server_configs[server_name]["app_name"]
5152
self.query_name: str = server_configs[server_name]["query_name"]
5253
self.base_url: str = server_configs[server_name]["base_url"]
54+
self.xli_user = settings.XLI_USER
55+
self.xli_password = settings.XLI_PASSWORD
56+
self.lrm_user = settings.LRM_USER
57+
self.lrm_password = settings.LRM_PASSWORD
5358

5459
def process_response(self, url: str, payload: dict[str, Any]) -> Any:
5560
response = requests.post(url, headers={}, json=payload, verify=False)
@@ -63,9 +68,9 @@ def process_response(self, url: str, payload: dict[str, Any]) -> Any:
6368

6469
def query(self, page: int, collection_config_folder: str = "") -> Any:
6570
if self.server_name == "lis_server":
66-
url = f"{self.base_url}/api/v1/search.query?Password=admin&User=admin"
71+
url = f"{self.base_url}/api/v1/search.query?Password={self.xli_password}&User={self.xli_user}"
6772
elif self.server_name == "lrm_dev_server":
68-
url = f"{self.base_url}/api/v1/search.query?Password=QDZ8ASZagUpRCHR&User=lrmdev"
73+
url = f"{self.base_url}/api/v1/search.query?Password={self.lrm_password}&User={self.lrm_user}"
6974
else:
7075
url = f"{self.base_url}/api/v1/search.query"
7176
payload = {

sde_collections/tasks.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from config import celery_app
1212

13-
from .models.collection import Collection
13+
from .models.collection import Collection, WorkflowStatusChoices
1414
from .sinequa_api import Api
1515
from .utils.github_helper import GitHubHandler
1616

@@ -90,6 +90,14 @@ def import_candidate_urls_from_api(server_name="test", collection_ids=[]):
9090
print("Applying existing patterns; this may take a while")
9191
collection.apply_all_patterns()
9292

93+
if collection.workflow_status == WorkflowStatusChoices.READY_FOR_ENGINEERING:
94+
collection.workflow_status = WorkflowStatusChoices.ENGINEERING_IN_PROGRESS
95+
collection.save()
96+
97+
# Finally set the status to READY_FOR_CURATION
98+
collection.workflow_status = WorkflowStatusChoices.READY_FOR_CURATION
99+
collection.save()
100+
93101
print("Deleting temp files")
94102
shutil.rmtree(TEMP_FOLDER_NAME)
95103

sde_indexing_helper/static/css/candidate_url_list.css

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@
9090
border-color: #fafafa;
9191
font-size: 0.6875rem;
9292
box-shadow: 0 2px 2px 0 rgba(153, 153, 153, 0.14), 0 3px 1px -2px rgba(153, 153, 153, 0.2), 0 1px 5px 0 rgba(153, 153, 153, 0.12); }
93-
93+
9494
.select-dropdown:hover {
9595
box-shadow: 0 14px 26px -12px rgba(250, 250, 250, 0.42), 0 4px 23px 0px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(250, 250, 250, 0.2);
9696
}
97-
97+
9898
.select-dropdown:focus,
9999
.select-dropdown.focus {
100100
box-shadow: none, 0 0 0 0.2rem rgba(76, 175, 80, 0.5);
@@ -194,7 +194,7 @@ letter-spacing: -0.02em;
194194
display: flex;
195195
align-items: baseline;
196196
}
197-
197+
198198
.checkbox-wrapper label {
199199
font-weight: 600;
200200
font-size: 16px;
@@ -228,7 +228,7 @@ letter-spacing: -0.02em;
228228
width: 600px;
229229
color: #65B1EF;
230230
}
231-
231+
232232
.title-dropdown {
233233
width: fit-content !important;
234234
margin-top:20px;
@@ -237,7 +237,7 @@ letter-spacing: -0.02em;
237237
.table tbody tr:nth-child(odd) {
238238
background-color: #050E19 !important;
239239
}
240-
240+
241241
.table tbody tr:nth-child(even) {
242242
background-color: #3F4A58 !important;
243243
}
@@ -247,7 +247,7 @@ letter-spacing: -0.02em;
247247
}
248248

249249

250-
250+
251251
.custom-select, .buttons-csv, .customizeColumns, .addPattern{
252252
border-style: solid !important;
253253
border-color: #A7BACD !important;
@@ -346,7 +346,7 @@ div.dt-buttons .btn.processing:after {
346346
align-items: center;
347347
/* justify-content: space-between; */
348348
}
349-
349+
350350
.headerDiv{
351351
display: flex;
352352
justify-content: space-between;
@@ -356,6 +356,12 @@ div.dt-buttons .btn.processing:after {
356356
display:flex;
357357
align-items: center;
358358
justify-content: space-between;
359+
word-wrap: break-word;
360+
word-break: break-all;
361+
white-space: normal;
362+
overflow-wrap: break-word;
363+
min-width: 100%;
364+
max-width: 100%;
359365
}
360366

361367
.url-icon {
@@ -415,4 +421,10 @@ div.dt-buttons .btn.processing:after {
415421
div.dt-container div.dt-paging ul.pagination {
416422
position: absolute;
417423
right: 60px;
418-
}
424+
}
425+
426+
.individual_title_input {
427+
width: 100%;
428+
max-width: 100%;
429+
min-width: 100%;
430+
}

0 commit comments

Comments
 (0)