146 form = self.vreg['forms'].select('edition', req, rset=rset, row=0, col=0) |
146 form = self.vreg['forms'].select('edition', req, rset=rset, row=0, col=0) |
147 # should be also selectable by specifying entity |
147 # should be also selectable by specifying entity |
148 self.vreg['forms'].select('edition', req, entity=rset.get_entity(0, 0)) |
148 self.vreg['forms'].select('edition', req, entity=rset.get_entity(0, 0)) |
149 self.assertFalse(any(f for f in form.fields if f is None)) |
149 self.assertFalse(any(f for f in form.fields if f is None)) |
150 |
150 |
|
151 def test_attribute_add_permissions(self): |
|
152 # https://www.cubicweb.org/ticket/4342844 |
|
153 with self.admin_access.repo_cnx() as cnx: |
|
154 self.create_user(cnx, 'toto') |
|
155 cnx.commit() |
|
156 with self.new_access('toto').web_request() as req: |
|
157 e = self.vreg['etypes'].etype_class('Personne')(req) |
|
158 cform = self.vreg['forms'].select('edition', req, entity=e) |
|
159 self.assertIn('sexe', |
|
160 [rschema.type |
|
161 for rschema, _ in cform.editable_attributes()]) |
|
162 with self.new_access('toto').repo_cnx() as cnx: |
|
163 person_eid = cnx.create_entity('Personne', nom=u'Robert').eid |
|
164 cnx.commit() |
|
165 person = req.entity_from_eid(person_eid) |
|
166 mform = self.vreg['forms'].select('edition', req, entity=person) |
|
167 self.assertNotIn('sexe', |
|
168 [rschema.type |
|
169 for rschema, _ in mform.editable_attributes()]) |
|
170 |
151 |
171 |
152 class FormViewsTC(CubicWebTC): |
172 class FormViewsTC(CubicWebTC): |
153 |
173 |
154 def test_delete_conf_formview(self): |
174 def test_delete_conf_formview(self): |
155 with self.admin_access.web_request() as req: |
175 with self.admin_access.web_request() as req: |