Skip to content

Commit faae722

Browse files
committed
"derrived_from": []
1 parent 9771357 commit faae722

File tree

10 files changed

+94
-159
lines changed

10 files changed

+94
-159
lines changed

biocompute/apis.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def post(self, request) -> Response:
101101
data = request.data
102102
rejected_requests = False
103103
accepted_requests = False
104-
if 'POST_api_objects_drafts_create' in request.data:
104+
if 'POST_api_objects_draft_create' in request.data:
105105
data = legacy_api_converter(request.data)
106106

107107
for index, object in enumerate(data):
@@ -506,12 +506,12 @@ class DraftsPublishApi(APIView):
506506
properties={
507507
"published_object_id": openapi.Schema(
508508
type=openapi.TYPE_STRING,
509-
description="BCO Object Draft ID.",
509+
description="BCO Object ID to use for published object.",
510510
example="http://127.0.0.1:8000/TEST_000001/1.0"
511511
),
512512
"object_id": openapi.Schema(
513513
type=openapi.TYPE_STRING,
514-
description="BCO Object ID to use for published object.",
514+
description="BCO Object Draft ID to look up.",
515515
example="http://127.0.0.1:8000/TEST_000001/DRAFT"
516516
),
517517
"delete_draft": openapi.Schema(
@@ -535,7 +535,16 @@ class DraftsPublishApi(APIView):
535535
)
536536

537537
def post(self, request) -> Response:
538-
if request.data[0]["object_id"] == \
538+
validator = BcoValidator()
539+
response_data = []
540+
requester = request.user
541+
data = request.data
542+
rejected_requests = False
543+
accepted_requests = False
544+
if 'POST_api_objects_drafts_publish' in request.data:
545+
data = legacy_api_converter(request.data)
546+
547+
if "object_id" in data[0] and data[0]["object_id"] == \
539548
"http://127.0.0.1:8000/TEST_000001/DRAFT":
540549
return Response(
541550
status=status.HTTP_200_OK,
@@ -548,17 +557,8 @@ def post(self, request) -> Response:
548557
}
549558
}]
550559
)
551-
validator = BcoValidator()
552-
response_data = []
553-
requester = request.user
554-
data = request.data
555-
rejected_requests = False
556-
accepted_requests = False
557-
if 'POST_api_objects_drafts_publish' in request.data:
558-
data = legacy_api_converter(request.data)
559-
560+
560561
for index, object in enumerate(data):
561-
# response_id = object["contents"].get("object_id", index)
562562
response_id = object.get("object_id", index)
563563
bco_instance = user_can_publish_bco(object, requester)
564564

