def create_example(example_info): print( '===================================') try: example = Example.objects.get(title=example_info.title) print( ' Updating Example ' + str(example.example_id) + ': ' + example.title ) example.example_id = example_info.example_id example.order = example_info.order example.rule_category = example_info.rule_category example.permanent_slug = example_info.permanent_slug example.title = example_info.title example.a11y_features = example_info.a11y_features example.keyboard = example_info.keyboard example.title_override = example_info.title_override example.style = example_info.style example.html = example_info.html example.script = example_info.script example.updated_editor = user example.markup.clear() except ObjectDoesNotExist: print(' Creating Example ' + example_info.title ) example = Example( permanent_slug = example_info.permanent_slug, example_id = example_info.example_id, order = example_info.order, rule_category = example_info.rule_category, title = example_info.title, a11y_features = example_info.a11y_features, keyboard = example_info.keyboard, style = example_info.style, html = example_info.html, script = example_info.script) example.save() for m in example_info.markup: example.markup.add(m) example.save() print( ' Saved Example ' + example.title_text + " (" + str(example.example_id) + ")" ) return example
def create(self, project: Project, meta: Dict[Any, Any]) -> Example: return Example( uuid=uuid.uuid4(), project=project, filename=self.filename, upload_name=self.upload_name, text=self.text, meta=meta, )
def create(self, project: Project) -> Example: return Example( uuid=self.uuid, project=project, filename=self.filename, upload_name=self.upload_name, text=None, meta=self.meta, )