本文整理汇总了Python中avocado.models.DataConcept.description方法的典型用法代码示例。如果您正苦于以下问题:Python DataConcept.description方法的具体用法?Python DataConcept.description怎么用?Python DataConcept.description使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类avocado.models.DataConcept
的用法示例。
在下文中一共展示了DataConcept.description方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from avocado.models import DataConcept [as 别名]
# 或者: from avocado.models.DataConcept import description [as 别名]
def setUp(self):
management.call_command('avocado', 'sync', 'export', quiet=True)
first_name_field = DataField.objects.get_by_natural_key('export', 'employee', 'first_name')
first_name_field.description = 'First Name'
last_name_field = DataField.objects.get_by_natural_key('export', 'employee', 'last_name')
last_name_field.description = 'Last Name'
title_field = DataField.objects.get_by_natural_key('export', 'title', 'name')
title_field.description = 'Employee Title'
salary_field = DataField.objects.get_by_natural_key('export', 'title', 'salary')
salary_field.description = 'Salary'
is_manager_field = DataField.objects.get_by_natural_key('export', 'employee', 'is_manager')
is_manager_field.description = 'Is a Manager?'
[x.save() for x in [first_name_field, last_name_field, title_field,
salary_field, is_manager_field]]
employee_concept = DataConcept()
employee_concept.name = 'Employee'
employee_concept.description = 'A Single Employee'
employee_concept.save()
DataConceptField(concept=employee_concept, field=first_name_field, order=1).save()
DataConceptField(concept=employee_concept, field=last_name_field, order=2).save()
DataConceptField(concept=employee_concept, field=is_manager_field, order=3).save()
DataConceptField(concept=employee_concept, field=title_field, order=4).save()
DataConceptField(concept=employee_concept, field=salary_field, order=5).save()
self.concepts = [employee_concept]
self.query = models.Employee.objects.values_list('first_name', 'last_name',
'is_manager', 'title__name', 'title__salary')
示例2: setUp
# 需要导入模块: from avocado.models import DataConcept [as 别名]
# 或者: from avocado.models.DataConcept import description [as 别名]
def setUp(self):
management.call_command("avocado", "init", "tests", quiet=True)
first_name_field = DataField.objects.get_by_natural_key("tests", "employee", "first_name")
first_name_field.description = "First Name"
last_name_field = DataField.objects.get_by_natural_key("tests", "employee", "last_name")
last_name_field.description = "Last Name"
title_field = DataField.objects.get_by_natural_key("tests", "title", "name")
title_field.description = "Employee Title"
salary_field = DataField.objects.get_by_natural_key("tests", "title", "salary")
salary_field.description = "Salary"
is_manager_field = DataField.objects.get_by_natural_key("tests", "employee", "is_manager")
is_manager_field.description = "Is a Manager?"
[x.save() for x in [first_name_field, last_name_field, title_field, salary_field, is_manager_field]]
employee_concept = DataConcept()
employee_concept.name = "Employee"
employee_concept.description = "A Single Employee"
employee_concept.save()
DataConceptField(concept=employee_concept, field=first_name_field, order=1).save()
DataConceptField(concept=employee_concept, field=last_name_field, order=2).save()
DataConceptField(concept=employee_concept, field=is_manager_field, order=3).save()
DataConceptField(concept=employee_concept, field=title_field, order=4).save()
DataConceptField(concept=employee_concept, field=salary_field, order=5).save()
self.concepts = [employee_concept]
self.query = models.Employee.objects.values_list(
"first_name", "last_name", "is_manager", "title__name", "title__salary"
)
示例3: _migrate_concept
# 需要导入模块: from avocado.models import DataConcept [as 别名]
# 或者: from avocado.models.DataConcept import description [as 别名]
def _migrate_concept(self, model, migrate_func, **options):
no_input = options.get('no_input')
total_migrated = 0
for lc in model.objects.iterator():
field_nks = list(lc.fields.values('app_name', 'model_name',
'field_name').distinct())
field_cond = Q()
for f in field_nks:
field_cond = field_cond | Q(**f)
fields = DataField.objects.filter(field_cond).distinct()
# Mismatch of fields from new to old
if len(fields) != len(field_nks):
print('One or more fields mismatched for "{0}". '
'Skipping...'.format(lc))
continue
matches = DataConcept.objects.filter(name=lc.name)
# Filter concepts by existence of fields
for f in fields:
matches = matches.filter(fields__app_name=f.app_name,
fields__model_name=f.model_name,
fields__field_name=f.field_name)
num = len(matches)
if num > 1:
print('{0} have the same name and fields. '
'Skipping...'.format(num))
continue
if num == 1:
c = matches[0]
existing = True
if not no_input:
override = True
while True:
response = raw_input(u'Match found for "{0}". '
'Override? [n/Y] '.format(c))
if not response:
break
if response.lower() == 'n':
override = False
break
if not override:
continue
else:
c = DataConcept(queryable=False, viewable=False)
existing = False
c.name = lc.name
c.order = lc.order
c.published = lc.is_public
# This looks odd, but this handles choosing the longer of the two
# descriptions for criterion and column if both exist.
if not c.description or lc.description and \
len(lc.description) > len(c.description):
c.description = lc.description
if lc.category:
try:
kwargs = {
'name__iexact': lc.category.name,
}
# Filter by parent if one exists since categories with the
# same name can exists as sub-categories.
if lc.category.parent_id:
kwargs['parent__name'] = lc.category.parent.name
c.category = DataCategory.objects.get(**kwargs)
except DataCategory.DoesNotExist:
pass
# Apply migration specific function to concept from legacy concept
migrate_func(c, lc)
# Save for foreign key references to concept fields
c.save()
cfs = []
if not existing:
lcfs = list(lc.conceptfields.select_related('field'))
# Dict of legacy concept fields to the new field it
# corresponds to
lcf_map = {}
for lcf in lcfs:
for f in fields:
# Match and break
if lcf.field.natural_key() == f.natural_key():
lcf_map[lcf.pk] = f
break
#.........这里部分代码省略.........