artefactual / archivematica-storage-service

Archivematica storage service
http://www.archivematica.org
GNU Affero General Public License v3.0
34 stars 43 forks source link

Problem: Dataverse create/edit space page is not rendering correctly #352

Closed ross-spencer closed 5 years ago

ross-spencer commented 6 years ago

The form component after the staging path when asked to re-render, e.g. submitting the form once correctly or otherwise results in the following output:

image

The HTML when we view source looks as follows:

<form action="/spaces/create/" method="post">
    <input type='hidden' name='csrfmiddlewaretoken' value='GDfsIWLVjGdtH6EFnDSxiJl3tbuYdQbq' />
    <p>
        <label for="id_space-access_protocol">Access protocol:</label>
        <select id="id_space-access_protocol" name="space-access_protocol">
            <option value="">---------</option>
            <option value="ARKIVUM">Arkivum</option>
            <option value="DV" selected="selected">Dataverse</option>
            <option value="DC">DuraCloud</option>
            <option value="DSPACE">DSpace via SWORD2 API</option>
            <option value="FEDORA">FEDORA via SWORD2</option>
            <option value="GPG">GPG encryption on Local Filesystem</option>
            <option value="FS">Local Filesystem</option>
            <option value="LOM">LOCKSS-o-matic</option>
            <option value="NFS">NFS</option>
            <option value="PIPE_FS">Pipeline Local Filesystem</option>
            <option value="SWIFT">Swift</option>
        </select> <span class="helptext">How the space can be accessed.</span></p>
    <p>
        <label for="id_space-size">Size:</label>
        <input id="id_space-size" max="9223372036854775807" min="-9223372036854775808" name="space-size" type="number" /> <span class="helptext">Size in bytes (optional)</span></p>
    <p>
        <label for="id_space-path">Path:</label>
        <textarea cols="40" id="id_space-path" name="space-path" rows="10">
            /var/archivematica/storage_service/dataverse/staging/</textarea> <span class="helptext">Absolute path to the space on the storage service machine.</span></p>
    <p>
        <label for="id_space-staging_path">Staging path:</label>
        <textarea cols="40" id="id_space-staging_path" name="space-staging_path" rows="10">
            /var/archivematica/storage_service/dataverse/staging/</textarea> <span class="helptext">Absolute path to a staging area.  Must be UNIX filesystem compatible, preferably on the same filesystem as the path.</span></p>
    <div id="protocol_form">&lt;ul class=&quot;errorlist&quot;&gt;&lt;li&gt;This field is required.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;label for=&quot;id_protocol-host&quot;&gt;Host:&lt;/label&gt; &lt;input id=&quot;id_protocol-host&quot; maxlength=&quot;256&quot; name=&quot;protocol-host&quot; type=&quot;text&quot; /&gt; &lt;span class=&quot;helptext&quot;&gt;xxx&lt;/span&gt;&lt;/p&gt; &lt;ul class=&quot;errorlist&quot;&gt;&lt;li&gt;This field is required.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;label for=&quot;id_protocol-api_key&quot;&gt;API key:&lt;/label&gt; &lt;input id=&quot;id_protocol-api_key&quot; maxlength=&quot;50&quot; name=&quot;protocol-api_key&quot; type=&quot;text&quot; /&gt; &lt;span class=&quot;helptext&quot;&gt;xxx&lt;/span&gt;&lt;/p&gt; &lt;ul class=&quot;errorlist&quot;&gt;&lt;li&gt;This field is required.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;label for=&quot;id_protocol-agent_name&quot;&gt;Agent name:&lt;/label&gt; &lt;input id=&quot;id_protocol-agent_name&quot; maxlength=&quot;50&quot; name=&quot;protocol-agent_name&quot; type=&quot;text&quot; /&gt; &lt;span class=&quot;helptext&quot;&gt;xxx&lt;/span&gt;&lt;/p&gt; &lt;ul class=&quot;errorlist&quot;&gt;&lt;li&gt;This field is required.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;label for=&quot;id_protocol-agent_type&quot;&gt;Agent type:&lt;/label&gt; &lt;input id=&quot;id_protocol-agent_type&quot; maxlength=&quot;50&quot; name=&quot;protocol-agent_type&quot; type=&quot;text&quot; /&gt; &lt;span class=&quot;helptext&quot;&gt;xxx&lt;/span&gt;&lt;/p&gt; &lt;ul class=&quot;errorlist&quot;&gt;&lt;li&gt;This field is required.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;label for=&quot;id_protocol-agent_identifier&quot;&gt;Agent identifier:&lt;/label&gt; &lt;input id=&quot;id_protocol-agent_identifier&quot; maxlength=&quot;256&quot; name=&quot;protocol-agent_identifier&quot; type=&quot;text&quot; /&gt; &lt;span class=&quot;helptext&quot;&gt;xxx&lt;/span&gt;&lt;/p&gt; &lt;div class=&quot;alert&quot;&gt;Integration with Dataverse is currently a beta feature&lt;/div&gt;</div>
    <input type="submit" value="Create Space" class='btn btn-primary' />
</form>
ross-spencer commented 6 years ago

We're overriding as_p here: https://github.com/artefactual/archivematica-storage-service/blob/stable/0.11.x/storage_service/locations/forms.py#L106

And the definition of as_p is here: https://docs.djangoproject.com/en/2.0/_modules/django/forms/forms/

For whatever reason, minor or otherwise, appending a string to as_p is causing this issue because if you remove it, all is okay.

There's a pretty nice thread on overriding this function here: https://stackoverflow.com/a/7770417. Consulting this and the class seems to show a focus on rows, not what happens at the end of the form, so I will take a look at this in more detail and also see if there are any clues as to why our little override isn't quite working when we come to render the form.

joel-simpson commented 6 years ago

Have tested this in our dataverse QA environment and it is looking good to me!