entities/__init__.py
changeset 3418 7b49fa7e942d
parent 3377 dd9d292b6a6d
child 3451 6b46d73823f5
equal deleted inserted replaced
3412:368c68ffb99e 3418:7b49fa7e942d
    84         """return latest modification date of this entity"""
    84         """return latest modification date of this entity"""
    85         return self.format_date(self.modification_date, date_format=date_format)
    85         return self.format_date(self.modification_date, date_format=date_format)
    86 
    86 
    87     def dc_type(self, form=''):
    87     def dc_type(self, form=''):
    88         """return the display name for the type of this entity (translated)"""
    88         """return the display name for the type of this entity (translated)"""
    89         return self.e_schema.display_name(self.req, form)
    89         return self.e_schema.display_name(self._cw, form)
    90 
    90 
    91     def dc_language(self):
    91     def dc_language(self):
    92         """return language used by this entity (translated)"""
    92         """return language used by this entity (translated)"""
    93         # check if entities has internationalizable attributes
    93         # check if entities has internationalizable attributes
    94         # XXX one is enough or check if all String attributes are internationalizable?
    94         # XXX one is enough or check if all String attributes are internationalizable?
    95         for rschema, attrschema in self.e_schema.attribute_definitions():
    95         for rschema, attrschema in self.e_schema.attribute_definitions():
    96             if rschema.rproperty(self.e_schema, attrschema,
    96             if rschema.rproperty(self.e_schema, attrschema,
    97                                  'internationalizable'):
    97                                  'internationalizable'):
    98                 return self.req._(self.req.user.property_value('ui.language'))
    98                 return self._cw._(self.req.user.property_value('ui.language'))
    99         return self.req._(self.vreg.property_value('ui.language'))
    99         return self._cw._(self._cw.vreg.property_value('ui.language'))
   100 
   100 
   101     @property
   101     @property
   102     def creator(self):
   102     def creator(self):
   103         """return the CWUser entity which has created this entity, or None if
   103         """return the CWUser entity which has created this entity, or None if
   104         unknown or if the curent user doesn't has access to this euser
   104         unknown or if the curent user doesn't has access to this euser
   120                          "(view=None, recurs=False), please update",
   120                          "(view=None, recurs=False), please update",
   121                          DeprecationWarning)
   121                          DeprecationWarning)
   122                     path = parent.breadcrumbs(view) + [self]
   122                     path = parent.breadcrumbs(view) + [self]
   123         if not recurs:
   123         if not recurs:
   124             if view is None:
   124             if view is None:
   125                 if 'vtitle' in self.req.form:
   125                 if 'vtitle' in self._cw.form:
   126                     # embeding for instance
   126                     # embeding for instance
   127                     path.append( self.req.form['vtitle'] )
   127                     path.append( self._cw.form['vtitle'] )
   128             elif view.id != 'primary' and hasattr(view, 'title'):
   128             elif view.id != 'primary' and hasattr(view, 'title'):
   129                 path.append( self.req._(view.title) )
   129                 path.append( self._cw._(view.title) )
   130         return path
   130         return path
   131 
   131 
   132     ## IFeed interface ########################################################
   132     ## IFeed interface ########################################################
   133 
   133 
   134     def rss_feed_url(self):
   134     def rss_feed_url(self):
   161             return self.__linkto[(rtype, role)]
   161             return self.__linkto[(rtype, role)]
   162         except AttributeError:
   162         except AttributeError:
   163             self.__linkto = {}
   163             self.__linkto = {}
   164         except KeyError:
   164         except KeyError:
   165             pass
   165             pass
   166         linktos = list(self.req.list_form_param('__linkto'))
   166         linktos = list(self._cw.list_form_param('__linkto'))
   167         linkedto = []
   167         linkedto = []
   168         for linkto in linktos[:]:
   168         for linkto in linktos[:]:
   169             ltrtype, eid, ltrole = linkto.split(':')
   169             ltrtype, eid, ltrole = linkto.split(':')
   170             if rtype == ltrtype and role == ltrole:
   170             if rtype == ltrtype and role == ltrole:
   171                 # delete __linkto from form param to avoid it being added as
   171                 # delete __linkto from form param to avoid it being added as
   172                 # hidden input
   172                 # hidden input
   173                 if remove:
   173                 if remove:
   174                     linktos.remove(linkto)
   174                     linktos.remove(linkto)
   175                     self.req.form['__linkto'] = linktos
   175                     self._cw.form['__linkto'] = linktos
   176                 linkedto.append(typed_eid(eid))
   176                 linkedto.append(typed_eid(eid))
   177         self.__linkto[(rtype, role)] = linkedto
   177         self.__linkto[(rtype, role)] = linkedto
   178         return linkedto
   178         return linkedto
   179 
   179 
   180     # edit controller callbacks ###############################################
   180     # edit controller callbacks ###############################################