-
Notifications
You must be signed in to change notification settings - Fork 27
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
Provision editing #2277
Conversation
indigo_api/views/documents.py
Outdated
@@ -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?) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Nice! The chooser looks great |
indigo_api/models/documents.py
Outdated
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) |
There was a problem hiding this comment.
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?
indigo_api/models/documents.py
Outdated
# 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') |
There was a problem hiding this comment.
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.
indigo_api/serializers.py
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly falls away
indigo_api/serializers.py
Outdated
try: | ||
xml = attrs['content'] | ||
ns = AKN_NAMESPACES[DEFAULT_VERSION] | ||
xml = f'<akomaNtoso xmlns="{ns}">{xml}</akomaNtoso>' |
There was a problem hiding this comment.
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
indigo_api/views/documents.py
Outdated
@@ -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}) |
There was a problem hiding this comment.
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 === "") { |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
Nice! This is now much simpler, actually. |
No description provided.