예제 #1
0
 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")
예제 #2
0
 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")
예제 #3
0
 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")
예제 #4
0
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
예제 #5
0
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
예제 #6
0
 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")
예제 #7
0
 def test_default_blank_text(self):
     pirate = Pirate.objects.create(id=1, name="Lowell Taylor")
     self.assertEqual(object_edit_link("Edit")(pirate), "")
예제 #8
0
 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>')
예제 #9
0
 def test_default_blank_text(self):
     pirate = Pirate.objects.create(id=1, name="Lowell Taylor")
     self.assertEqual(object_edit_link("Edit")(pirate), "")
예제 #10
0
 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>')