Пример #1
0
def reset_data(request):
    """ 15.07.09: This needs to be broken into different sets of options for collections, basic mode """
    if CIV_template.BasicMode:
        CIV_template.create_TempData_header()
        return render(request,'djciv_data/basic_form.html',  {'form_content' : ActiveTemplate})
    else:
        Case.objects.all().delete()
        return render(request,'djciv_data/select_collection.html',{'files' : CollectionList})
Пример #2
0
def read_template(request):
    """ main routine for setting up a template: reads a file, checks for errors, and then either renders the form or 
        lists the errors """
    global ActiveTemplate
    CIV_template.init_template()
    if 'codername' in request.POST:
        CIV_template.codername = request.POST['codername']        
    if 'template_name' in request.FILES:
#        print('RT2:',request.FILES['template_name'])        
        st = request.FILES['template_name']
    else:
#        print('RT: Use demo')
        st = open('djciv_data/static/djciv_data/CIVET.demo.template.txt','r')
    thecontent = ''
    commln = CIV_template.get_commlines(st)
    while len(commln) > 0:
        thecontent += CIV_template.do_command(commln)
        commln = CIV_template.get_commlines(st)

#    print('thecontent:',thecontent)
    if len(CIV_template.SaveList) == 0:
        thecontent += '~Error~<p>A "save:" command is required in the template<br>\n'
    else:
        misslist = []
        for ele in CIV_template.SaveList:
            if ele not in CIV_template.VarList:
                misslist.append(ele)
        if len(misslist) > 0:
            thecontent += '~Error~<p>The following variables are in the "save:" command but were not declared in a data field<br>' + str(misslist) + '\n'

    if '~Error~' in thecontent:
        errortext = ''
        indx = thecontent.find('~Error~')
        while indx >= 0:
            indy = thecontent.find('\n',indx)
            errortext += thecontent[indx+7:indy+1]
            indx = thecontent.find('~Error~',indy)
        return render(request,'djciv_data/template_error.html', {'form_content' :  errortext})
    else:
        ActiveTemplate = thecontent
        CIV_template.create_TempData_header()
        CIV_template.BasicMode = True
        return render(request,'djciv_data/basic_form.html', {'form_content' : thecontent})