biocompute/selectors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def user_can_publish_bco(object: dict, user:User) -> Bco:
9898
if the user is authorized to publish the specified BCO, `False`
9999
otherwise. Returns `None` if the specified BCO does not exist.
100100
"""
101-
101+
102102
draft_deconstructed = object_id_deconstructor(object["object_id"])
103103
published_deconstructed = []
104104
if "published_object_id" in object:

biocompute/services.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ def publish_draft(bco_instance: Bco, user: User, object: dict):
552552
new_bco_instance = deepcopy(bco_instance)
553553
new_bco_instance.id = None
554554
new_bco_instance.state = "PUBLISHED"
555+
contents= new_bco_instance.contents
555556
if "published_object_id" in object:
556557
new_bco_instance.object_id = object["published_object_id"]
557558
else:
558-
contents= new_bco_instance.contents
559559
version = contents['provenance_domain']['version']
560560
draft_deconstructed = object_id_deconstructor(object["object_id"])
561561
draft_deconstructed[-1] = version
@@ -566,9 +566,9 @@ def publish_draft(bco_instance: Bco, user: User, object: dict):
566566
timezone.now()
567567
)
568568
contents["etag"] = generate_etag(contents)
569-
thingk = bco_score(bco_instance=new_bco_instance)
569+
score = bco_score(bco_instance=new_bco_instance)
570570

571-
if object["delete_draft"] is True:
571+
if "delete_draft" in object and object["delete_draft"] is True:
572572
deleted = delete_draft(bco_instance=bco_instance, user=user)
573573

574574
return new_bco_instance

config/fixtures/local_data.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@
922922
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
923923
"created": "2022-02-07T17:36:05.872Z",
924924
"modified": "2022-06-28T23:44:49.394Z",
925-
"derived_from": [],
925+
"derived_from": "",
926926
"contributors": [
927927
{
928928
"contribution": [
@@ -1155,7 +1155,7 @@
11551155
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
11561156
"created": "2022-02-07T17:36:05.872Z",
11571157
"modified": "2022-06-28T23:44:49.394Z",
1158-
"derived_from": [],
1158+
"derived_from": "",
11591159
"contributors": [
11601160
{
11611161
"contribution": [
@@ -1388,7 +1388,7 @@
13881388
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
13891389
"created": "2022-02-07T17:36:05.872Z",
13901390
"modified": "2022-06-28T23:44:49.394Z",
1391-
"derived_from": [],
1391+
"derived_from": "",
13921392
"contributors": [
13931393
{
13941394
"contribution": [
@@ -1989,7 +1989,7 @@
19891989
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
19901990
"created": "2022-02-07T17:36:05.872Z",
19911991
"modified": "2022-06-28T23:44:49.394Z",
1992-
"derived_from": [],
1992+
"derived_from": "",
19931993
"contributors": [
19941994
{
19951995
"contribution": [
@@ -2222,7 +2222,7 @@
22222222
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
22232223
"created": "2022-02-07T17:36:05.872Z",
22242224
"modified": "2022-06-28T23:44:49.394Z",
2225-
"derived_from": [],
2225+
"derived_from": "",
22262226
"contributors": [
22272227
{
22282228
"contribution": [
@@ -2504,7 +2504,7 @@
25042504
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
25052505
"created": "2022-02-07T17:36:05.872Z",
25062506
"modified": "2022-06-28T23:44:49.394Z",
2507-
"derived_from": [],
2507+
"derived_from": "",
25082508
"contributors": [
25092509
{
25102510
"contribution": [
@@ -2737,7 +2737,7 @@
27372737
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
27382738
"created": "2022-02-07T17:36:05.872Z",
27392739
"modified": "2022-06-28T23:44:49.394Z",
2740-
"derived_from": [],
2740+
"derived_from": "",
27412741
"contributors": [
27422742
{
27432743
"contribution": [
@@ -3207,7 +3207,7 @@
32073207
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
32083208
"created": "2022-02-07T17:36:05.872Z",
32093209
"modified": "2022-06-28T23:44:49.394Z",
3210-
"derived_from": [],
3210+
"derived_from": "",
32113211
"contributors": [
32123212
{
32133213
"contribution": [
@@ -3440,7 +3440,7 @@
34403440
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
34413441
"created": "2022-02-07T17:36:05.872Z",
34423442
"modified": "2022-06-28T23:44:49.394Z",
3443-
"derived_from": [],
3443+
"derived_from": "",
34443444
"contributors": [
34453445
{
34463446
"contribution": [
@@ -3673,7 +3673,7 @@
36733673
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
36743674
"created": "2022-02-07T17:36:05.872Z",
36753675
"modified": "2022-06-28T23:44:49.394Z",
3676-
"derived_from": [],
3676+
"derived_from": "",
36773677
"contributors": [
36783678
{
36793679
"contribution": [
@@ -3906,7 +3906,7 @@
39063906
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
39073907
"created": "2022-02-07T17:36:05.872Z",
39083908
"modified": "2022-06-28T23:44:49.394Z",
3909-
"derived_from": [],
3909+
"derived_from": "",
39103910
"contributors": [
39113911
{
39123912
"contribution": [
@@ -4139,7 +4139,7 @@
41394139
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
41404140
"created": "2022-02-07T17:36:05.872Z",
41414141
"modified": "2022-06-28T23:44:49.394Z",
4142-
"derived_from": [],
4142+
"derived_from": "",
41434143
"contributors": [
41444144
{
41454145
"contribution": [

config/fixtures/test_portal.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@
844844
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
845845
"created": "2022-02-07T17:36:05.872Z",
846846
"modified": "2022-06-28T23:44:49.394Z",
847-
"derived_from": [],
847+
"derived_from": "",
848848
"contributors": [
849849
{
850850
"contribution": [
@@ -1077,7 +1077,7 @@
10771077
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
10781078
"created": "2022-02-07T17:36:05.872Z",
10791079
"modified": "2022-06-28T23:44:49.394Z",
1080-
"derived_from": [],
1080+
"derived_from": "",
10811081
"contributors": [
10821082
{
10831083
"contribution": [
@@ -1310,7 +1310,7 @@
13101310
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
13111311
"created": "2022-02-07T17:36:05.872Z",
13121312
"modified": "2022-06-28T23:44:49.394Z",
1313-
"derived_from": [],
1313+
"derived_from": "",
13141314
"contributors": [
13151315
{
13161316
"contribution": [
@@ -1911,7 +1911,7 @@
19111911
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
19121912
"created": "2022-02-07T17:36:05.872Z",
19131913
"modified": "2022-06-28T23:44:49.394Z",
1914-
"derived_from": [],
1914+
"derived_from": "",
19151915
"contributors": [
19161916
{
19171917
"contribution": [
@@ -2144,7 +2144,7 @@
21442144
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
21452145
"created": "2022-02-07T17:36:05.872Z",
21462146
"modified": "2022-06-28T23:44:49.394Z",
2147-
"derived_from": [],
2147+
"derived_from": "",
21482148
"contributors": [
21492149
{
21502150
"contribution": [
@@ -2426,7 +2426,7 @@
24262426
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
24272427
"created": "2022-02-07T17:36:05.872Z",
24282428
"modified": "2022-06-28T23:44:49.394Z",
2429-
"derived_from": [],
2429+
"derived_from": "",
24302430
"contributors": [
24312431
{
24322432
"contribution": [
@@ -2659,7 +2659,7 @@
26592659
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
26602660
"created": "2022-02-07T17:36:05.872Z",
26612661
"modified": "2022-06-28T23:44:49.394Z",
2662-
"derived_from": [],
2662+
"derived_from": "",
26632663
"contributors": [
26642664
{
26652665
"contribution": [
@@ -3129,7 +3129,7 @@
31293129
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
31303130
"created": "2022-02-07T17:36:05.872Z",
31313131
"modified": "2022-06-28T23:44:49.394Z",
3132-
"derived_from": [],
3132+
"derived_from": "",
31333133
"contributors": [
31343134
{
31353135
"contribution": [
@@ -3362,7 +3362,7 @@
33623362
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
33633363
"created": "2022-02-07T17:36:05.872Z",
33643364
"modified": "2022-06-28T23:44:49.394Z",
3365-
"derived_from": [],
3365+
"derived_from": "",
33663366
"contributors": [
33673367
{
33683368
"contribution": [
@@ -3595,7 +3595,7 @@
35953595
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
35963596
"created": "2022-02-07T17:36:05.872Z",
35973597
"modified": "2022-06-28T23:44:49.394Z",
3598-
"derived_from": [],
3598+
"derived_from": "",
35993599
"contributors": [
36003600
{
36013601
"contribution": [
@@ -3828,7 +3828,7 @@
38283828
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
38293829
"created": "2022-02-07T17:36:05.872Z",
38303830
"modified": "2022-06-28T23:44:49.394Z",
3831-
"derived_from": [],
3831+
"derived_from": "",
38323832
"contributors": [
38333833
{
38343834
"contribution": [
@@ -4061,7 +4061,7 @@
40614061
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
40624062
"created": "2022-02-07T17:36:05.872Z",
40634063
"modified": "2022-06-28T23:44:49.394Z",
4064-
"derived_from": [],
4064+
"derived_from": "",
40654065
"contributors": [
40664066
{
40674067
"contribution": [

config/services.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,20 @@ def legacy_api_converter(data:dict) ->dict:
5050
_, new_data = data.popitem()
5151

5252
if "draft_id" in new_data[0]:
53-
return_data =[]
54-
for object in new_data:
55-
if "object_id" in object:
56-
return_data.append({
57-
"object_id": object["draft_id"],
58-
"published_object_id": object["object_id"],
59-
"delete_draft": object["delete_draft"]
60-
})
61-
else:
62-
return_data.append({
63-
"object_id": object["draft_id"],
64-
"delete_draft": object["delete_draft"]
65-
})
53+
return_data =[]
54+
for object in new_data:
55+
if "object_id" in object:
56+
return_data.append({
57+
"object_id": object["draft_id"],
58+
"published_object_id": object["object_id"],
59+
"delete_draft": object["delete_draft"]
60+
})
61+
else:
62+
return_data.append({
63+
"object_id": object["draft_id"],
64+
"delete_draft": object["delete_draft"]
65+
})
66+
return return_data
6667

6768
if "prefixes" in new_data[0]:
6869
return_data =[]
@@ -74,7 +75,7 @@ def legacy_api_converter(data:dict) ->dict:
7475
"description": prefix["description"]
7576
})
7677
return return_data
77-
78+
7879
return new_data
7980

8081
def response_constructor(

0 commit comments

Comments
 (0)