Custom cross admin

48 views
Skip to first unread message

Lionel Roubeyrie

unread,
Mar 28, 2013, 7:11:58 AM3/28/13
to project...@googlegroups.com
Hi,
I need to use customs admin classes for two entities linked by a OneToMany relationship.
So, when I open A and call B in the A form, I don't want to see the A attribute in the B form. And vice-versa! But Camelot complains because he can't find the B custom admin class if B is not declared before A in the model.py file, but I have to declare A before B to give B the access of the custom admin class of A (infinite loop on!).

Don't work :
class A(Entity):
    Bs = relationship('B', backref="A")
    
    class Admin(EntityAdmin):
        form_display = ['id', 'Bs']

        field_attributes = {'Bs': {'admin': B.AdminWithoutA,},}

    class AdminWithoutB(EntityAdmin):
        form_display = ['id']

class B(Entity):
    A_id = Column(Integer, ForeignKey('A.id'), nullable=False)

    class Admin(EntityAdmin):
        form_display = ['id', 'A']

        field_attributes = {'A': {'admin': A.AdminWithoutB,},}

    class AdminWithoutA(EntityAdmin):
        form_display = ['id']

Any idea? Thanks

Erik Janssens

unread,
Mar 29, 2013, 1:33:53 PM3/29/13
to project...@googlegroups.com
you can solve this by injecting the admins in the field attributes
after definition, like :

B.Admin.field_attributes['A'] = dict(admin=A.AdminWithoutB)


--
--
You received this message because you are subscribed to the "Project Camelot" group.
Visit www.python-camelot.com for more information
 
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to
project-camel...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/project-camelot?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Project Camelot" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-camel...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Lionel Roubeyrie

unread,
Mar 30, 2013, 5:40:42 AM3/30/13
to project...@googlegroups.com
Ok thanks Erik, it works.


2013/3/29 Erik Janssens <Erik.J...@conceptive.be>
You received this message because you are subscribed to a topic in the Google Groups "Project Camelot" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/project-camelot/F8IUCXCtXnw/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to project-camel...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages