コード例 #1
0
ファイル: views.py プロジェクト: civet-software/CIVET-Django
def save_and_next(request):
    global ActiveCollection, CoderText
    update_values(request)
    civet_form.save_case(ActiveCollection, Deletelist)
#    print('SaNext-Mk1:',CollectionList)
    idx = CollectionList.index(ActiveCollection) + 1
    if idx < len(CollectionList):
        ActiveCollection = CollectionList[idx] 
        civet_form.FormFields = deepcopy(InitalFormVals)
        if civet_settings.SKIP_EDITING or civet_settings.NEVER_ANNOTATE:
            CoderText = ''
            return HttpResponseRedirect('code_collection')
        else:   
            return render(request,'djciv_data/civet_ckeditor.html', get_CKEditor_context())
    else:
        return HttpResponse(civet_utilities.unimplemented_feature("you've reached the end of the list"))
コード例 #2
0
ファイル: views.py プロジェクト: civet-software/CIVET-Django
def add_workspace_comments(request):
    return HttpResponse(civet_utilities.unimplemented_feature("add_workspace_comments"))
コード例 #3
0
ファイル: views.py プロジェクト: civet-software/CIVET-Django
def edit_metadata(request):
    return HttpResponse(civet_utilities.unimplemented_feature("edit_metadata"))
コード例 #4
0
ファイル: views.py プロジェクト: civet-software/CIVET-Django
def download_workspace_data(request, select_variables = False):
    """ writes all cases to a tab-delimited file """
    # need a time option here to just get the new cases
#    print('DWD0-entry:')

    def get_missing(textstr):
        if civet_settings.USE_TEXT_FOR_MISSING:
            return textstr
        else:
            return civet_settings.MISSING_VALUE
    
    if select_variables: 
        return HttpResponse(civet_utilities.unimplemented_feature("download selected variables"))
        # in final routing, this probably should go to a dialog for selecting a variable list, which will then be passed
        # here either as a global or arg: hmmm, yeah, so we will still have something like a if select but now select will contain that list
    else:
        writelist = civet_form.SaveList
        
#    print('DWD0:',writelist)
    tempdata = ''
    usevalue = []
    for ka, savename in enumerate(civet_form.SaveList): # write variable labels
        if '[' in civet_form.SaveTypes[ka]:
            usevalue.append(True)
            parts = civet_form.SaveTypes[ka].partition('[')
            varname = parts[2][:parts[2].find(']')].strip()
            if len(varname) == 0:
                varname = savename
            tempdata += varname + '\t'  # there was a check earlier that this existed
        else:
            tempdata += savename + '\t'
            usevalue.append(False)

    tempdata = tempdata[:-1] + '\n'     
    for acase in Case.objects.all():
        values = ast.literal_eval(acase.casevalues)  # read the dictionary as a dictionary init; probably should be a case method
#        print('DD-Mk-1:',values)
#        print('DD-Mk-2:', civet_form.SaveList)
        if '_discard_' in values and values['_discard_']:
            continue
        if '_delete_' in values:
            continue
        for ka, avar in enumerate(writelist):
            """if avar in values:
                print(' >> :',values[avar])
            else:
                print(' >> : variable not found') """               
            if avar in civet_form.SpecialVarList: 
                tempdata += civet_form.get_special_var(avar) + '\t'
            elif avar in civet_form.ConstVarDict.keys(): 
                tempdata += civet_form.ConstVarDict[avar] + '\t'
            elif avar in values:
                if values[avar]:  # go to missing if a null string
                    if usevalue[ka]:
                        if ']' == values[avar].rstrip()[-1]:
                            try:
                                thevalue = values[avar][values[avar].find('[')+1:values[avar].index(']')].strip()
                            except:
                                thevalue = get_missing(values[avar])
                        else:
                                thevalue = get_missing(values[avar]) 
                        tempdata += thevalue +'\t'
                    else:
                        if ']' == values[avar].rstrip()[-1]:
                            tempdata +=  values[avar][:values[avar].find('[')].strip() +'\t'
                        else:
                            tempdata +=  values[avar] +'\t'
                else:
                    thevalue = get_missing('')
            else:
                tempdata += avar + ' unchecked\t'  # shouldn't hit this, but probably still worth an error check
        tempdata = tempdata[:-1] + '\n'
    curfilename = request.POST['filename']
    if curfilename[-4:] != ".txt":
        curfilename += '.txt'
#    curfilename = 'test_data1.txt'  # debug
#    print('DD1:',curfilename)
    response = HttpResponse(content_type='text/plain')
    response['Content-Disposition'] = 'attachment; filename="' + curfilename + '"'
    response.write(tempdata)        
    return(response)