web/widgets.py
branchtls-sprint
changeset 1263 01152fffd593
parent 1132 96752791c2b6
parent 1227 e8b7c7407edf
child 1309 a4eb20f86cb0
equal deleted inserted replaced
1246:76b3cd5d4f31 1263:01152fffd593
   442             return entity.req._('yes')
   442             return entity.req._('yes')
   443         return entity.req._('no')
   443         return entity.req._('no')
   444 
   444 
   445 
   445 
   446 class YesNoRadioWidget(CheckBoxWidget):
   446 class YesNoRadioWidget(CheckBoxWidget):
   447     
   447     html_attributes = Widget.html_attributes | set(('disabled',))
   448     def _edit_render(self, entity):
   448     def _edit_render(self, entity):
   449         value = self.current_value(entity)
   449         value = self.current_value(entity)
   450         dvalue = self.current_display_value(entity)
   450         dvalue = self.current_display_value(entity)
   451         attrs1 = self.format_attrs()
   451         attrs1 = self.format_attrs()
   452         del self.attrs['id'] # avoid duplicate id for xhtml compliance
   452         del self.attrs['id'] # avoid duplicate id for xhtml compliance
   480                     ewdg = entity.get_widget(self.name + extraattr)
   480                     ewdg = entity.get_widget(self.name + extraattr)
   481                     wdgs.append(ewdg.render_label(entity))
   481                     wdgs.append(ewdg.render_label(entity))
   482                     wdgs.append(ewdg.edit_render(entity, includehelp=True))
   482                     wdgs.append(ewdg.edit_render(entity, includehelp=True))
   483                     wdgs.append(u'<br/>')
   483                     wdgs.append(u'<br/>')
   484             wdgs.append(u'</div>')
   484             wdgs.append(u'</div>')
   485         if entity.has_eid() and not self.required(entity):
   485         if entity.has_eid():
   486             # trick to be able to delete an uploaded file
   486             if not self.required(entity):
   487             wdgs.append(u'<br/>')
   487                 # trick to be able to delete an uploaded file
   488             wdgs.append(checkbox(eid_param('__%s_detach' % self.rname, entity.eid), False))
   488                 wdgs.append(u'<br/>')
   489             wdgs.append(req._('detach attached file'))
   489                 wdgs.append(checkbox(eid_param('__%s_detach' % self.rname, entity.eid), False))
       
   490                 wdgs.append(req._('detach attached file %s' % entity.dc_title()))
       
   491             else:
       
   492                 wdgs.append(u'<br/>')
       
   493                 wdgs.append(req._('currently attached file: %s' % entity.dc_title()))
   490         return '\n'.join(wdgs)
   494         return '\n'.join(wdgs)
   491     
   495     
   492     def _edit_render(self, entity):
   496     def _edit_render(self, entity):
   493         return self.hidden_input(entity, None) + self._file_wdg(entity)
   497         return self.hidden_input(entity, None) + self._file_wdg(entity)
   494 
   498 
   579                                                    multiple, **kwattrs)
   583                                                    multiple, **kwattrs)
   580         self.sort = sort
   584         self.sort = sort
   581         self.vocabfunc = vocabfunc
   585         self.vocabfunc = vocabfunc
   582 
   586 
   583     def vocabulary(self, entity):
   587     def vocabulary(self, entity):
   584         choices = self.vocabfunc(entity)
   588         choices = self.vocabfunc(entity=entity)
   585         if self.sort:
   589         if self.sort:
   586             choices = sorted(choices)
   590             choices = sorted(choices)
   587         if self.rschema.rproperty(self.subjtype, self.objtype, 'internationalizable'):
   591         if self.rschema.rproperty(self.subjtype, self.objtype, 'internationalizable'):
   588             return zip((entity.req._(v) for v in choices), choices)
   592             return zip((entity.req._(v) for v in choices), choices)
   589         return zip(choices, choices)
   593         return zip(choices, choices)