Skip to content

Commit 027f976

Browse files
committed
deposit: remove category
- Adapts JSONSchema to the new angular 17 version. - Removes the category file subfield to be consistent with the document resource. Co-Authored-by: Johnny Mariéthoz <[email protected]>
1 parent ad3310a commit 027f976

File tree

11 files changed

+44
-149
lines changed

11 files changed

+44
-149
lines changed

sonar/common/jsonschemas/classification-v1.0.0.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@
9292
],
9393
"widget": {
9494
"formlyConfig": {
95-
"wrappers": [
96-
"card"
97-
],
95+
"type": "tree-select",
9896
"props": {
9997
"sort": false,
10098
"options": [
@@ -503,4 +501,4 @@
503501
}
504502
}
505503
}
506-
}
504+
}

sonar/common/jsonschemas/license-v1.0.0.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
"expressions": {
1919
"props.required": "true"
2020
},
21-
"wrappers": [
22-
"card"
23-
],
2421
"props": {
2522
"options": [
2623
{
@@ -63,4 +60,4 @@
6360
}
6461
}
6562
}
66-
}
63+
}

sonar/common/jsonschemas/type-v1.0.0.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,10 @@
5454
],
5555
"widget": {
5656
"formlyConfig": {
57+
"type": "tree-select",
5758
"expressions": {
5859
"props.required": "true"
5960
},
60-
"wrappers": [
61-
"card"
62-
],
6361
"props": {
6462
"sort": false,
6563
"options": [
@@ -283,4 +281,4 @@
283281
}
284282
}
285283
}
286-
}
284+
}

sonar/dedicated/hepvs/projects/jsonschemas/hepvs/projects/project-v1.0.0_src.json

