def test_custom_edit_and_blank_text(self): ship = Ship.objects.create(id=1, name="Star of India") pirate = Pirate.objects.create(id=1, name="Lowell Taylor") self.assertEqual( object_edit_link("Go There", "N/A")(ship), '<a href="/adm/tests/ship/1/">Go There</a>') self.assertEqual(object_edit_link("Go There", "N/A")(pirate), "N/A")
def test_default(self): ship = Ship.objects.create(id=1, name="Star of India") self.assertEqual( object_edit_link()(ship), '<a href="/adm/tests/ship/1/change/">Star of India</a>', ) pirate = Pirate.objects.create(id=1, name="Lowell Taylor") self.assertEqual(object_edit_link()(pirate), "Lowell Taylor")
class TabInline(admin.TabularInline): model = models.Tab edit_link = object_edit_link(_("Edit")) fields = ('name', 'position', edit_link) readonly_fields = (edit_link, ) ordering = ('position', ) extra = 1
class CustomerPaymentProfileInline(admin.TabularInline): model = CustomerPaymentProfile form = CustomerPaymentForm fields = [ object_edit_link("Edit"), 'first_name', 'last_name', 'card_number', 'expiration_date' ] readonly_fields = fields extra = 0 max_num = 0 can_delete = False
def test_custom_edit_and_blank_text(self): ship = Ship.objects.create(id=1, name="Star of India") pirate = Pirate.objects.create(id=1, name="Lowell Taylor") self.assertEqual(object_edit_link("Go There", "N/A")(ship), '<a href="/adm/tests/ship/1/">Go There</a>') self.assertEqual(object_edit_link("Go There", "N/A")(pirate), "N/A")
def test_default_blank_text(self): pirate = Pirate.objects.create(id=1, name="Lowell Taylor") self.assertEqual(object_edit_link("Edit")(pirate), "")
def test_custom_edit_text(self): ship = Ship.objects.create(id=1, name="Star of India") self.assertEqual(object_edit_link("Go There")(ship), '<a href="/adm/tests/ship/1/">Go There</a>')
def test_custom_edit_text(self): ship = Ship.objects.create(id=1, name="Star of India") self.assertEqual( object_edit_link("Go There")(ship), '<a href="/adm/tests/ship/1/">Go There</a>')