visualization_views.py 2.74 KB
Newer Older
1
from django.shortcuts import render
2 3
import os

4 5 6 7 8 9 10

def MUSE_v3_display_summation(request,input_dict,output_dict,widget):
    if sum(input_dict['intList']) == input_dict['sum']:
        check = 'The calculation appears correct.'
    else:
        check = 'The calculation appears incorrect!'
    return render(request, 'visualizations/MUSE_v3_display_integers.html',{'widget':widget,'input_dict':input_dict, 'output_dict':output_dict, 'check':check})
11 12 13 14 15 16 17 18 19




def MUSE_view_xmlOLD(request, input_dict, output_dict, widget):
    return render(request, 'visualizations/MUSE_view_xml.html',
                  {'widget': widget, 'xml_data': input_dict['xml_data']})


vpodpecan's avatar
vpodpecan committed
20
def MUSE_view_xml_V3(request, input_dict, output_dict, widget):
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
    from mothra.settings import MEDIA_ROOT
    from workflows.helpers import ensure_dir

    filename = '/'.join([str(request.user.id), str(widget.id) + '.xml'])
    destination = '/'.join([MEDIA_ROOT, filename])
    ensure_dir(destination)
    f = open(destination, 'w')
    f.write(str(input_dict['xml_data']))
    f.close()

    return render(request, 'visualizations/MUSE_view_xml.html',
                  {'widget': widget, 'filename': filename})


def MUSE_virtual_environment_visualization(request, input_dict, output_dict, widget):
    from mothra.settings import MEDIA_ROOT
    from workflows.helpers import ensure_dir
    filename = os.path.join(str(request.user.id), str(widget.id) + '.txt')
    destination = os.path.join(MEDIA_ROOT, filename)
    ensure_dir(destination)
    f = open(destination, 'w')
    f.write(str(input_dict['NLP_data']))
    f.close()
    return render(request,
                  'visualizations/MUSE_view_3D_environment.html',
                  {'widget': widget,
                   'filename': filename,
                   'unitylink': input_dict['unitylink']
                   })


vpodpecan's avatar
vpodpecan committed
52
def MUSE_virtual_environment_demonstrator_tuk_V3(request, input_dict, output_dict, widget):
53 54 55 56 57
    from urllib import urlencode
    params = urlencode({'filename': str(input_dict['mappingLink'])})
    unityLink = '%s?%s' % (str(input_dict['unityLink']), params)
    # print unityLink
    return render(request,
vpodpecan's avatar
fixes  
vpodpecan committed
58
                  'visualizations/MUSE_Tuk_demonstrator_V3.html',
59 60 61 62 63
                  {'widget': widget,
                   'unityLink': unityLink}
                  )


vpodpecan's avatar
vpodpecan committed
64
def MUSE_virtual_environment_demonstrator_tuk_local_V3(request, input_dict, output_dict, widget):
65 66 67 68 69
    from urllib import urlencode
    params = urlencode({'filename': str(input_dict['mappingLink'])})
    unityLink = '%s?%s' % (str(input_dict['unityLink']), params)
    # print unityLink
    return render(request,
vpodpecan's avatar
fixes  
vpodpecan committed
70
                  'visualizations/MUSE_Tuk_demonstrator_local_V3.html',
71 72 73
                  {'widget': widget,
                   'unityLink': unityLink}
                  )