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