turn old __rtags__ the new way tls-sprint
authorsylvain.thenault@logilab.fr
Thu, 26 Mar 2009 20:11:20 +0100
branchtls-sprint
changeset 1151 b20677336ee6
parent 1150 2d1b721fded9
child 1152 c99ef2a2535c
turn old __rtags__ the new way
web/views/bookmark.py
web/views/boxes.py
web/views/editforms.py
web/views/emailaddress.py
web/views/eproperties.py
web/views/euser.py
web/views/schema.py
web/views/workflow.py
--- a/web/views/bookmark.py	Thu Mar 26 19:15:57 2009 +0100
+++ b/web/views/bookmark.py	Thu Mar 26 20:11:20 2009 +0100
@@ -1,7 +1,7 @@
 """Primary view for bookmarks + user's bookmarks box
 
 :organization: Logilab
-:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
 """
 __docformat__ = "restructuredtext en"
@@ -14,6 +14,10 @@
 from cubicweb.web.action import Action
 from cubicweb.web.box import UserRQLBoxTemplate
 from cubicweb.web.views.baseviews import PrimaryView
+from cubicweb.web.views.editform import AutomaticEntityForm
+
+AutomaticEntityForm.rcategories.set_rtag('primary', 'path', 'subject', 'Bookmark')
+AutomaticEntityForm.rwidgets.set_rtag('StringWidget', 'path', 'subject', 'Bookmark')
 
 
 class FollowAction(Action):
--- a/web/views/boxes.py	Thu Mar 26 19:15:57 2009 +0100
+++ b/web/views/boxes.py	Thu Mar 26 20:11:20 2009 +0100
@@ -37,6 +37,17 @@
     order = 2
     # 'link' / 'create' relation tags, used to control the "add entity" submenu
     rmode = RelationTags() 
+    rmode.set_rtag('link', 'is', 'subject')
+    rmode.set_rtag('link', 'is', 'object')
+    rmode.set_rtag('link', 'is_instance_of', 'subject')
+    rmode.set_rtag('link', 'is_instance_of', 'object')
+    rmode.set_rtag('link', 'identity', 'subject')
+    rmode.set_rtag('link', 'identity', 'object')
+    rmode.set_rtag('link', 'owned_by', 'subject')
+    rmode.set_rtag('link', 'created_by', 'subject')
+    rmode.set_rtag('link', 'require_permission', 'subject')
+    rmode.set_rtag('link', 'wf_info_for', 'subject')
+    rmode.set_rtag('link', 'wf_info_for', 'subject')
 
     @classmethod
     def registered(cls, registry):
--- a/web/views/editforms.py	Thu Mar 26 19:15:57 2009 +0100
+++ b/web/views/editforms.py	Thu Mar 26 20:11:20 2009 +0100
@@ -154,12 +154,25 @@
     rcategories.set_rtag('primary', 'subject', 'eid')
     rcategories.set_rtag('metadata', 'subject', 'creation_date')
     rcategories.set_rtag('metadata', 'subject', 'modification_date')
-    rcategories.set_rtag('generated', 'subject', 'has_text')        
+    rcategories.set_rtag('generated', 'subject', 'has_text')
+    rcategories.set_rtag('metadata', 'owned_by', 'subject')
+    rcategories.set_rtag('metadata', 'created_by', 'subject')
+    rcategories.set_rtag('generated', 'is', 'subject')
+    rcategories.set_rtag('generated', 'is', 'object')
+    rcategories.set_rtag('generated', 'is_instance_of', 'subject')
+    rcategories.set_rtag('generated', 'is_instance_of', 'object')
+    rcategories.set_rtag('generated', 'identity', 'subject')
+    rcategories.set_rtag('generated', 'identity', 'object')
+    rcategories.set_rtag('generated', 'require_permission', 'subject')
+    rcategories.set_rtag('primary', 'in_state', 'subject')
+    rcategories.set_rtag('generated', 'wf_info_for', 'subject')
+    rcategories.set_rtag('generated', 'wf_info_for', 'subject')
+    rcategories.set_rtag('secondary', 'description', 'subject')
 
     # relations'widget (eg one of available class name in cubicweb.web.formwidgets)
     rwidgets = RelationTags()
     # inlined view flag for non final relations
-    inlined = RelationTags()
+    rinlined = RelationTags()
     # set of tags of the form <action>_on_new on relations. <action> is a
     # schema action (add/update/delete/read), and when such a tag is found
     # permissions checking is by-passed and supposed to be ok
@@ -325,8 +338,7 @@
         """
         entity = self.edited_entity
         pending_deletes = self.req.get_pending_deletes(entity.eid)
-        # XXX add metadata category quick fix to get Folder relations
-        for label, rschema, role in self.srelations_by_category(('generic', 'metadata'), 'add'):
+        for label, rschema, role in self.srelations_by_category('generic'), 'add'):
             relatedrset = entity.related(rschema, role, limit=self.limit)
             if rschema.has_perm(self.req, 'delete'):
                 toggable_rel_link_func = toggable_relation_link
@@ -377,7 +389,7 @@
         """return true if the given relation with entity has role and a
         targettype target should be inlined
         """
-        return self.inlined.etype_rtag(self.edited_entity.id, role, rschema, targettype)
+        return self.rinlined.etype_rtag(self.edited_entity.id, role, rschema, targettype)
 
     def should_display_inline_creation_form(self, rschema, existant, card):
         """return true if a creation form should be inlined
--- a/web/views/emailaddress.py	Thu Mar 26 19:15:57 2009 +0100
+++ b/web/views/emailaddress.py	Thu Mar 26 20:11:20 2009 +0100
@@ -1,7 +1,7 @@
 """Specific views for email addresses entities
 
 :organization: Logilab
-:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
 """
 __docformat__ = "restructuredtext en"
