web/views/baseviews.py
changeset 570 0c9dfc430200
parent 532 ce3e94cbb074
child 573 9c8fd72ba6c1
equal deleted inserted replaced
569:94e2202ee9c3 570:0c9dfc430200
   860         rtype = self.req.form.get('rtype', rtype)
   860         rtype = self.req.form.get('rtype', rtype)
   861         showlabel = self.req.form.get('showlabel', showlabel)
   861         showlabel = self.req.form.get('showlabel', showlabel)
   862         assert rtype is not None, "rtype is mandatory for 'edirelation' view"
   862         assert rtype is not None, "rtype is mandatory for 'edirelation' view"
   863         targettype = self.req.form.get('targettype', targettype)
   863         targettype = self.req.form.get('targettype', targettype)
   864         role = self.req.form.get('role', role)
   864         role = self.req.form.get('role', role)
   865         mode = entity.rtags.get_mode(rtype, targettype, role)
       
   866         if mode == 'create':
       
   867             return
       
   868         category = entity.rtags.get_category(rtype, targettype, role)
   865         category = entity.rtags.get_category(rtype, targettype, role)
   869         if category in ('generated', 'metadata'):
   866         if category in ('primary', 'secondary') or self.schema.rschema(rtype).is_final():
   870             return
       
   871         elif category in ('primary', 'secondary'):
       
   872             if hasattr(entity, '%s_format' % rtype):
   867             if hasattr(entity, '%s_format' % rtype):
   873                 formatwdg = entity.get_widget('%s_format' % rtype, role)
   868                 formatwdg = entity.get_widget('%s_format' % rtype, role)
   874                 self.w(formatwdg.edit_render(entity))
   869                 self.w(formatwdg.edit_render(entity))
   875                 self.w(u'<br/>')
   870                 self.w(u'<br/>')
   876             wdg = entity.get_widget(rtype, role)
   871             wdg = entity.get_widget(rtype, role)
   877             if showlabel:
   872             if showlabel:
   878                 self.w(u'%s' % wdg.render_label(entity))
   873                 self.w(u'%s' % wdg.render_label(entity))
   879             self.w(u'%s %s %s' %
   874             self.w(u'%s %s %s' %
   880                    (wdg.render_error(entity), wdg.edit_render(entity),
   875                    (wdg.render_error(entity), wdg.edit_render(entity),
   881                     wdg.render_help(entity),))
   876                     wdg.render_help(entity),))
   882         elif category == 'generic':
   877         else:
   883             self._render_generic_relation(entity, rtype, role)
   878             self._render_generic_relation(entity, rtype, role)
   884         else:
       
   885             self.error("oops, wrong category %s", category)
       
   886 
   879 
   887     def _render_generic_relation(self, entity, relname, role):
   880     def _render_generic_relation(self, entity, relname, role):
   888         text = self.req.__('add %s %s %s' % (entity.e_schema, relname, role))
   881         text = self.req.__('add %s %s %s' % (entity.e_schema, relname, role))
   889         # pending operations
   882         # pending operations
   890         operations = self.req.get_pending_operations(entity, relname, role)
   883         operations = self.req.get_pending_operations(entity, relname, role)