Exemplo n.º 1
0
def list_tags(request, project):
    if request.method == 'POST':  # user define a tag name (by clicking it)
        ajaxTempOb = AjaxTemplate(project, request.POST)
        ajaxTempOb.filter_search(request.POST)
        ajaxTempOb.init_object_list()
        dic = ajaxTempOb.getDict()
        return render_to_response('content.html', dic)
    else:
        return render_to_response('tag_list.html', {
            'tags_list': Tag.objects.all(),
            'project_name': project
        })
Exemplo n.º 2
0
def search(request, project):
    ajaxTempOb = AjaxTemplate(project, request.POST)
    if request.POST.has_key(
            'fulltext_inquiry'):  # using the input #search_subnav
        ajaxTempOb.filter_search(request.POST)
        ajaxTempOb.init_object_list(ajaxTempOb.page)
        return render_to_response('content.html', ajaxTempOb.getDict())
    else:  # using the form
        if ajaxTempOb.form.is_valid():
            ajaxTempOb.filter_search(
                ajaxTempOb.form.cleaned_data
            )  # taking into consideration the search form
            ajaxTempOb.init_object_list(
                ajaxTempOb.page)  # taking into consideration pagination
            # content.html is a part of record_list.html
            return render_to_response('content.html', ajaxTempOb.getDict())
        else:
            return HttpResponse('search form is not valid')
Exemplo n.º 3
0
def run_sim(request, project):
    if request.POST.has_key('content'):  # save the edited argument file
        content = request.POST.get(
            'content', False)  # in case user changed the argument file
        arg_file = request.POST.get('arg_file', False)
        if os.name == 'posix':
            fow = open(os.getcwd() + '/' + arg_file, 'w')
        else:
            fow = open(os.getcwd() + '\\' + arg_file, 'w')
        fow.write(content)
        fow.close()
        return HttpResponse('ok')
    else:  # run computation
        run_opt = {
            '--label': request.POST.get('label', False),
            '--reason': request.POST.get('reason', False),
            '--tag': request.POST.get('tag', False),
            'exec': request.POST.get('execut', False),
            '--main': request.POST.get('main_file', False),
            'args': request.POST.get('args', False)
        }
        options_list = []
        for key, item in run_opt.iteritems():
            if item:
                if key == 'args':
                    options_list.append(item)
                elif key == 'exec':
                    executable = str(os.path.basename(item))
                    if '.exe' in executable:
                        executable = executable.split('.')[0]
                    options_list.append('='.join(['--executable', executable]))
                else:
                    options_list.append('='.join([key, item]))
        run(options_list)
        ajaxTempOb = AjaxTemplate(project)
        ajaxTempOb.init_object_list(1)  # taking into consideration pagination
        if len(Record.objects.filter(project__id=project)) == 1:
            return HttpResponse('OK')
        else:
            return render_to_response('content.html', ajaxTempOb.getDict())