Skip to content

Commit

Permalink
Merge pull request #128 from will-moore/script_gui_file_upload
Browse files Browse the repository at this point in the history
script GUI file upload
  • Loading branch information
jburel authored Feb 18, 2020
2 parents 0717a9f + 7abf1c0 commit f56a796
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit f56a796

Please sign in to comment.