Beispiel #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))
Beispiel #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')
Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #6
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Genre, 'collection', "novels")
     self.assertEqual(link.short_description, "novels")
Beispiel #7
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Person, 'bibliography', "novels")
     self.assertEqual(link.short_description, "novels")
Beispiel #8
0
 def setUp(self):
     self.people = Person.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Person, 'bibliography')
Beispiel #9
0
 def setUp(self):
     self.people = Person.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Person, 'bibliography')
Beispiel #10
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Book, 'categories', "genres")
     self.assertEqual(link.short_description, "genres")
Beispiel #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')
Beispiel #12
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Genre, 'collection', "novels")
     self.assertEqual(link.short_description, "novels")
Beispiel #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(), "")
Beispiel #14
0
 def setUp(self):
     self.genres = Genre.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Genre, 'collection')
Beispiel #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(), "")
Beispiel #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")
Beispiel #17
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Person, 'bibliography', "novels")
     self.assertEqual(link.short_description, "novels")
Beispiel #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")
Beispiel #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")
Beispiel #20
0
 def setUp(self):
     self.genres = Genre.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Genre, 'collection')
Beispiel #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')
Beispiel #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")
Beispiel #23
0
 def setUp(self):
     self.genres = Genre.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Book, 'categories')
Beispiel #24
0
 def setUp(self):
     self.genres = Genre.objects.all()
     self.books = Book.objects.all()
     self.link = link_to_changelist(Book, 'categories')
Beispiel #25
0
 def test_short_description_sets_short_description(self):
     link = link_to_changelist(Book, 'categories', "genres")
     self.assertEqual(link.short_description, "genres")
Beispiel #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")
Beispiel #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")