@@ -11,6 +11,8 @@
 from cubicweb.selectors import implements
 from cubicweb.common import Unauthorized
 from cubicweb.web.views import baseviews
+from cubicweb.web.views.editform import AutomaticEntityForm
+
 
 class EmailAddressPrimaryView(baseviews.PrimaryView):
     __select__ = implements('EmailAddress')
--- a/web/views/eproperties.py	Thu Mar 26 19:15:57 2009 +0100
+++ b/web/views/eproperties.py	Thu Mar 26 20:11:20 2009 +0100
@@ -17,6 +17,10 @@
 from cubicweb.web import INTERNAL_FIELD_VALUE, eid_param
 from cubicweb.web.views import baseviews
 from cubicweb.web.form import FormMixIn
+from cubicweb.web.views.editform import AutomaticEntityForm
+
+AutomaticEntityForm.rwidgets.set_rtag('PropertyKeyWidget', 'pkey', 'subject', 'EProperty')
+AutomaticEntityForm.rwidgets.set_rtag('PropertyValueWidget', 'value', 'subject', 'EProperty')
 
 _ = unicode
 
--- a/web/views/euser.py	Thu Mar 26 19:15:57 2009 +0100
+++ b/web/views/euser.py	Thu Mar 26 20:11:20 2009 +0100
@@ -16,8 +16,25 @@
 from cubicweb.web.form import FormMixIn
 from cubicweb.web.action import Action
 from cubicweb.web.views.baseviews import PrimaryView, EntityView
+from cubicweb.web.views.editform import AutomaticEntityForm
+from cubicweb.web.views.boxes import EditBox
 
 
+AutomaticEntityForm.rcategories.set_rtag('secondary', 'firstname', 'subject', 'EUser')
+AutomaticEntityForm.rcategories.set_rtag('secondary', 'surname', 'subject', 'EUser')
+AutomaticEntityForm.rcategories.set_rtag('metadata', 'last_login_time', 'subject', 'EUser')
+AutomaticEntityForm.rcategories.set_rtag('primary', 'in_group', 'subject', 'EUser')
+AutomaticEntityForm.rcategories.set_rtag('generated', 'owned_by', 'object', 'EUser')
+AutomaticEntityForm.rcategories.set_rtag('metadata', 'created_by', 'object', 'EUser')
+AutomaticEntityForm.rcategories.set_rtag('metadata', 'bookmarked_by', 'object', 'EUser')
+AutomaticEntityForm.rinlined.set_rtag(True, 'use_email', 'subject', 'EUser')
+
+EditBox.rmode.set_rtag('create', 'in_group', 'subject', 'EGroup')
+EditBox.rmode.set_rtag('link', 'owned_by', 'object', 'EUser')
+EditBox.rmode.set_rtag('link', 'created_by', 'object', 'EUser')
+EditBox.rmode.set_rtag('create', 'bookmarked_by', 'object', 'EUser')
+    
+
 class UserPreferencesEntityAction(Action):
     id = 'prefs'
     __select__ = (one_line_rset() & implements('EUser') &
--- a/web/views/schema.py	Thu Mar 26 19:15:57 2009 +0100
+++ b/web/views/schema.py	Thu Mar 26 20:11:20 2009 +0100
@@ -18,6 +18,23 @@
 from cubicweb.web.action import Action
 from cubicweb.web.views import baseviews
 from cubicweb.web.views import TmpFileViewMixin
+from cubicweb.web.views.editform import AutomaticEntityForm
+from cubicweb.web.views.boxes import EditBox
+
+
+AutomaticEntityForm.rcategories.set_rtag('primary', 'require_group', 'subject', 'EPermission')
+AutomaticEntityForm.rcategories.set_rtag('generated', 'final', 'subject', 'EEtype')
+AutomaticEntityForm.rcategories.set_rtag('generated', 'final', 'subject', 'ERtype')
+AutomaticEntityForm.rinlined.set_rtag(True, 'relation_type', 'subject', 'ENFRDef')
+AutomaticEntityForm.rinlined.set_rtag(True, 'from_entity', 'subject', 'ENFRDef')
+AutomaticEntityForm.rinlined.set_rtag(True, 'to_entity', 'subject', 'ENFRDef')
+AutomaticEntityForm.rwidgets.set_rtag('StringWidget', 'expression', 'subject', 'RQLExpression')
+
+EditBox.rmode.set_rtag('create', 'state_of', 'object', 'EEType')
+EditBox.rmode.set_rtag('create', 'transition_of', 'object', 'EEType')
+EditBox.rmode.set_rtag('create', 'relation_type', 'object', 'ERType')
+EditBox.rmode.set_rtag('link', 'from_entity', 'object', 'EEType')
+EditBox.rmode.set_rtag('link', 'to_entity', 'object', 'EEType')
 
 
 class ViewSchemaAction(Action):
--- a/web/views/workflow.py	Thu Mar 26 19:15:57 2009 +0100
+++ b/web/views/workflow.py	Thu Mar 26 20:11:20 2009 +0100
@@ -20,6 +20,13 @@
 from cubicweb.web.formfields import StringField,  RichTextField
 from cubicweb.web.formwidgets import HiddenInput
 from cubicweb.web.views import TmpFileViewMixin
+from cubicweb.web.views.boxes import EditBox
+
+
+EditBox.rmode.set_rtag('create', 'destination_state', 'subject', 'Transition')
+EditBox.rmode.set_rtag('create', 'allowed_transition', 'object', 'Transition')
+EditBox.rmode.set_rtag('create', 'destination_state', 'object', 'State')
+EditBox.rmode.set_rtag('create', 'allowed_transition', 'subject', 'State')
 
 
 # IWorkflowable views #########################################################