diff --git a/python/nistoar/midas/dbio/project.py b/python/nistoar/midas/dbio/project.py index 855e438..8065593 100644 --- a/python/nistoar/midas/dbio/project.py +++ b/python/nistoar/midas/dbio/project.py @@ -214,7 +214,7 @@ def _restore_last_published_data(self, prec: ProjectRecord, message: str=None, prec.data = pubrec.data if reset_state: - prec.status.set_state(status.PUBLISHED) + prec.status.set_state(pubrec.status.state) prec.status.act(self.STATUS_ACTION_RESTORE, message or defmsg) prec.save() @@ -930,7 +930,7 @@ def submit(self, id: str, message: str=None, _prec=None) -> status.RecordStatus: if _prec.data.get('@version', '1.0.0') == '1.0.0': message = "Initial version " + poststat else: - message = "Revision " + postat + message = "Revision " + poststat # record provenance record self.dbcli.record_action(Action(Action.PROCESS, _prec.id, self.who, message, {"name": "submit"})) @@ -964,6 +964,7 @@ def _submit(self, prec: ProjectRecord) -> str: not due to anything the client did, but rather reflects a system problem (e.g. from a downstream service). """ + endstate = status.SUBMITTED # or could be status.PUBLISHED try: latestcli = self.dbcli.client_for(f"{self.dbcli.project}_latest", AUTOADMIN) versioncli = self.dbcli.client_for(f"{self.dbcli.project}_version", AUTOADMIN) @@ -974,8 +975,10 @@ def _submit(self, prec: ProjectRecord) -> str: recd['id'] += "/pdr:v/" + recd['data'].get("@version", "0") version = ProjectRecord(versioncli.project, deepcopy(recd), versioncli) - # Fix permissions + # Fix permissions, state for pubrec in (latest, version): + pubrec.status.set_state(endstate) + # no one can delete, write, or admin (except superusers) pubrec.acls.revoke_perm_from_all(ACLs.DELETE) pubrec.acls.revoke_perm_from_all(ACLs.WRITE) @@ -993,7 +996,7 @@ def _submit(self, prec: ProjectRecord) -> str: self.log.error("%s: Problem with default publication submission: %s", prec.id, str(ex)) raise SubmissionFailed() from ex - return status.PUBLISHED + return endstate diff --git a/python/tests/nistoar/midas/dbio/test_project.py b/python/tests/nistoar/midas/dbio/test_project.py index 108492b..12573f3 100644 --- a/python/tests/nistoar/midas/dbio/test_project.py +++ b/python/tests/nistoar/midas/dbio/test_project.py @@ -167,6 +167,7 @@ def test_restore_last_published_data(self): pubcli = self.project.dbcli.client_for(self.project.dbcli.project + "_latest") pubrec = project.ProjectRecord(pubcli.project, recd, pubcli) + pubrec.status.set_state(status.SUBMITTED) pubrec.save() pubrec = pubcli.get_record_for(recd['id']) self.assertEqual(pubrec.id, recd['id']) @@ -182,7 +183,7 @@ def test_restore_last_published_data(self): prec = self.project.get_record(prec.id) self.assertEqual(prec.data.get('color'), "red") self.assertIsNone(prec.data.get('title')) - self.assertEqual(prec.status.state, status.PUBLISHED) + self.assertEqual(prec.status.state, status.SUBMITTED) def test_delete_revision(self): self.create_service() @@ -198,6 +199,7 @@ def test_delete_revision(self): pubcli = self.project.dbcli.client_for(self.project.dbcli.project + "_latest") pubrec = project.ProjectRecord(pubcli.project, recd, pubcli) + pubrec.status.set_state(status.PUBLISHED) pubrec.save() pubrec = pubcli.get_record_for(recd['id']) self.assertEqual(pubrec.id, recd['id']) @@ -422,7 +424,7 @@ def test_submit(self): prec = self.project.get_record(prec.id) self.assertEqual(prec.data.get("@version"), "1.0.0") self.assertEqual(prec.data.get("@id"), "ark:/88434/mdm1-0003") - self.assertEqual(prec.status.state, "published") + self.assertEqual(prec.status.state, "submitted") pubcli = self.project.dbcli.client_for(self.project.dbcli.project+"_latest") pubrec = pubcli.get_record_for(prec.data["@id"]) diff --git a/python/tests/nistoar/midas/dbio/wsgi/test_project.py b/python/tests/nistoar/midas/dbio/wsgi/test_project.py index e221095..95dee5f 100644 --- a/python/tests/nistoar/midas/dbio/wsgi/test_project.py +++ b/python/tests/nistoar/midas/dbio/wsgi/test_project.py @@ -884,7 +884,7 @@ def test_process(self): self.assertIn("200 ", self.resp[0]) resp = self.body2dict(body) - self.assertEqual(resp['state'], 'published') + self.assertEqual(resp['state'], 'submitted') self.assertEqual(resp['action'], 'submit') self.assertIn('modified', resp) self.assertIn('since', resp)