Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
questionset.key = element['key'] or ''
questionset.comment = element['comment'] or ''
if element['attribute']:
try:
questionset.attribute = Attribute.objects.get(uri=element['attribute'])
except Attribute.DoesNotExist:
pass
questionset.is_collection = element['is_collection']
questionset.order = element['order']
for lang_code, lang_string, lang_field in get_languages():
set_lang_field(questionset, 'title', element, lang_code, lang_field)
set_lang_field(questionset, 'help', element, lang_code, lang_field)
set_lang_field(questionset, 'verbose_name', element, lang_code, lang_field)
set_lang_field(questionset, 'verbose_name_plural', element, lang_code, lang_field)
try:
QuestionSetUniquePathValidator(questionset).validate()
except ValidationError as e:
log.info('QuestionSet not saving "%s" due to validation error (%s).', element['uri'], e)
pass
else:
log.info('QuestionSet saving to "%s".', element['uri'])
questionset.save()
questionset.conditions.clear()
if element['conditions'] is not None:
for condition in element['conditions']:
try:
questionset.conditions.add(Condition.objects.get(uri=condition))
questionset.comment = element['comment'] or ''
if element['attribute']:
try:
questionset.attribute = Attribute.objects.get(uri=element['attribute'])
except Attribute.DoesNotExist:
pass
questionset.is_collection = element['is_collection']
questionset.order = element['order']
for lang_code, lang_string, lang_field in get_languages():
set_lang_field(questionset, 'title', element, lang_code, lang_field)
set_lang_field(questionset, 'help', element, lang_code, lang_field)
set_lang_field(questionset, 'verbose_name', element, lang_code, lang_field)
set_lang_field(questionset, 'verbose_name_plural', element, lang_code, lang_field)
try:
QuestionSetUniquePathValidator(questionset).validate()
except ValidationError as e:
log.info('QuestionSet not saving "%s" due to validation error (%s).', element['uri'], e)
pass
else:
log.info('QuestionSet saving to "%s".', element['uri'])
questionset.save()
questionset.conditions.clear()
if element['conditions'] is not None:
for condition in element['conditions']:
try:
questionset.conditions.add(Condition.objects.get(uri=condition))
except Condition.DoesNotExist:
question.uri_prefix = element['uri_prefix'] or ''
question.key = element['key'] or ''
question.comment = element['comment'] or ''
if element['attribute']:
try:
question.attribute = Attribute.objects.get(uri=element['attribute'])
except Attribute.DoesNotExist:
pass
question.is_collection = element['is_collection']
question.order = element['order']
for lang_code, lang_string, lang_field in get_languages():
set_lang_field(question, 'text', element, lang_code, lang_field)
set_lang_field(question, 'help', element, lang_code, lang_field)
set_lang_field(question, 'verbose_name', element, lang_code, lang_field)
set_lang_field(question, 'verbose_name_plural', element, lang_code, lang_field)
question.widget_type = element['widget_type'] or ''
question.value_type = element['value_type'] or ''
question.maximum = element['maximum']
question.minimum = element['minimum']
question.step = element['step']
question.unit = element['unit'] or ''
try:
QuestionUniquePathValidator(question).validate()
except ValidationError as e:
log.info('Question not saving "%s" due to validation error (%s).', element['uri'], e)
pass
else:
question.key = element['key'] or ''
question.comment = element['comment'] or ''
if element['attribute']:
try:
question.attribute = Attribute.objects.get(uri=element['attribute'])
except Attribute.DoesNotExist:
pass
question.is_collection = element['is_collection']
question.order = element['order']
for lang_code, lang_string, lang_field in get_languages():
set_lang_field(question, 'text', element, lang_code, lang_field)
set_lang_field(question, 'help', element, lang_code, lang_field)
set_lang_field(question, 'verbose_name', element, lang_code, lang_field)
set_lang_field(question, 'verbose_name_plural', element, lang_code, lang_field)
question.widget_type = element['widget_type'] or ''
question.value_type = element['value_type'] or ''
question.maximum = element['maximum']
question.minimum = element['minimum']
question.step = element['step']
question.unit = element['unit'] or ''
try:
QuestionUniquePathValidator(question).validate()
except ValidationError as e:
log.info('Question not saving "%s" due to validation error (%s).', element['uri'], e)
pass
else:
log.info('Question saving to "%s".', element['uri'])
def import_task(element):
try:
task = Task.objects.get(uri=element['uri'])
except Task.DoesNotExist:
log.info('Task not in db. Created with uri %s.', element['uri'])
task = Task()
task.uri_prefix = element['uri_prefix'] or ''
task.key = element['key'] or ''
task.comment = element['comment'] or ''
for lang_code, lang_string, lang_field in get_languages():
set_lang_field(task, 'title', element, lang_code, lang_field)
set_lang_field(task, 'text', element, lang_code, lang_field)
if element['start_attribute']:
try:
task.start_attribute = Attribute.objects.get(uri=element['start_attribute'])
except Attribute.DoesNotExist:
pass
if element['end_attribute']:
try:
task.end_attribute = Attribute.objects.get(uri=element['end_attribute'])
except Attribute.DoesNotExist:
pass
task.days_before = element['days_before']
task.days_after = element['days_after']
def import_view(element):
try:
view = View.objects.get(uri=element['uri'])
except View.DoesNotExist:
log.info('View not in db. Created with uri %s.', element['uri'])
view = View()
view.uri_prefix = element['uri_prefix'] or ''
view.key = element['key'] or ''
view.comment = element['comment'] or ''
view.template = element['template'] or ''
for lang_code, lang_string, lang_field in get_languages():
set_lang_field(view, 'title', element, lang_code, lang_field)
set_lang_field(view, 'help', element, lang_code, lang_field)
try:
ViewUniqueKeyValidator(view).validate()
except ValidationError as e:
log.info('View not saving "%s" due to validation error (%s).', element['uri'], e)
pass
else:
log.info('View saving to "%s".', element['uri'])
view.save()
questionset.uri_prefix = element['uri_prefix'] or ''
questionset.key = element['key'] or ''
questionset.comment = element['comment'] or ''
if element['attribute']:
try:
questionset.attribute = Attribute.objects.get(uri=element['attribute'])
except Attribute.DoesNotExist:
pass
questionset.is_collection = element['is_collection']
questionset.order = element['order']
for lang_code, lang_string, lang_field in get_languages():
set_lang_field(questionset, 'title', element, lang_code, lang_field)
set_lang_field(questionset, 'help', element, lang_code, lang_field)
set_lang_field(questionset, 'verbose_name', element, lang_code, lang_field)
set_lang_field(questionset, 'verbose_name_plural', element, lang_code, lang_field)
try:
QuestionSetUniquePathValidator(questionset).validate()
except ValidationError as e:
log.info('QuestionSet not saving "%s" due to validation error (%s).', element['uri'], e)
pass
else:
log.info('QuestionSet saving to "%s".', element['uri'])
questionset.save()
questionset.conditions.clear()
if element['conditions'] is not None:
for condition in element['conditions']:
try: