web/views/autoform.py
branchtls-sprint
changeset 1702 312310ed8a2f
parent 1607 9747a0aa753c
child 1721 694f6a50e138
equal deleted inserted replaced
1701:9fb5b4741a08 1702:312310ed8a2f
     3 :organization: Logilab
     3 :organization: Logilab
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 """
     6 """
     7 __docformat__ = "restructuredtext en"
     7 __docformat__ = "restructuredtext en"
       
     8 _ = unicode
     8 
     9 
     9 from logilab.common.decorators import iclassmethod
    10 from logilab.common.decorators import iclassmethod
    10 
    11 
    11 from cubicweb import typed_eid
    12 from cubicweb import typed_eid
    12 from cubicweb.web import stdmsgs, uicfg
    13 from cubicweb.web import stdmsgs, uicfg
    13 from cubicweb.web.form import FieldNotFound, EntityFieldsForm
    14 from cubicweb.web.form import FieldNotFound, EntityFieldsForm
    14 from cubicweb.web.formfields import guess_field
    15 from cubicweb.web.formfields import guess_field
    15 from cubicweb.web.formwidgets import Button, SubmitButton
    16 from cubicweb.web.formwidgets import Button, SubmitButton
    16 from cubicweb.web.views.editforms import toggleable_relation_link, relation_id
    17 from cubicweb.web.views.editforms import toggleable_relation_link, relation_id
    17 
    18 
    18 _ = unicode
       
    19 
    19 
    20 class AutomaticEntityForm(EntityFieldsForm):
    20 class AutomaticEntityForm(EntityFieldsForm):
    21     """base automatic form to edit any entity.
    21     """base automatic form to edit any entity.
    22 
    22 
    23     Designed to be fully generated from schema but highly configurable through:
    23     Designed to be fully generated from schema but highly configurable through:
   242 
   242 
   243     action = property(action, set_action)
   243     action = property(action, set_action)
   244 
   244 
   245     def editable_attributes(self):
   245     def editable_attributes(self):
   246         """return a list of (relation schema, role) to edit for the entity"""
   246         """return a list of (relation schema, role) to edit for the entity"""
   247         return [(rschema, x) for rschema, _, x in self.relations_by_category(
   247         return [(rschema, role) for rschema, _, role in self.relations_by_category(
   248                 self.attrcategories, 'add') if rschema != 'eid']
   248                 self.attrcategories, 'add') if rschema != 'eid']
   249 
   249 
   250     def relations_table(self):
   250     def relations_table(self):
   251         """yiels 3-tuples (rtype, target, related_list)
   251         """yiels 3-tuples (rtype, target, related_list)
   252         where <related_list> itself a list of :
   252         where <related_list> itself a list of :