Exemple #1
0
def base(request, context):
    # Keep existing service name previously set by any of the webtools
    serviceName = getVarFromRequest(request, SERVICE_NAME)

    if serviceName is None and SERVICE_NAME in context:
        serviceName = context[SERVICE_NAME]

    context_base = {
        # ICON
        'favicon': getResourceIcon('favicon'),
        'logo_scipion': getResourceIcon('logo_scipion'),
        'logo_scipion_transparent':
        getResourceIcon('logo_scipion_transparent'),
        # CSS
        'general_css': getResourceCss('general'),
        'messi_css': getResourceCss('messi'),
        'font_awesome': getResourceCss('font_awesome'),
        # JS
        'jquery': getResourceJs('jquery'),
        'messi_js': getResourceJs('messi'),
        # JS
        'utils': getResourceJs('utils'),
        "projectName": getVarFromRequest(request, PROJECT_NAME),
        SERVICE_NAME: serviceName
    }

    context = VARS_base(request, context)
    context.update(context_base)
    return context
Exemple #2
0
def create_project(request):
    manager = Manager()

    if request.is_ajax():
        projectName = getVarFromRequest(request, PROJECT_NAME)
        workflow = getVarFromRequest(request, WORKFLOW)
        manager.createProject(projectName, chdir=False, workflow=workflow)

    return HttpResponse(content_type='application/javascript')
Exemple #3
0
def project_content(request):
    projectName = getVarFromRequest(request, PROJECT_NAME)
    mode = getVarFromRequest(request, MODE)
    project = Manager().loadProject(projectName, chdir=False)
    context = contentContext(request, project)
    context.update({'mode': mode, 'formUrl': 'form'})

    if mode == MODE_WORKFLOW:
        context.update({'nowest': True})

    return render_to_response('project_content/project_content.html', context)
Exemple #4
0
def contentContext(request, project, serviceName=None):
    from pyworkflow.gui.tree import ProjectRunsTreeProvider

    projectName = project.getShortName()
    if serviceName is None:
        serviceName = getVarFromRequest(request, SERVICE_NAME)

    project_settings = project.getSettings()
    request.session[CTX_PROJECT_PATH] = project.getPath()
    request.session[PROJECT_NAME] = projectName

    provider = ProjectRunsTreeProvider(project)
    runs = formatProvider(provider, "runs")
    request.session['runs'] = runs

    # Get the selected runs stored in BD
    selectedRuns = project_settings.runSelection

    # Get the run mode view (0:list / 1:graph / 2:small graph) stored in BD
    runsView = project_settings.runsView.get()

    # load the protocol tree current active
    htmlTree = loadProtTree(project, serviceName)

    # get the choices to load protocol trees
    choices = project.getProtocolViews()

    # get the choice current
    choiceSelected = choices.index(project.getCurrentProtocolView().text.get())

    context = {
        CTX_PROJECT_NAME: projectName,
        'view': 'protocols',
        'editTool': getResourceIcon('edit_toolbar'),
        'copyTool': getResourceIcon('copy_toolbar'),
        'deleteTool': getResourceIcon('delete_toolbar'),
        'browseTool': getResourceIcon('browse_toolbar'),
        'stopTool': getResourceIcon('stop_toolbar'),
        'analyzeTool': getResourceIcon('analyze_toolbar'),
        'treeTool': getResourceIcon('tree_toolbar'),
        'listTool': getResourceIcon('list_toolbar'),
        'graph_utils': getResourceJs('graph_utils'),
        'project_content_utils': getResourceJs('project_content_utils'),
        'jquery_cookie': getResourceJs('jquery_cookie'),
        'jquery_treeview': getResourceJs('jquery_treeview'),
        'project_content_css': getResourceCss('project_content'),
        'protTreeHtml': htmlTree,
        'choices': choices,
        'choiceSelected': choiceSelected,
        'runs': runs,
        'columns': provider.getColumns(),
        'runsView': runsView,
        'selectedRuns': selectedRuns,
        SERVICE_NAME: serviceName
    }

    context = base_flex(request, context)

    return context
Exemple #5
0
def delete_project(request):
    manager = Manager()

    if request.is_ajax():
        projectName = getVarFromRequest(request, PROJECT_NAME)
        manager.deleteProject(projectName)

    return HttpResponse(content_type='application/javascript')
Exemple #6
0
def base_wiz(request, context):
    context_base = {
        'general_style': getResourceCss('general'),
        'wizard_style': getResourceCss('wizard'),
        'jquery_ui_style': getResourceCss('jquery_ui'),
        'font_awesome': getResourceCss('font_awesome'),
        'jquery': getResourceJs('jquery'),
        'jquery_ui': getResourceJs('jquery_ui'),
        'jquery_ui_touch': getResourceJs('jquery_ui_touch'),
        'wizard_utils': getResourceJs('wizard_utils'),
        'raphael': getResourceJs('raphael'),
        'utils': getResourceJs('utils'),
        CTX_PROJECT_NAME: getVarFromRequest(request, PROJECT_NAME),
        SERVICE_NAME: getVarFromRequest(request, SERVICE_NAME),
        'loading': getResourceIcon('loading'),
    }

    context = VARS_base(request, context)
    context.update(context_base)
    return context
Exemple #7
0
def data_content(request):
    projectName = getVarFromRequest(request, PROJECT_NAME)

    manager = Manager()
    request.session[CTX_PROJECT_PATH] = manager.getProjectPath(projectName)
    # project = loadProject(request)

    context = {CTX_PROJECT_NAME: projectName,
               'editTool': getResourceIcon('edit_toolbar'),
               'graph_utils': getResourceJs('graph_utils'),
               'project_content_utils': getResourceJs('project_content_utils'),
               'data_content_utils': getResourceJs('data_content_utils'),
               'jquery_cookie': getResourceJs('jquery_cookie'),
               'jquery_treeview': getResourceJs('jquery_treeview'),
               'project_content_css': getResourceCss('project_content'),
               'view': 'data'
               }

    context = base_flex(request, context)

    return render_to_response('data_content/data_content.html', context)
def contextForm(request):
    from views_base import base_form
    from django.core.context_processors import csrf
    from views_util import getResourceCss, getResourceIcon, getResourceJs, getResourceLogo
    from pyworkflow.protocol.params import Group, Line
    
    project, protocol = loadProtocolProject(request, requestType='GET')
    action = request.GET.get('action', None)
    paramProt = request.GET.get('paramProt', None)
    protRunIdViewer = request.GET.get('protRunIdViewer', None)
    
    # Patch : to fix the relion dynamic way to generate the viewer form
    #         For this is necessary to call setProtocol method
    if protRunIdViewer is not None:
        protocol_parent = project.getProtocol(int(protRunIdViewer))
        protocol.setProtocol(protocol_parent)
    
    hosts = project.getHostNames()
    print "Host in the project: ", hosts
    
    visualize = 0
    
    viewerDict = None
    if action == 'visualize':
        visualize = 1
        viewerDict = protocol._getVisualizeDict()
    elif action == 'protSimple':
        visualize = 2
    elif action == 'copy':
        protocol = project.copyProtocol(protocol)
        
    package = protocol.getClassPackage()
    logoPath = ''
    path = getattr(package, '_logo', '')
    if path != '': 
        logoPath = getResourceLogo(path)
            
    wizards = findWizardsWeb(protocol)
    
    protocol.htmlCitations = parseText(protocol.citations())
    protocol.htmlDoc = parseText(protocol.getDoc())
    
    for section in protocol._definition.iterSections():
        for paramName, param in section.iterParams():
            protVar = getattr(protocol, paramName, None)
            if protVar is None:
#                raise Exception("_fillSection: param '%s' not found in protocol" % paramName)
               
                # GROUP PARAM
                if isinstance(param, Group):
                    for paramGroupName, paramGroup in param.iterParams():
                        protVar = getattr(protocol, paramGroupName, None)
                        
                        # LINE PARAM
                        if isinstance(paramGroup, Line):
                            for paramLineName, paramLine in paramGroup.iterParams():
                                protVar = getattr(protocol, paramLineName, None)
                                
                                if protVar is None:
                                    pass
                                else:
                                    paramLine = PreprocessParamForm(request, paramLine, paramLineName, wizards, viewerDict, visualize, protVar)                  
                                
                            # PATCH: This is applied to all the params in the line, maybe just need for the first one.
                            for name, _ in paramGroup.iterParams():
                                wizParamName = name
                                if wizParamName in wizards:
                                    paramGroup.hasWizard = True
                                    paramGroup.wizardClassName = wizards[wizParamName].__name__
                                
                            if visualize == 1:
                                if paramGroupName in viewerDict:
                                    paramGroup.hasViewer = True
                            
                            if not paramGroup.help.empty():
                                paramGroup.htmlHelp = parseText(paramGroup.help.get())
                                
                            paramGroup.htmlCond = paramGroup.condition.get()
                            paramGroup.htmlDepend = ','.join(paramGroup._dependants)
                            paramGroup.htmlCondParams = ','.join(paramGroup._conditionParams)   
                            
                        elif protVar is None:
                            pass
                        else:
                            paramGroup = PreprocessParamForm(request, paramGroup, paramGroupName, wizards, viewerDict, visualize, protVar)
                
                    param.htmlCond = param.condition.get()
                    param.htmlDepend = ','.join(param._dependants)
                    param.htmlCondParams = ','.join(param._conditionParams)   
                            
                # LINE PARAM
                if isinstance(param, Line):
                    for paramLineName, paramLine in param.iterParams():
                        protVar = getattr(protocol, paramLineName, None)
                        
                        if protVar is None:
                            pass
                        else:
                            paramLine = PreprocessParamForm(request, paramLine, paramLineName, wizards, viewerDict, visualize, protVar)                  
                        
                    # PATCH: This is applied to all the params in the line, maybe just need for the first one.
                    for name, _ in param.iterParams():
                        wizParamName = name
                        if wizParamName in wizards:
                            param.hasWizard = True
                            param.wizardClassName = wizards[wizParamName].__name__
                        
                    if visualize == 1:
                        if paramName in viewerDict:
                            param.hasViewer = True
                    
                    if not param.help.empty():
                        param.htmlHelp = parseText(param.help.get())
                        
                    param.htmlCond = param.condition.get()
                    param.htmlDepend = ','.join(param._dependants)
                    param.htmlCondParams = ','.join(param._conditionParams)   
                                     
            else:
                # OTHER PARAM
                param = PreprocessParamForm(request, param, paramName, wizards, viewerDict, visualize, protVar)
    
    context = {SERVICE_NAME: getVarFromRequest(request, SERVICE_NAME),
               CTX_PROJECT_NAME: project.getShortName(),
               'protocol': protocol,
               'package_logo': logoPath,
               'protRunIdViewer': protRunIdViewer,
               'definition': protocol._definition,
               'visualize': visualize,
               'paramProt': paramProt,
               'favicon': getResourceIcon('favicon'),
               'comment': getResourceIcon('edit_toolbar'),
               'jquery_ui_css': getResourceCss('jquery_ui'),
               'wizard': getResourceIcon('wizard'),
               'protocol_form_utils': getResourceJs('protocol_form_utils'),
               'hosts': hosts,
               'comment': parseText(protocol.getObjComment()),
               'showHost': True,
               'showParallel': True
               }
    
    # Update the context dictionary with the special params
    for paramName in SPECIAL_PARAMS:
        context[paramName] = protocol.getAttributeValue(paramName, '')

    # Cross Site Request Forgery protection is need it
    context.update(csrf(request))
    context = base_form(request, context)

    return context