예제 #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")