web/views/editcontroller.py
changeset 3386 ab797c5374b7
parent 3384 f76a38731bc1
child 3387 a357d4147eee
equal deleted inserted replaced
3385:68953ecddd2b 3386:ab797c5374b7
    81     def edit_entity(self, formparams, multiple=False):
    81     def edit_entity(self, formparams, multiple=False):
    82         """edit / create / copy an entity and return its eid"""
    82         """edit / create / copy an entity and return its eid"""
    83         etype = formparams['__type']
    83         etype = formparams['__type']
    84         entity = self.vreg['etypes'].etype_class(etype)(self.req)
    84         entity = self.vreg['etypes'].etype_class(etype)(self.req)
    85         entity.eid = eid = self._get_eid(formparams['eid'])
    85         entity.eid = eid = self._get_eid(formparams['eid'])
    86         edited = self.req.form.get('__maineid') == formparams['eid']
       
    87         # let a chance to do some entity specific stuff.
    86         # let a chance to do some entity specific stuff.
       
    87         is_main_entity = self.req.form.get('__maineid') == formparams['eid']
    88         entity.pre_web_edit()
    88         entity.pre_web_edit()
    89         # create a rql query from parameters
    89         # create a rql query from parameters
    90         self.relations = []
    90         self.relations = []
    91         self.restrictions = []
    91         self.restrictions = []
    92         # process inlined relations at the same time as attributes
    92         # process inlined relations at the same time as attributes
   133             self.handle_relation(rschema, formparams, 'subject', entity)
   133             self.handle_relation(rschema, formparams, 'subject', entity)
   134         for rschema in entity.e_schema.object_relations():
   134         for rschema in entity.e_schema.object_relations():
   135             if rschema.is_final():
   135             if rschema.is_final():
   136                 continue
   136                 continue
   137             self.handle_relation(rschema, formparams, 'object', entity)
   137             self.handle_relation(rschema, formparams, 'object', entity)
   138         if edited:
   138         if is_main_entity:
   139             self.notify_edited(entity)
   139             self.notify_edited(entity)
   140         if formparams.has_key('__delete'):
   140         if formparams.has_key('__delete'):
   141             todelete = self.req.list_form_param('__delete', formparams, pop=True)
   141             todelete = self.req.list_form_param('__delete', formparams, pop=True)
   142             self.delete_relations(parse_relations_descr(todelete))
   142             self.delete_relations(parse_relations_descr(todelete))
   143         if formparams.has_key('__cloned_eid'):
   143         if formparams.has_key('__cloned_eid'):
   144             entity.copy_relations(formparams['__cloned_eid'])
   144             entity.copy_relations(formparams['__cloned_eid'])
   145         if formparams.has_key('__insert'):
   145         if formparams.has_key('__insert'):
   146             toinsert = self.req.list_form_param('__insert', formparams, pop=True)
   146             toinsert = self.req.list_form_param('__insert', formparams, pop=True)
   147             self.insert_relations(parse_relations_descr(toinsert))
   147             self.insert_relations(parse_relations_descr(toinsert))
   148         if edited: # only execute linkto for the main entity
   148         if is_main_entity: # only execute linkto for the main entity
   149             self.execute_linkto(eid)
   149             self.execute_linkto(eid)
   150         return eid
   150         return eid
   151 
   151 
   152     def _action_apply(self):
   152     def _action_apply(self):
   153         self._default_publish()
   153         self._default_publish()