示例#1
0
 def test_text_sets_rendered_link_text(self):
     link = link_to_changelist(Person, 'bibliography',
                               text="List bibliography")
     url = "/foo/admin/bar/adminbrowse/book/?author__pid__exact=3"
     title = "List books with this author"
     self.assertEqual(link(self.people[2]).strip(),
         '<span class="changelist-link"><a href="%s" title="%s">List'
         ' bibliography</a></span>' % (url, title))
示例#2
0
class GroupAdmin(AutoBrowseModelAdmin):
    list_display = ('name', 'slug', 'remark', 'grab_article', 'article_num',
                    'rss_url')
    # 在group的修改页面显示它的rss模块
    inlines = [
        RssInline,
    ]
    link_to_changelist(Group, 'related_rss')
示例#3
0
 def test_callable_text_gets_called_with_value(self):
     link = link_to_changelist(Person, 'bibliography',
                               text=lambda x: "List books (%s)" % len(x))
     url = "/foo/admin/bar/adminbrowse/book/?author__pid__exact=3"
     title = "List books with this author"
     self.assertEqual(link(self.people[2]).strip(),
         '<span class="changelist-link"><a href="%s" title="%s">List'
         ' books (2)</a></span>' % (url, title))
示例#4
0
 def test_callable_text_gets_called_with_value(self):
     link = link_to_changelist(Person,
                               'bibliography',
                               text=lambda x: "List books (%s)" % len(x))
     url = "/foo/admin/bar/adminbrowse/book/?author__pid__exact=3"
     title = "List books with this author"
     self.assertEqual(
         link(self.people[2]).strip(),
         '<span class="changelist-link"><a href="%s" title="%s">List'
         ' books (2)</a></span>' % (url, title))
示例#5
0
 def test_text_sets_rendered_link_text(self):
     link = link_to_changelist(Person,
                               'bibliography',
                               text="List bibliography")
     url = "/foo/admin/bar/adminbrowse/book/?author__pid__exact=3"
     title = "List books with this author"
     self.assertEqual(
         link(self.people[2]).strip(),
         '<span class="changelist-link"><a href="%s" title="%s">List'
         ' bibliography</a></span>' % (url, title))
示例#6
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Genre, 'collection', "novels")
     self.assertEqual(link.short_description, "novels")
示例#7
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Person, 'bibliography', "novels")
     self.assertEqual(link.short_description, "novels")
示例#8
0
 def setUp(self):
     self.people = Person.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Person, 'bibliography')
示例#9
0
 def setUp(self):
     self.people = Person.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Person, 'bibliography')
示例#10
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Book, 'categories', "genres")
     self.assertEqual(link.short_description, "genres")
示例#11
0
 def setUp(self):
     self.one_to_many = link_to_changelist(User, 'logentry_set')
     self.many_to_many = link_to_changelist(Group, 'user_set')
示例#12
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Genre, 'collection', "novels")
     self.assertEqual(link.short_description, "novels")
示例#13
0
 def test_html_for_empty_text_defauls_to_empty_string(self):
     link = link_to_changelist(Person, 'bibliography', text="")
     self.assertEqual(link(self.people[2]).strip(), "")
示例#14
0
 def setUp(self):
     self.genres = Genre.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Genre, 'collection')
示例#15
0
 def test_html_for_empty_text_defauls_to_empty_string(self):
     link = link_to_changelist(Person, 'bibliography', text="")
     self.assertEqual(link(self.people[2]).strip(), "")
示例#16
0
 def test_default_sets_html_for_empty_text(self):
     link = link_to_changelist(Person, 'bibliography', default="No books")
     self.assertEqual(link(self.people[0]).strip(), "No books")
示例#17
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Person, 'bibliography', "novels")
     self.assertEqual(link.short_description, "novels")
示例#18
0
 def test_default_sets_html_for_empty_text(self):
     link = link_to_changelist(Person, 'bibliography', default="No books")
     self.assertEqual(link(self.people[0]).strip(), "No books")
示例#19
0
 def test_default_sets_html_for_empty_set(self):
     link = link_to_changelist(Genre, 'collection', default="No books")
     self.assertEqual(link(self.genres[4]).strip(), "No books")
示例#20
0
 def setUp(self):
     self.genres = Genre.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Genre, 'collection')
示例#21
0
 def setUp(self):
     self.one_to_many = link_to_changelist(User, 'logentry_set')
     self.many_to_many = link_to_changelist(Group, 'user_set')
示例#22
0
 def test_default_sets_html_for_empty_set(self):
     link = link_to_changelist(Genre, 'collection', default="No books")
     self.assertEqual(link(self.genres[4]).strip(), "No books")
示例#23
0
 def setUp(self):
     self.genres = Genre.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Book, 'categories')
示例#24
0
 def setUp(self):
     self.genres = Genre.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Book, 'categories')
示例#25
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Book, 'categories', "genres")
     self.assertEqual(link.short_description, "genres")
示例#26
0
 def test_default_sets_html_for_empty_set(self):
     link = link_to_changelist(Book, 'categories', default="No genres")
     self.assertEqual(link(self.books[5]).strip(), "No genres")
示例#27
0
 def test_default_sets_html_for_empty_set(self):
     link = link_to_changelist(Book, 'categories', default="No genres")
     self.assertEqual(link(self.books[5]).strip(), "No genres")