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

Provision editing #2277

Merged
merged 43 commits into from
Dec 13, 2024
Merged

Provision editing #2277

merged 43 commits into from
Dec 13, 2024

Conversation

goose-life
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Nov 12, 2024

Test Results

568 tests  ±0   568 ✅ ±0   4m 20s ⏱️ -3s
 60 suites ±0     0 💤 ±0 
 60 files   ±0     0 ❌ ±0 

Results for commit 40edf09. ± Comparison against base commit 858efd8.

♻️ This comment has been updated with latest results.

@@ -122,6 +122,7 @@ def content(self, request, *args, **kwargs):

if request.method == 'PUT':
try:
# TODO: don't just reset here, integrate the content IFF in provision mode (or always?)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do I hit this breakpoint?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is called at all any more; it can be removed (and the PUT above) and we'll see when it breaks.

@goose-life
Copy link
Contributor Author

@longhotsummer
Copy link
Contributor

Nice! The chooser looks great

@goose-life
Copy link
Contributor Author

xml = etree.fromstring(provision_xml)
akn_provision = generator.wrap_akn(xml)
portion = Portion(etree.tostring(akn_provision, encoding='unicode'))
updated_provision = portion.get_portion_element(new_provision_eid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems odd to have to have the new_provision_id, can't we just use the portionBody first child element?

# fix up the XML: rewrite eids, correct tags etc.
updated_xml = generator.post_process(self.doc.main)
with_akn_tag = generator.wrap_akn(updated_xml)
return etree.tostring(with_akn_tag, encoding='unicode')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call reset_xml here to save the updates into the string, so that the string and self.doc are still aligned.

@@ -264,6 +264,10 @@ class DocumentSerializer(serializers.HyperlinkedModelSerializer):
repeal = RepealSerializer(read_only=True,
help_text="Description of the repeal of this work, if it has been repealed.")

# only for provision editing
provision_eid = serializers.CharField(required=False, allow_blank=True)
new_provision_eid = serializers.CharField(required=False, allow_blank=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly falls away

try:
xml = attrs['content']
ns = AKN_NAMESPACES[DEFAULT_VERSION]
xml = f'<akomaNtoso xmlns="{ns}">{xml}</akomaNtoso>'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather get the client to provide this as fully valid AKN, so the server doesn't have to make guesses

@@ -354,7 +356,11 @@ def post(self, request, document_id):
doc.frbr_uri = frbr_uri
xml = doc.to_xml(encoding='unicode')

return Response({'output': xml})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally the client should be extracting the eId and doing with it whatever it needs to, so these changes can fall away

new indigoAkn.EidRewriter().rewriteAllEids(this.xmlDocument.documentElement);
// rewrite all attachment FRBR URI work components too
new indigoAkn.WorkComponentRewriter().rewriteAllAttachmentWorkComponents(this.xmlDocument.documentElement);
if (Indigo.Preloads.provisionEid === "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:( always needs to be done, in case you quick-edit something and give it a duplicate eid

@@ -185,6 +187,8 @@
// changes in a single revision on the server.
// We do this by delegating to the document object.
this.document.attributes.content = this.get('content');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when in provision mode, wrap this in appropriate tags to make it a fully valid akn portion

@@ -576,6 +578,11 @@
.fail(fail);
}

// TODO: a better way of reloading the page (will redirect to provision chooser for now)
if (Indigo.Preloads.provisionEid !== Indigo.Preloads.newProvisionEid) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will change to check the expected against the actual in the XML, rather than using preloads.newProvisionEid

@goose-life goose-life marked this pull request as ready for review December 11, 2024 14:43
@longhotsummer
Copy link
Contributor

Nice! This is now much simpler, actually.

longhotsummer
longhotsummer previously approved these changes Dec 12, 2024
longhotsummer
longhotsummer previously approved these changes Dec 12, 2024
@goose-life goose-life merged commit 51c827e into master Dec 13, 2024
5 checks passed
@goose-life goose-life deleted the provision-editing branch December 13, 2024 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants