Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/candidate url page blocking url lengths #885

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Generated by Django 4.2.9 on 2024-06-24 16:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("sde_collections", "0055_alter_workflowhistory_old_status_and_more"),
]

operations = [
migrations.AlterField(
model_name="candidateurl",
name="document_type",
field=models.IntegerField(
choices=[
(1, "Images"),
(2, "Data"),
(3, "Documentation"),
(4, "Software and Tools"),
(5, "Missions and Instruments"),
],
null=True,
),
),
migrations.AlterField(
model_name="collection",
name="document_type",
field=models.IntegerField(
choices=[
(1, "Images"),
(2, "Data"),
(3, "Documentation"),
(4, "Software and Tools"),
(5, "Missions and Instruments"),
],
default=3,
),
),
migrations.AlterField(
model_name="documenttypepattern",
name="document_type",
field=models.IntegerField(
choices=[
(1, "Images"),
(2, "Data"),
(3, "Documentation"),
(4, "Software and Tools"),
(5, "Missions and Instruments"),
]
),
),
]
1 change: 0 additions & 1 deletion sde_collections/models/collection_choice_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class DocumentTypes(models.IntegerChoices):
DOCUMENTATION = 3, "Documentation"
SOFTWARETOOLS = 4, "Software and Tools"
MISSIONSINSTRUMENTS = 5, "Missions and Instruments"
TRAININGANDEDUCATION = 6, "Training and Education"

@classmethod
def lookup_by_text(cls, text: str) -> int | None:
Expand Down
22 changes: 14 additions & 8 deletions sde_indexing_helper/static/css/candidate_url_list.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@
border-color: #fafafa;
font-size: 0.6875rem;
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); }

.select-dropdown:hover {
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);
}

.select-dropdown:focus,
.select-dropdown.focus {
box-shadow: none, 0 0 0 0.2rem rgba(76, 175, 80, 0.5);
Expand Down Expand Up @@ -194,7 +194,7 @@ letter-spacing: -0.02em;
display: flex;
align-items: baseline;
}

.checkbox-wrapper label {
font-weight: 600;
font-size: 16px;
Expand Down Expand Up @@ -228,7 +228,7 @@ letter-spacing: -0.02em;
width: 600px;
color: #65B1EF;
}

.title-dropdown {
width: fit-content !important;
margin-top:20px;
Expand All @@ -237,7 +237,7 @@ letter-spacing: -0.02em;
.table tbody tr:nth-child(odd) {
background-color: #050E19 !important;
}

.table tbody tr:nth-child(even) {
background-color: #3F4A58 !important;
}
Expand All @@ -247,7 +247,7 @@ letter-spacing: -0.02em;
}



