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

Script GUI file upload #128

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@

{% if i.min %}<span style="color: #666"> Min: {{ i.min }} </span>{% endif %}
{% if i.max %}<span style="color: #666"> Max: {{ i.max }} </span>{% endif %}

<!-- If "File Annotation", allow user to choose file to upload, to create a File-Annotation -->
{% ifequal i.name 'File Annotation' %}
OR <input name='file_annotation' type='file'/>
{% endifequal %}

</td></tr>
</table>
</div>
12 changes: 12 additions & 0 deletions omeroweb/webclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4337,10 +4337,22 @@ def script_run(request, scriptId, conn=None, **kwargs):

logger.debug("Script: run with request.POST: %s" % request.POST)

# upload new file
fileupload = ('file_annotation' in request.FILES and
request.FILES['file_annotation'] or None)
fileAnnId = None
if fileupload is not None and fileupload != "":
manager = BaseContainer(conn)
fileAnnId = manager.createFileAnnotations(fileupload, [])

for key, param in params.inputs.items():
prototype = param.prototype
pclass = prototype.__class__

if key == "File_Annotation" and fileAnnId is not None:
inputMap[key] = pclass(str(fileAnnId))
continue

# handle bool separately, since unchecked checkbox will not be in
# request.POST
if pclass == omero.rtypes.RBoolI:
Expand Down