Ticket #9071: add-r9017-tests.diff
File add-r9017-tests.diff, 2.0 KB (added by , 16 years ago) |
---|
-
tests/regressiontests/admin_widgets/models.py
39 39 >>> from django.contrib.admin.widgets import FilteredSelectMultiple, AdminSplitDateTime 40 40 >>> from django.contrib.admin.widgets import AdminFileWidget, ForeignKeyRawIdWidget, ManyToManyRawIdWidget 41 41 >>> from django.contrib.admin.widgets import RelatedFieldWidgetWrapper 42 >>> from django.contrib.admin import site 43 >>> from django.forms.widgets import Select as SelectWidget 42 44 43 45 Calling conditional_escape on the output of widget.render will simulate what 44 46 happens in the template. This is easier than setting up a template and context … … 101 103 >>> w = ForeignKeyRawIdWidget(rel) 102 104 >>> print w.render('test', core.parent_id, attrs={}) 103 105 <input type="text" name="test" value="86" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Apple</strong> 106 107 108 # Check that RelatedFieldWidgetWrapper doesn'tshow the add image when explicitely 109 # requested 110 >>> site.register(Band) 111 >>> rel = Album._meta.get_field('band').rel 112 >>> w = RelatedFieldWidgetWrapper(SelectWidget(), rel, site, True) 113 >>> print w.render('test', 'test') 114 <select name="test"> 115 </select><a href="../../../admin_widgets/band/add/" class="add-another" id="add_id_test" onclick="return showAddAnotherPopup(this);"> <img src="/media/img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a> 116 117 >>> w = RelatedFieldWidgetWrapper(SelectWidget(), rel, site, False) 118 >>> print w.render('test', 'test') 119 <select name="test"> 120 </select> 121 104 122 """ % { 105 123 'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX, 106 124 'STORAGE_URL': default_storage.url(''), 107 125 }} 126