def test_custom_selected_tags(self): widget = LabelWidget(model=MyCustomTag) return_list = widget.tag_list([t.name for t in self.post.tags.all()]) self.assertEqual( ["Coffee"], [tag[0] for tag in return_list if tag[1] == "selected"] ) self.assertEqual(["tea"], [tag[0] for tag in return_list if tag[1] == ""])
def test_custom_selected_tags(self): widget = LabelWidget(model=MyCustomTag) return_list = widget.tag_list([t.name for t in self.post.tags.all()]) self.assertEqual( ["Coffee"], [tag[0] for tag in return_list if tag[1] == "selected"]) self.assertEqual(["tea"], [tag[0] for tag in return_list if tag[1] == ""])
def test_selected_tags(self): widget = LabelWidget() return_list = widget.tag_list( [t.name for t in self.article.tags.all()]) self.assertEqual( ["Python"], [tag[0] for tag in return_list if tag[1] == 'selected']) self.assertEqual(["Django", "Advanced Computering"], [tag[0] for tag in return_list if tag[1] == ''])
def test_selected_tags(self): widget = LabelWidget() return_list = widget.tag_list([t.name for t in self.article.tags.all()]) self.assertEqual( ["Python"], [tag[0] for tag in return_list if tag[1] == "selected"] ) self.assertEqual( ["Django", "Advanced Computering"], [tag[0] for tag in return_list if tag[1] == ""], )
class Meta: model = Post fields = '__all__' widgets = { 'content': RedactorEditor(), 'tags': LabelWidget() }
class ProfileAdminForm(ModelForm): # tags = TagField(required=False, widget=LabelWidget) clusters = TagField( required=False, widget=LabelWidget(model=Cluster), help_text="Clusters the user wants to be included in", )
class AgendaAdminForm(forms.ModelForm): contenido = forms.CharField(widget=TinyMCE( mce_attrs=customize_tinyMCE({ 'width': 980, 'height': 600 }))) tags = TagField(required=False, widget=LabelWidget(model=HierarchicalTag, hierarchical=True)) localidad = TagField(required=False, widget=LabelWidget(model=LocationTag, hierarchical=False)) def __init__(self, *args, **kwargs): super(AgendaAdminForm, self).__init__(*args, **kwargs) init_gallerycon_settings()
class Meta: model = PUC fields = [ "gen_cat", "prod_fam", "prod_type", "description", "tags", "kind" ] readonly_fields = ("num_products", ) widgets = {"tags": LabelWidget(model=PUCTag)}
def test_render_new(self): """Render method shouldn't error out with missing or string tags""" widget = LabelWidget(model=MyCustomTag) widget.render("tags", None, attrs={"id": u"id_tags"}) widget.render("tags", "'My Tag', 'Another tag'", attrs={"id": u"id_tags"})
class Meta: model = PUC fields = [ 'gen_cat', 'prod_fam', 'prod_type', 'description', 'tags', ] readonly_fields = ('num_products', ) widgets = { 'tags': LabelWidget(model=PUCTag), }
class PaginaAdminForm(forms.ModelForm): contenido = forms.CharField( required=False, widget=TinyMCE(mce_attrs=customize_tinyMCE({ 'width': 980, 'height': 600 }))) tags = TagField(required=False, widget=LabelWidget(model=HierarchicalTag, hierarchical=True)) def __init__(self, *args, **kwargs): request = self.request super(PaginaAdminForm, self).__init__(*args, **kwargs) init_gallerycon_settings() if 'parent_id' in request.GET: self.fields['parent'].initial = Pagina.objects.get( pk=request.GET.get('parent_id'))
class RecursoAdminForm(forms.ModelForm): descripcion = forms.CharField( required=False, widget=TinyMCE(mce_attrs=customize_tinyMCE({ 'width': 980, 'height': 300 }))) contenido = forms.CharField( required=False, widget=TinyMCE(mce_attrs=customize_tinyMCE({ 'width': 980, 'height': 800 }))) tags = TagField(required=False, widget=LabelWidget(model=HierarchicalTag, hierarchical=True)) def __init__(self, *args, **kwargs): super(RecursoAdminForm, self).__init__(*args, **kwargs) init_gallerycon_settings()
class Meta: model = ac_models.Hostingprovider fields = "__all__" widgets = { "services": LabelWidget(model=Tag), }
class MultimediaAdminForm(forms.ModelForm): tags = TagField(required=False, widget=LabelWidget(model=HierarchicalTag, hierarchical=True))
class AdvertForm(ModelForm): tags = TagField(required=False, widget=LabelWidget(model=models.HierarchicalTag))
class Meta: model = Recipe fields = '__all__' widgets = { 'tags': LabelWidget() }
class Meta: widgets = {"tags": LabelWidget(model=ActionTags)}
class Meta: widgets = {"tags": LabelWidget(model=QuoteTags)}
def test_initialization(self): customized_widget = LabelWidget(model=MyCustomTag) self.assertEqual(customized_widget.model, MyCustomTag) default_widget = LabelWidget() self.assertEqual(default_widget.model, Tag)