18 |
18 |
19 from cubicweb.rtags import RelationTags |
19 from cubicweb.rtags import RelationTags |
20 from cubicweb.selectors import match_user_groups, non_final_entity |
20 from cubicweb.selectors import match_user_groups, non_final_entity |
21 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem |
21 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem |
22 from cubicweb.view import EntityView |
22 from cubicweb.view import EntityView |
|
23 from cubicweb.web import uicfg |
23 from cubicweb.web.box import BoxTemplate |
24 from cubicweb.web.box import BoxTemplate |
24 |
25 |
25 _ = unicode |
26 _ = unicode |
26 |
27 |
27 class EditBox(BoxTemplate): |
28 class EditBox(BoxTemplate): |
32 id = 'edit_box' |
33 id = 'edit_box' |
33 __select__ = BoxTemplate.__select__ & non_final_entity() |
34 __select__ = BoxTemplate.__select__ & non_final_entity() |
34 |
35 |
35 title = _('actions') |
36 title = _('actions') |
36 order = 2 |
37 order = 2 |
37 # 'link' / 'create' relation tags, used to control the "add entity" submenu |
38 # class attributes below are actually stored in the uicfg module since we |
38 rmode = RelationTags() |
39 # don't want them to be reloaded |
39 rmode.set_rtag('link', 'is', 'subject') |
40 rmode = uicfg.rmode |
40 rmode.set_rtag('link', 'is', 'object') |
|
41 rmode.set_rtag('link', 'is_instance_of', 'subject') |
|
42 rmode.set_rtag('link', 'is_instance_of', 'object') |
|
43 rmode.set_rtag('link', 'identity', 'subject') |
|
44 rmode.set_rtag('link', 'identity', 'object') |
|
45 rmode.set_rtag('link', 'owned_by', 'subject') |
|
46 rmode.set_rtag('link', 'created_by', 'subject') |
|
47 rmode.set_rtag('link', 'require_permission', 'subject') |
|
48 rmode.set_rtag('link', 'wf_info_for', 'subject') |
|
49 rmode.set_rtag('link', 'wf_info_for', 'subject') |
|
50 |
|
51 @classmethod |
|
52 def registered(cls, registry): |
|
53 """build class using descriptor at registration time""" |
|
54 super(EditBox, cls).registered(registry) |
|
55 cls.init_rtags_mode() |
|
56 return cls |
|
57 |
41 |
58 @classmethod |
42 @classmethod |
59 def init_rtags_mode(cls): |
43 def vreg_initialization_completed(cls): |
60 """set default category tags for relations where it's not yet defined in |
44 """set default category tags for relations where it's not yet defined in |
61 the category relation tags |
45 the category relation tags |
62 """ |
46 """ |
63 for eschema in cls.schema.entities(): |
47 for eschema in cls.schema.entities(): |
64 for rschema, tschemas, role in eschema.relation_definitions(True): |
48 for rschema, tschemas, role in eschema.relation_definitions(True): |