.custom-select, .buttons-csv, .customizeColumns, .addPattern{
border-style: solid !important;
border-color: #A7BACD !important;
Expand Down Expand Up @@ -346,7 +346,7 @@ div.dt-buttons .btn.processing:after {
align-items: center;
/* justify-content: space-between; */
}

.headerDiv{
display: flex;
justify-content: space-between;
Expand All @@ -356,6 +356,12 @@ div.dt-buttons .btn.processing:after {
display:flex;
align-items: center;
justify-content: space-between;
word-wrap: break-word;
word-break: break-all;
white-space: normal;
overflow-wrap: break-word;
min-width: 500px;
max-width: 500px;
}

.url-icon {
Expand Down Expand Up @@ -415,4 +421,4 @@ div.dt-buttons .btn.processing:after {
div.dt-container div.dt-paging ul.pagination {
position: absolute;
right: 60px;
}
}
131 changes: 58 additions & 73 deletions sde_indexing_helper/static/js/candidate_url_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ function initializeDataTable() {
3: "Documentation",
4: "Software and Tools",
5: "Missions and Instruments",
6: "Training and Education",
};
this.api()
.columns()
Expand Down Expand Up @@ -604,7 +603,6 @@ function initializeDataTable() {
Documentation: 3,
"Software and Tools": 4,
"Missions and Instruments": 5,
"Training and Education": 6,
},
},
};
Expand Down Expand Up @@ -768,7 +766,6 @@ function getDocumentTypeColumn() {
3: "Documentation",
4: "Software and Tools",
5: "Missions and Instruments",
6: "Training and Education",
};
button_text = data ? dict[data] : "Select";
button_color = data ? "btn-success" : "btn-secondary";
Expand All @@ -786,7 +783,6 @@ function getDocumentTypeColumn() {
<a class="dropdown-item document_type_select" href="#" value="3">Documentation</a>
<a class="dropdown-item document_type_select" href="#" value="4">Software and Tools</a>
<a class="dropdown-item document_type_select" href="#" value="5">Missions and Instruments</a>
<a class="dropdown-item document_type_select" href="#" value="6">Training and Education</a>
</div>
</div>`;
},
Expand Down Expand Up @@ -997,16 +993,14 @@ function postDocumentTypePatterns(
success: function (data) {
$("#candidate_urls_table").DataTable().ajax.reload(null, false);
$("#document_type_patterns_table").DataTable().ajax.reload(null, false);
if (currentTab === "") {
//Only add a notification if we are on the first tab
newDocumentTypePatternsCount = newDocumentTypePatternsCount + 1;
$("#documentTypePatternsTab").html(
`Document Type Patterns <span class="pill notifyBadge badge badge-pill badge-primary">` +
newDocumentTypePatternsCount +
" new" +
`</span>`
);
}
if(currentTab === ""){ //Only add a notification if we are on the first tab
newDocumentTypePatternsCount = newDocumentTypePatternsCount + 1;
$("#documentTypePatternsTab").html(
`Document Type Patterns <span class="pill notifyBadge badge badge-pill badge-primary">` +
newDocumentTypePatternsCount + " new" +
`</span>`
);
}
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand Down Expand Up @@ -1050,16 +1044,14 @@ function postExcludePatterns(match_pattern, match_pattern_type = 0, force) {
success: function (data) {
$("#candidate_urls_table").DataTable().ajax.reload(null, false);
$("#exclude_patterns_table").DataTable().ajax.reload(null, false);
if (currentTab === "") {
//Only add a notification if we are on the first tab
newExcludePatternsCount = newExcludePatternsCount + 1;
$("#excludePatternsTab").html(
`Exclude Patterns <span class="pill notifyBadge badge badge-pill badge-primary">` +
newExcludePatternsCount +
" new" +
`</span>`
);
}
if(currentTab === ""){ //Only add a notification if we are on the first tab
newExcludePatternsCount = newExcludePatternsCount + 1;
$("#excludePatternsTab").html(
`Exclude Patterns <span class="pill notifyBadge badge badge-pill badge-primary">` +
newExcludePatternsCount + " new" +
`</span>`
);
}
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand Down Expand Up @@ -1094,16 +1086,14 @@ function postIncludePatterns(match_pattern, match_pattern_type = 0) {
success: function (data) {
$("#candidate_urls_table").DataTable().ajax.reload(null, false);
$("#include_patterns_table").DataTable().ajax.reload(null, false);
if (currentTab === "") {
//Only add a notification if we are on the first tab
newIncludePatternsCount = newIncludePatternsCount + 1;
$("#includePatternsTab").html(
`Include Patterns <span class="pill notifyBadge badge badge-pill badge-primary">` +
newIncludePatternsCount +
" new" +
`</span>`
);
}
if(currentTab === ""){ //Only add a notification if we are on the first tab
newIncludePatternsCount = newIncludePatternsCount + 1;
$("#includePatternsTab").html(
`Include Patterns <span class="pill notifyBadge badge badge-pill badge-primary">` +
newIncludePatternsCount + " new" +
`</span>`
);
}
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand All @@ -1122,45 +1112,40 @@ function postTitlePatterns(
return;
}

$.ajax({
url: "/api/title-patterns/",
type: "POST",
data: {
collection: collection_id,
match_pattern: match_pattern,
match_pattern_type: match_pattern_type,
title_pattern: title_pattern,
csrfmiddlewaretoken: csrftoken,
},
success: function (data) {
$("#candidate_urls_table").DataTable().ajax.reload(null, false);
$("#title_patterns_table").DataTable().ajax.reload(null, false);
if (currentTab === "") {
//Only add a notification if we are on the first tab
newTitlePatternsCount = newTitlePatternsCount + 1;
$("#titlePatternsTab").html(
`Title Patterns <span class="pill notifyBadge badge badge-pill badge-primary">` +
newTitlePatternsCount +
" new" +
`</span>`
);
}
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
if (
errorMessage ==
'{"error":{"non_field_errors":["The fields collection, match_pattern must make a unique set."]},"status_code":400}'
) {
toastr.success("Pattern already exists");
return;
}
var errorMessages = JSON.parse(errorMessage);
Object.entries(errorMessages.error).forEach(([key, value]) => {
toastr.error(value, key);
});
},
});
$.ajax({
url: '/api/title-patterns/',
type: "POST",
data: {
collection: collection_id,
match_pattern: match_pattern,
match_pattern_type: match_pattern_type,
title_pattern: title_pattern,
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#title_patterns_table').DataTable().ajax.reload(null, false);
if(currentTab === ""){ //Only add a notification if we are on the first tab
newTitlePatternsCount = newTitlePatternsCount + 1;
$("#titlePatternsTab").html(
`Title Patterns <span class="pill notifyBadge badge badge-pill badge-primary">` +
newTitlePatternsCount + " new" +
`</span>`
);
}
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
if (errorMessage == '{"error":{"non_field_errors":["The fields collection, match_pattern must make a unique set."]},"status_code":400}') {
toastr.success("Pattern already exists");
return;
}
var errorMessages = JSON.parse(errorMessage);
Object.entries(errorMessages.error).forEach(([key, value]) => {
toastr.error(value, key);
});
}
});
}

function postVisited(url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ <h3 class="whiteText candidateTitle">
<option value="3">Documentation</option>
<option value="4">Software and Tools</option>
<option value="5">Missions and Instruments</option>
<option value="6">Training and Education</option>
</select></td>
<td ></td>
<td ></td>
Expand Down Expand Up @@ -253,7 +252,6 @@ <h3 class="whiteText candidateTitle">
<option value="Documentation">Documentation</option>
<option value="Software and Tools">Software and Tools</option>
<option value="Missions and Instruments">Missions and Instruments</option>
<option value="Training and Education">Training and Education</option>
</select></td>
<td ></td>
<td ></td>
Expand Down Expand Up @@ -476,4 +474,4 @@ <h5 class="modal-title">Are you sure?</h5>



{% endblock content %}
{% endblock content %}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1 class="nameWrapper"><div class="collectionName" id="collectionName">{{ colle
data-match-pattern
remove_protocol
row
url>
url>
<button class="btn {{ collection.workflow_status_button_color }} btn-sm dropdown-toggle"
type="button"
id="workflow-status-button-{{ collection.id }}"
Expand Down Expand Up @@ -166,8 +166,6 @@ <h1 class="nameWrapper"><div class="collectionName" id="collectionName">{{ colle
Software and Tools</option>
<option value="5" {% if collection.document_type == 5 %} selected="selected" {% endif %}>
Missions and Instruments</option>
<option value="6" {% if collection.document_type == 6 %} selected="selected" {% endif %}>Training and Education
</option>
</select>

</td>
Expand Down Expand Up @@ -296,7 +294,7 @@ <h1 class="nameWrapper"><div class="collectionName" id="collectionName">{{ colle
id="workflow-history-button-{{ collection.id }}"
aria-expanded="false">{{ entry.get_workflow_status_display }}</button>
</td>
<td class="whiteText">
<td class="whiteText">
{{ entry.curated_by }}</td>
<td class="whiteText">{{entry.created_at|timesince}} ago</td>
</tr>
Expand Down Expand Up @@ -324,8 +322,8 @@ <h5 class="modal-title">Are you sure?</h5>
<div class="modal-footer">
<form id="divisionChangeModalForm">
<div class="button-wrapper">
<button type="submit" class="btn btn-secondary modal-button-1" id="cancelDivisionChange">No</button>
<button type="submit" class="btn btn-primary modal-button-2" data-dismiss="modal" id="makeDivisionChange">Yes</button>
<button type="submit" class="btn btn-secondary modal-button-1" id="cancelDivisionChange">No</button>
<button type="submit" class="btn btn-primary modal-button-2" data-dismiss="modal" id="makeDivisionChange">Yes</button>
</div>
</form>
</div>
Expand Down