class VendaAdmin(admin.ModelAdmin):
    fields = ("categoria", "imovel", "valor", "cliente", 'corretor',
              'pagamento')
    list_display = ('id', 'link_categoria', 'link_imovel', 'endereco', 'valor',
                    'pagamento', 'link_cliente', 'comissao')
    search_fields = ("categoria", "imovel", "cliente", 'corretor', 'pagamento')

    link_imovel = easy.ForeignKeyAdminField('imovel')
    link_cliente = easy.ForeignKeyAdminField('cliente')
    link_categoria = easy.ForeignKeyAdminField('categoria')
Exemple #2
0
    def test_foreignkey_display_sub_property(self):
        question = mommy.make(Question, question_text='Eba!')

        custom_field = easy.ForeignKeyAdminField('poll', 'poll.id')
        ret = custom_field(question)

        expected = u'<a href="/admin/test_app/poll/1/">1</a>'

        self.assertEqual(expected, ret)
        self.assertTrue(custom_field.allow_tags)
Exemple #3
0
    def test_foreignkey_display(self):
        question = mommy.make(Question, question_text='Eba!')

        custom_field = easy.ForeignKeyAdminField('poll', 'poll_id')
        ret = custom_field(question)
        if django.VERSION < (1, 9):
            expected = u'<a href="/admin/test_app/poll/1/">1</a>'
        else:
            expected = u'<a href="/admin/test_app/poll/1/change/">1</a>'

        self.assertEqual(expected, ret)
        self.assertTrue(custom_field.allow_tags)
    def test_foreignkey(self):
        question = baker.make(Question, question_text='Eba!')

        custom_field = easy.ForeignKeyAdminField('poll')
        ret = custom_field(question)
        if django.VERSION < (1, 9):
            expected = u'<a href="/admin/test_app/poll/1/">Poll object</a>'
        elif django.VERSION < (2, 0):
            expected = u'<a href="/admin/test_app/poll/1/change/">Poll object</a>'
        else:
            expected = u'<a href="/admin/test_app/poll/1/change/">Poll object (1)</a>'

        self.assertEqual(expected, ret)
        self.assertTrue(custom_field.allow_tags)
Exemple #5
0
class QuestionAdmin(admin.ModelAdmin):
    list_display = ('id', 'poll_link', 'bool_sample', 'question_text', 'pub_date',)
    list_filter = ('pub_date',)
    search_fields = ('question_text',)
    fieldsets = (
        (None, {
            'fields': ('poll', 'question_text',)
        }),(
            'Date information',
            {'classes': ('collapse',),
            'fields': ('pub_date',),
            }
        ),
    )
    inlines = (ChoiceInline,)

    poll_link = easy.ForeignKeyAdminField('poll')
    bool_sample = easy.BooleanAdminField(lambda x: x.id == 1, 'First')