202 Should return a list of eids which can be used to generate message ids |
202 Should return a list of eids which can be used to generate message ids |
203 of previously sent email |
203 of previously sent email |
204 """ |
204 """ |
205 return () |
205 return () |
206 |
206 |
207 # XXX deprecates, may be killed once old widgets system is gone ########### |
|
208 |
|
209 @classmethod |
|
210 def get_widget(cls, rschema, x='subject'): |
|
211 """return a widget to view or edit a relation |
|
212 |
|
213 notice that when the relation support multiple target types, the widget |
|
214 is necessarily the same for all those types |
|
215 """ |
|
216 # let ImportError propage if web par isn't available |
|
217 from cubicweb.web.widgets import widget |
|
218 if isinstance(rschema, basestring): |
|
219 rschema = cls.schema.rschema(rschema) |
|
220 if x == 'subject': |
|
221 tschema = rschema.objects(cls.e_schema)[0] |
|
222 wdg = widget(cls.vreg, cls, rschema, tschema, 'subject') |
|
223 else: |
|
224 tschema = rschema.subjects(cls.e_schema)[0] |
|
225 wdg = widget(cls.vreg, tschema, rschema, cls, 'object') |
|
226 return wdg |
|
227 |
|
228 @deprecated('[3.4] use EntityFieldsForm.subject_relation_vocabulary') |
|
229 def subject_relation_vocabulary(self, rtype, limit): |
|
230 form = self.vreg.select('forms', 'edition', self.req, entity=self) |
|
231 return form.subject_relation_vocabulary(rtype, limit) |
|
232 |
|
233 @deprecated('[3.4] use EntityFieldsForm.object_relation_vocabulary') |
|
234 def object_relation_vocabulary(self, rtype, limit): |
|
235 form = self.vreg.select('forms', 'edition', self.req, entity=self) |
|
236 return form.object_relation_vocabulary(rtype, limit) |
|
237 |
|
238 @deprecated('[3.4] use AutomaticEntityForm.[e]relations_by_category') |
|
239 def relations_by_category(self, categories=None, permission=None): |
|
240 from cubicweb.web.views.autoform import AutomaticEntityForm |
|
241 return AutomaticEntityForm.erelations_by_category(self, categories, permission) |
|
242 |
|
243 @deprecated('[3.4] use AutomaticEntityForm.[e]srelations_by_category') |
|
244 def srelations_by_category(self, categories=None, permission=None): |
|
245 from cubicweb.web.views.autoform import AutomaticEntityForm |
|
246 return AutomaticEntityForm.esrelations_by_category(self, categories, permission) |
|
247 |
|
248 def attribute_values(self, attrname): |
|
249 if self.has_eid() or attrname in self: |
|
250 try: |
|
251 values = self[attrname] |
|
252 except KeyError: |
|
253 values = getattr(self, attrname) |
|
254 # actual relation return a list of entities |
|
255 if isinstance(values, list): |
|
256 return [v.eid for v in values] |
|
257 return (values,) |
|
258 # the entity is being created, try to find default value for |
|
259 # this attribute |
|
260 try: |
|
261 values = self.req.form[attrname] |
|
262 except KeyError: |
|
263 try: |
|
264 values = self[attrname] # copying |
|
265 except KeyError: |
|
266 values = getattr(self, 'default_%s' % attrname, |
|
267 self.e_schema.default(attrname)) |
|
268 if callable(values): |
|
269 values = values() |
|
270 if values is None: |
|
271 values = () |
|
272 elif not isinstance(values, (list, tuple)): |
|
273 values = (values,) |
|
274 return values |
|
275 |
|
276 def use_fckeditor(self, attr): |
|
277 """return True if fckeditor should be used to edit entity's attribute named |
|
278 `attr`, according to user preferences |
|
279 """ |
|
280 if self.req.use_fckeditor() and self.e_schema.has_metadata(attr, 'format'): |
|
281 if self.has_eid() or '%s_format' % attr in self: |
|
282 return self.attr_metadata(attr, 'format') == 'text/html' |
|
283 return self.req.property_value('ui.default-text-format') == 'text/html' |
|
284 return False |
|
285 |
|
286 # XXX: store a reference to the AnyEntity class since it is hijacked in goa |
207 # XXX: store a reference to the AnyEntity class since it is hijacked in goa |
287 # configuration and we need the actual reference to avoid infinite loops |
208 # configuration and we need the actual reference to avoid infinite loops |
288 # in mro |
209 # in mro |
289 ANYENTITY = AnyEntity |
210 ANYENTITY = AnyEntity |
290 |
211 |