def indiv2foy(varname, quifoy): ''' Yields the field of the foy corresponding to the varname ''' convert = foy2of_dict() value = None for field in convert.keys(): if field2quifoy(field) == quifoy: if convert[field] == varname: value = field return value
def get_declar3(self, form=None, idfoy=0): ''' Gets declar values in compo.scenario from Declar3Form ''' declar = self.scenario.declar[idfoy] # Build a dict of individulas present on the declar cleaned_indiv = extract_foy_indiv(self.scenario, idfoy=idfoy) convert = foy2of_dict() data = form.cleaned_data for field, value in data.iteritems(): if field in convert.keys(): quifoy = field2quifoy(field) varname = convert[field] for person in cleaned_indiv.itervalues(): if person['quifoy'] == quifoy: person[varname] = value else: declar[field] = value
def get_declar3(self, form = None, idfoy = 0): ''' Gets declar values in compo.scenario from Declar3Form ''' declar = self.scenario.declar[idfoy] # Build a dict of individulas present on the declar cleaned_indiv = extract_foy_indiv(self.scenario, idfoy= idfoy) convert = foy2of_dict() data = form.cleaned_data for field, value in data.iteritems(): if field in convert.keys(): quifoy = field2quifoy(field) varname = convert[field] for person in cleaned_indiv.itervalues(): if person['quifoy'] == quifoy: person[varname] = value else: declar[field] = value