Skip to content

Commit 475ab56

Browse files
authored
Merge branch 'master' into manual-validator-workflow
2 parents 0510e0d + dd08222 commit 475ab56

File tree

18 files changed

+248
-25
lines changed

18 files changed

+248
-25
lines changed

.github/bors.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ status = [
22
"linting",
33
"build-frontend",
44
"build-docs",
5+
"build-docker",
56
"test-windows",
67
"test-linux (sqlite)",
78
"test-linux (mariadb)",

.github/workflows/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ jobs:
142142
cd ESSArch_Core/docs
143143
make html SPHINXOPTS="-W"
144144
145+
build-docker:
146+
runs-on: ubuntu-latest
147+
steps:
148+
- uses: actions/checkout@v1
149+
150+
- name: Build
151+
run: |
152+
cd docker
153+
docker-compose build essarch
154+
145155
test-windows:
146156
runs-on: windows-latest
147157
env:

ESSArch_Core/config/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
# Set test runner
39-
TEST_RUNNER = "ESSArch_Core.testing.runner.QuietTestRunner"
39+
TEST_RUNNER = "ESSArch_Core.testing.runner.ESSArchTestRunner"
4040

4141
ALLOWED_HOSTS = ['*']
4242

ESSArch_Core/db/__init__.py

Whitespace-only changes.

ESSArch_Core/db/utils.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from django.db.models import Case, CharField, F, IntegerField, Value, When
2+
from django.db.models.functions import Cast, Length, StrIndex, Substr, Trim
3+
4+
5+
def natural_sort(qs, field):
6+
return qs.annotate(
7+
ns_len=Length(field),
8+
ns_split_index=StrIndex(field, Value(' ')),
9+
ns_suffix=Trim(Substr(field, F('ns_split_index'), output_field=CharField())),
10+
).annotate(
11+
ns_code=Trim(Substr(field, Value(1), 'ns_split_index', output_field=CharField())),
12+
ns_weight=Case(
13+
When(ns_split_index=0, then=Value(0)),
14+
default=Case(
15+
When(
16+
ns_suffix__regex=r'^\d+$',
17+
then=Cast(
18+
Substr(field, F('ns_split_index'), output_field=CharField()),
19+
output_field=IntegerField(),
20+
)
21+
),
22+
default=Value(1230),
23+
output_field=IntegerField()
24+
),
25+
output_field=IntegerField(),
26+
)
27+
).order_by('ns_code', 'ns_weight', 'ns_len', field)

ESSArch_Core/docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
# The short X.Y version.
120120
version = get_versions()['version']
121121
# The full version, including alpha/beta/rc tags.
122-
release = get_versions()['full-revisionid']
122+
release = get_versions()['full-revisionid'] or ''
123123

124124
# The language for content autogenerated by Sphinx. Refer to documentation
125125
# for a list of supported languages.

ESSArch_Core/frontend/static/frontend/scripts/controllers/SearchDetailCtrl.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,20 @@ export default class SearchDetailCtrl {
237237
vm.getClassificationStructureChildren = function(id) {
238238
console.log('Getting children of structure with id "' + id + '"');
239239
const url = vm.url + 'structures/' + id + '/units/';
240-
return $http.get(url, {params: {has_parent: false, pager: 'none'}}).then(function(response) {
241-
const data = response.data.map(function(unit) {
242-
unit._id = unit.id;
243-
unit._is_structure_unit = true;
244-
delete unit.parent;
245-
return vm.createNode(unit);
240+
return $http
241+
.get(url, {params: {has_parent: false, ordering: 'reference_code', pager: 'none'}})
242+
.then(function(response) {
243+
const data = response.data.map(function(unit) {
244+
unit._id = unit.id;
245+
unit._is_structure_unit = true;
246+
delete unit.parent;
247+
return vm.createNode(unit);
248+
});
249+
return {
250+
data: data,
251+
count: response.headers('Count'),
252+
};
246253
});
247-
return {
248-
data: data,
249-
count: response.headers('Count'),
250-
};
251-
});
252254
};
253255

254256
vm.createPlaceholderNode = function() {

ESSArch_Core/frontend/static/frontend/views/administration_media_information.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ <h4>
4545
<table class="table table-striped" style="margin-bottom: 0px;">
4646
<thead>
4747
<tr>
48-
<th class="clickable" st-sort="medium_id" class="column-label">ID</th>
48+
<th class="clickable" st-sort="medium_id" st-sort-default="true" class="column-label">ID</th>
4949
<th class="clickable" st-sort="storage_target" class="column-label">{{'STORAGETARGET' | translate}}</th>
50-
<th class="clickable" st-sort="create_date" st-sort-default="reverse" class="column-label">
50+
<th class="clickable" st-sort="create_date" class="column-label">
5151
{{'CREATED' | translate}}
5252
</th>
5353
<th class="clickable" st-sort="status" class="column-label">{{'STATUS' | translate}}</th>
5454
<th class="clickable" st-sort="location" class="column-label">{{'LOCATION' | translate}}</th>
5555
<th class="clickable" st-sort="location_status" class="column-label">{{'LOCATIONSTATUS' | translate}}</th>
5656
<th class="clickable" st-sort="used_capacity" class="column-label">{{'USEDCAPACITY' | translate}}</th>
57-
<th class="clickable" st-sort="storage_target.max_capacity" class="column-label">
57+
<th class="clickable" st-sort="max_capacity" class="column-label">
5858
{{'MAXCAPACITY' | translate}}
5959
</th>
6060
</tr>

ESSArch_Core/storage/filters.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"""
2424

2525
from django_filters import rest_framework as filters
26+
from django_filters.constants import EMPTY_VALUES
2627

2728
from ESSArch_Core.api.filters import CharSuffixRangeFilter, ListFilter
2829
from ESSArch_Core.configuration.models import StoragePolicy
@@ -36,6 +37,16 @@
3637
)
3738

3839

40+
class StorageMediumOrderingFilter(filters.OrderingFilter):
41+
def filter(self, qs, value):
42+
if value in EMPTY_VALUES or 'medium_id' in value:
43+
return qs.natural_sort()
44+
elif '-medium_id' in value:
45+
return qs.natural_sort().reverse()
46+
47+
return super().filter(qs, value)
48+
49+
3950
class StorageMediumFilter(filters.FilterSet):
4051
status = ListFilter(field_name='status', distinct='true')
4152
medium_type = filters.ChoiceFilter(field_name='storage_target__type', choices=medium_type_CHOICES)
@@ -68,11 +79,12 @@ def filter_migratable(self, queryset, name, value):
6879
else:
6980
return queryset.non_migratable()
7081

71-
ordering = filters.OrderingFilter(
82+
ordering = StorageMediumOrderingFilter(
7283
fields=(
7384
('id', 'id'),
7485
('medium_id', 'medium_id'),
7586
('storage_target__name', 'storage_target'),
87+
('storage_target__max_capacity', 'max_capacity'),
7688
('status', 'status'),
7789
('location', 'location'),
7890
('location_status', 'location_status'),

ESSArch_Core/storage/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
)
3939

4040
from ESSArch_Core.configuration.models import Parameter, Path
41+
from ESSArch_Core.db.utils import natural_sort
4142
from ESSArch_Core.fixity.validation.backends.checksum import ChecksumValidator
4243
from ESSArch_Core.storage.backends import get_backend
4344
from ESSArch_Core.storage.copy import copy_file
@@ -508,6 +509,9 @@ def migratable(self):
508509
def non_migratable(self):
509510
return self.exclude(pk__in=self.migratable())
510511

512+
def natural_sort(self):
513+
return natural_sort(self, 'medium_id')
514+
511515
def fastest(self):
512516
container = Case(
513517
When(storage_target__methods__containers=False, then=Value(1)),

0 commit comments

Comments
 (0)