update rtags and widgets, js_get_concerned_by must be decorated by jsonize
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 27 May 2009 15:04:50 +0200
changeset 14 a8d17f05b594
parent 13 452a91b57e43
child 15 f4c6ce965e48
update rtags and widgets, js_get_concerned_by must be decorated by jsonize
entities.py
views/__init__.py
views/controllers.py
--- a/entities.py	Mon May 18 09:39:52 2009 +0200
+++ b/entities.py	Wed May 27 15:04:50 2009 +0200
@@ -3,18 +3,11 @@
 from cubes.expense.entities import Expense as BaseExpense, ExpenseLine as BaseExpenseLine
 
 class Expense(BaseExpense):
+    autocomplete_initfuncs = {'spent_for' : 'get_concerned_by'}
 
-    __rtags__ = {'spent_for' : 'primary'}
-    widgets = {'spent_for' : 'RestrictedAutoCompletionWidget'}
-    autocomplete_initfuncs = {'spent_for' : 'get_concerned_by'}
-    
 
 class ExpenseLine(BaseExpenseLine):
 
-    __rtags__ = {
-        'paid_by' : 'primary',
-        }
-
     @property
     def workcase(self):
         rql = 'Any R WHERE E has_lines EL, EL eid %(el)s, E spent_for W, W ref R'
--- a/views/__init__.py	Mon May 18 09:39:52 2009 +0200
+++ b/views/__init__.py	Wed May 27 15:04:50 2009 +0200
@@ -1,1 +1,17 @@
 """template-specific forms/views/actions/components"""
+from logilab.common.decorators import monkeypatch
+
+from cubicweb.web import uicfg
+from cubicweb.web.formwidgets import RestrictedAutoCompletionWidget
+from cubicweb.web.views import basecontrollers
+
+uicfg.autoform_section.tag_subject_of(('Expense', 'spent_for', '*'), 'primary')
+uicfg.autoform_field_kwargs.tag_subject_of(('Expense', 'spent_for', '*'),
+                                           {'widget': RestrictedAutoCompletionWidget})
+
+
+
+@monkeypatch(basecontrollers.JSonController)
+@basecontrollers.jsonize
+def js_get_concerned_by(self):
+    return self.req.execute('DISTINCT Any W,R ORDERBY R WHERE W ref R').rows
--- a/views/controllers.py	Mon May 18 09:39:52 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-"""Specific controllers for CRM.
-
-:organization: Logilab
-:copyright: 2003-2007 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-"""
-__docformat__ = "restructuredtext en"
-
-from cubicweb.web.views.basecontrollers import JSonController
-
-def js_get_concerned_by(self):
-    return self.req.execute('DISTINCT Any W,R WHERE W ref R ORDERBY R').rows
-
-JSonController.js_get_concerned_by = js_get_concerned_by