def create_label(self, item): label = Element("div") label.add_class("entry_label") label.append(self.get_item_label(item)) if self.filter_item \ and self._is_accessible(item) != ACCESSIBLE: label.add_class("filtered") else: url = self.get_item_url(item) if url is not None: label.tag = "a" label["href"] = url return label
def create_new_button(self): new_button = Element(class_name="ItemSelector-button new") instantiable_types = set( content_type for content_type in ([self.member.type] + list(self.member.type.derived_schemas())) if content_type.visible and content_type.instantiable and get_current_user().has_permission(CreatePermission, target=content_type)) if len(instantiable_types) > 1: new_button.add_class("selector") label = Element("span", class_name="label") new_button.append(label) container = Element(class_name="selector_content") new_button.append(container) content_type_tree = templates.new("woost.views.ContentTypeTree") content_type_tree.root = self.member.type content_type_tree.filter_item = instantiable_types.__contains__ @extend(content_type_tree) def create_label(tree, content_type): label = call_base(content_type) label.tag = "button" label["type"] = "submit" label["name"] = "relation-new" label[ "value"] = self.member.name + "-" + content_type.full_name return label container.append(content_type_tree) else: new_button.tag = "button" new_button["type"] = "submit" new_button["name"] = "relation-new" new_button["value"] = \ self.member.name + "-" + list(instantiable_types)[0].full_name label = new_button label.append(translations("woost.views.ItemSelector new")) return new_button
def create_label(self, item): if self.should_link(item): label = Element("a") label["href"] = self.get_item_uri(item) else: label = Element("span") label.append(self.get_item_label(item)) if self.emphasized_selection and item is self.selection: if label.tag == "a": label = Element("strong", children=[label]) else: label.tag = "strong" return label
def create_field(self, member): hidden = self.get_member_hidden(member) entry = Element("tr" if self.table_layout else "div") entry.field_instances = [] if hidden: entry.tag = None else: entry.add_class("field") entry.add_class(member.name + "_field") if member.required: entry.add_class("required") def create_instance(language=None): if hidden: with language_context(language): return self.create_hidden_input(self.data, member) else: instance = self.create_field_instance(member, language) entry.field_instances.append(instance) return instance if member.translated: entry.add_class("translated") if not hidden and not self.redundant_translation_labels: entry.append(self.create_label(member)) for language in (self.translations if self.translations is not None else (get_language(), )): field_instance = create_instance(language) field_instance.add_class(language) entry.append(field_instance) else: entry.append(create_instance()) return entry