def __init__(self, *args, **kwargs): super(ExportDataForm, self).__init__(*args, **kwargs) choices = [] for species in Species.objects.values('wid', 'name').all(): choices.append((species['wid'], species['name'], )) self.fields['species'].choices = choices model_types = getObjectTypes() models = getModels() choices = [] for model_type in model_types: choices.append((model_type, models[model_type]._meta.verbose_name_plural, )) self.fields['model_type'].choices = choices self.fields['model_type'].initial = model_types
def __init__(self, *args, **kwargs): super(ExportDataForm, self).__init__(*args, **kwargs) choices = [] for species in Species.objects.values('wid', 'name').all(): choices.append(( species['wid'], species['name'], )) self.fields['species'].choices = choices model_types = getObjectTypes() models = getModels() choices = [] for model_type in model_types: choices.append(( model_type, models[model_type]._meta.verbose_name_plural, )) self.fields['model_type'].choices = choices self.fields['model_type'].initial = model_types
def test_data_model(self): for name, model in helpers.getModels().iteritems(): validate_fields(model) validate_model(model) for tmp in helpers.getEntryDatas(): validate_model(tmp[1])
field.model.__name__, field_name, name_obj, field_name, ) else: if field.name != 'sequence': return '\t' * depth + '{{ %s.%s }}\n' % ( name_obj, field_name, ) return '' for modelname, model in getModels().iteritems(): #make full text template filename = '%s/templates/search/indexes/%s/%s_%s.txt' % ( settings.ROOT_DIR, model._meta.app_label, modelname.lower(), 'text') f = open(filename, 'w') f.write('{% load templatetags %}\n') for field in getModelDataFields(model): f.write(str(format_field_for_indexing(field=field))) for related in model._meta.get_all_related_objects( ) + model._meta.get_all_related_many_to_many_objects(): if related.get_accessor_name() != '+': f.write(str(format_field_for_indexing(related=related))) f.close() #create index class if issubclass(model, SpeciesComponent):
elif isinstance(field, ForeignKey): if (depth <= 0) or (not issubclass(field_model, Entry)): result = '\t'*depth + '{%% with %s=%s.%s %%}\n' % (name_child, name_obj, field_name, ) for subfield in field_model._meta.fields + field_model._meta.many_to_many: result += format_field_for_indexing(field=subfield, depth=depth+1) result += '\t'*depth + '{% endwith %}\n' return result elif (field.choices is not None) and (len(field.choices) > 0) and (not isinstance(field, (BooleanField, NullBooleanField))): return '\t'*depth + '{%% get_choice_verbose_name "%s" "%s" "%s" %s.%s %%}\n' % (field.model._meta.app_label, field.model.__name__, field_name, name_obj, field_name, ) else: if field.name != 'sequence': return '\t'*depth + '{{ %s.%s }}\n' % (name_obj, field_name, ) return '' for modelname, model in getModels().iteritems(): #make full text template filename = '%s/templates/search/indexes/%s/%s_%s.txt' % ( settings.ROOT_DIR, model._meta.app_label, modelname.lower(), 'text') f = open(filename, 'w') f.write('{% load templatetags %}\n') for field in getModelDataFields(model): f.write(str(format_field_for_indexing(field=field))) for related in model._meta.get_all_related_objects() + model._meta.get_all_related_many_to_many_objects(): if related.get_accessor_name() != '+': f.write(str(format_field_for_indexing(related=related))) f.close() #create index class if issubclass(model, SpeciesComponent): index = type(model.__class__.__name__ + 'Index', (SpeciesComponentIndex, ), {})