-3
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@
540540
],
541541
"widget": {
542542
"formlyConfig": {
543-
"type": "select",
544543
"props": {
545544
"options": [
546545
{
@@ -687,7 +686,6 @@
687686
],
688687
"widget": {
689688
"formlyConfig": {
690-
"type": "select",
691689
"props": {
692690
"options": [
693691
{
@@ -943,7 +941,6 @@
943941
],
944942
"widget": {
945943
"formlyConfig": {
946-
"type": "select",
947944
"expressions": {
948945
"hide": "!model || !model.choice"
949946
},

sonar/modules/collections/jsonschemas/collections/collection-v1.0.0_src.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@
166166
"type": "string",
167167
"minLength": 1
168168
},
169+
"label": {
170+
"title": "Label",
171+
"type": "string",
172+
"minLength": 1
173+
},
169174
"mimetype": {
170175
"title": "Mimetype",
171176
"type": "string",
@@ -183,6 +188,9 @@
183188
"type": "integer"
184189
}
185190
},
191+
"propertiesOrder": [
192+
"label"
193+
],
186194
"required": [
187195
"bucket",
188196
"file_id",
@@ -199,4 +207,4 @@
199207
"required": [
200208
"name"
201209
]
202-
}
210+
}

sonar/modules/deposits/api.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -456,20 +456,12 @@ def create_document(self):
456456
dbcommit=True,
457457
with_bucket=True)
458458

459-
current_order = 2
460-
for file in self.files:
459+
for idx, file in enumerate(self.files, start=1):
461460
with file.file.storage().open() as pdf_file:
462461
content = pdf_file.read()
463-
464-
if file.get('category', 'main') == 'main':
465-
order = 1
466-
else:
467-
order = current_order
468-
current_order += 1
469-
470462
kwargs = {
471463
'label': file.get('label', file['key']),
472-
'order': order
464+
'order': file.get('order', idx)
473465
}
474466

475467
if file.get('embargo', False) and file.get('embargoDate'):

sonar/modules/deposits/jsonschemas/deposits/deposit-v1.0.0_src.json

+9-104
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,12 @@
7373
"type": "string",
7474
"minLength": 1
7575
},
76-
"category": {
77-
"title": "Type",
78-
"type": "string",
79-
"enum": [
80-
"main",
81-
"additional"
82-
],
83-
"default": "main"
76+
"order": {
77+
"title": "Position",
78+
"description": "Position of the file, the first file in the list is the main file.",
79+
"type": "integer",
80+
"default": 1,
81+
"minimum": 1
8482
},
8583
"type": {
8684
"title": "Type",
@@ -324,14 +322,6 @@
324322
"language": {
325323
"$ref": "language-v1.0.0.json"
326324
}
327-
},
328-
"widget": {
329-
"formlyConfig": {
330-
"wrappers": [
331-
"card"
332-
],
333-
"props": {}
334-
}
335325
}
336326
},
337327
"language": {
@@ -425,9 +415,7 @@
425415
],
426416
"widget": {
427417
"formlyConfig": {
428-
"wrappers": [
429-
"card"
430-
],
418+
"type": "tree-select",
431419
"props": {
432420
"options": [
433421
{
@@ -570,14 +558,6 @@
570558
"type",
571559
"value"
572560
]
573-
},
574-
"widget": {
575-
"formlyConfig": {
576-
"wrappers": [
577-
"card"
578-
],
579-
"props": {}
580-
}
581561
}
582562
},
583563
"publication": {
@@ -739,11 +719,7 @@
739719
"formlyConfig": {
740720
"expressions": {
741721
"hide": "field.parent.model && !['coar:c_3248', 'coar:c_5794', 'coar:c_6670', 'coar:c_3e5a', 'coar:c_ba08', 'coar:c_beb9', 'coar:c_6501', 'coar:c_816b', 'coar:c_998f', 'coar:c_dcae04bc'].includes(field.parent.model.documentType)"
742-
},
743-
"wrappers": [
744-
"card"
745-
],
746-
"props": {}
722+
}
747723
}
748724
}
749725
},
@@ -790,14 +766,6 @@
790766
}
791767
}
792768
}
793-
},
794-
"widget": {
795-
"formlyConfig": {
796-
"wrappers": [
797-
"card"
798-
],
799-
"props": {}
800-
}
801769
}
802770
},
803771
"collections": {
@@ -828,14 +796,6 @@
828796
"required": [
829797
"$ref"
830798
]
831-
},
832-
"widget": {
833-
"formlyConfig": {
834-
"wrappers": [
835-
"card"
836-
],
837-
"props": {}
838-
}
839799
}
840800
},
841801
"classification": {
@@ -874,14 +834,6 @@
874834
}
875835
}
876836
}
877-
},
878-
"widget": {
879-
"formlyConfig": {
880-
"wrappers": [
881-
"card"
882-
],
883-
"props": {}
884-
}
885837
}
886838
},
887839
"subjects": {
@@ -916,14 +868,6 @@
916868
}
917869
}
918870
}
919-
},
920-
"widget": {
921-
"formlyConfig": {
922-
"wrappers": [
923-
"card"
924-
],
925-
"props": {}
926-
}
927871
}
928872
},
929873
"dissertation": {
@@ -972,11 +916,7 @@
972916
"formlyConfig": {
973917
"expressions": {
974918
"hide": "field.parent.model && !['coar:c_46ec', 'coar:c_7a1f', 'coar:c_db06', 'coar:c_bdcc', 'habilitation_thesis', 'advanced_studies_thesis', 'other_thesis'].includes(field.parent.model.documentType)"
975-
},
976-
"wrappers": [
977-
"card"
978-
],
979-
"props": {}
919+
}
980920
}
981921
}
982922
},
@@ -1200,14 +1140,6 @@
12001140
}
12011141
}
12021142
}
1203-
},
1204-
"widget": {
1205-
"formlyConfig": {
1206-
"wrappers": [
1207-
"card"
1208-
],
1209-
"props": {}
1210-
}
12111143
}
12121144
}
12131145
}
@@ -1271,9 +1203,6 @@
12711203
],
12721204
"widget": {
12731205
"formlyConfig": {
1274-
"wrappers": [
1275-
"card"
1276-
],
12771206
"props": {
12781207
"options": [
12791208
{
@@ -1329,14 +1258,6 @@
13291258
"minLength": 4
13301259
}
13311260
}
1332-
},
1333-
"widget": {
1334-
"formlyConfig": {
1335-
"wrappers": [
1336-
"card"
1337-
],
1338-
"props": {}
1339-
}
13401261
}
13411262
},
13421263
"projects": {
@@ -1438,14 +1359,6 @@
14381359
]
14391360
}
14401361
]
1441-
},
1442-
"widget": {
1443-
"formlyConfig": {
1444-
"wrappers": [
1445-
"card"
1446-
],
1447-
"props": {}
1448-
}
14491362
}
14501363
},
14511364
"diffusion": {
@@ -1493,14 +1406,6 @@
14931406
"required": [
14941407
"$ref"
14951408
]
1496-
},
1497-
"widget": {
1498-
"formlyConfig": {
1499-
"wrappers": [
1500-
"card"
1501-
],
1502-
"props": {}
1503-
}
15041409
}
15051410
},
15061411
"masked": {

sonar/modules/deposits/mappings/v7/deposits/deposit-v1.0.0.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
"size": {
4242
"type": "integer"
4343
},
44+
"order": {
45+
"type": "integer"
46+
},
4447
"label": {
4548
"type": "text"
4649
},
47-
"category": {
48-
"type": "keyword"
49-
},
5050
"type": {
5151
"type": "keyword"
5252
},

sonar/modules/deposits/rest.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def post(pid=None):
6666
# Store document
6767
deposit.files[key] = BytesIO(request.get_data())
6868
deposit.files[key]['label'] = re.search(r'(.*)\..*$', key).group(1)
69-
deposit.files[key]['category'] = request.args['type']
7069
deposit.files[key]['type'] = 'file'
7170

7271
deposit.commit()
@@ -247,7 +246,7 @@ def extract_metadata(pid=None):
247246

248247
main_file = [
249248
file for file in deposit.files
250-
if file['category'] == 'main' and file.mimetype == 'application/pdf'
249+
if file['order'] == 1 and file.mimetype == 'application/pdf'
251250
]
252251

253252
if not main_file:

0 commit comments

Comments
 (0)