154 self._test_richtextfield('''<select id="description_format:%(eid)s" name="description_format:%(eid)s" size="1" style="display: block" tabindex="0"> |
154 self._test_richtextfield('''<select id="description_format:%(eid)s" name="description_format:%(eid)s" size="1" style="display: block" tabindex="0"> |
155 <option value="text/cubicweb-page-template">text/cubicweb-page-template</option> |
155 <option value="text/cubicweb-page-template">text/cubicweb-page-template</option> |
156 <option value="text/html">text/html</option> |
156 <option value="text/html">text/html</option> |
157 <option value="text/plain">text/plain</option> |
157 <option value="text/plain">text/plain</option> |
158 <option selected="selected" value="text/rest">text/rest</option> |
158 <option selected="selected" value="text/rest">text/rest</option> |
159 </select><textarea cols="80" id="description:%(eid)s" name="description:%(eid)s" onkeyup="autogrow(this)" rows="2" tabindex="1"/>''') |
159 </select><textarea cols="80" id="description:%(eid)s" name="description:%(eid)s" onkeyup="autogrow(this)" rows="2" tabindex="1"></textarea>''') |
160 |
160 |
161 |
161 |
162 def test_richtextfield_2(self): |
162 def test_richtextfield_2(self): |
163 self.req.use_fckeditor = lambda: True |
163 self.req.use_fckeditor = lambda: True |
164 self._test_richtextfield('<input name="description_format:%(eid)s" style="display: block" type="hidden" value="text/rest"/><textarea cols="80" cubicweb:type="wysiwyg" id="description:%(eid)s" name="description:%(eid)s" onkeyup="autogrow(this)" rows="2" tabindex="0"/>') |
164 self._test_richtextfield('<input name="description_format:%(eid)s" style="display: block" type="hidden" value="text/rest"></input><textarea cols="80" cubicweb:type="wysiwyg" id="description:%(eid)s" name="description:%(eid)s" onkeyup="autogrow(this)" rows="2" tabindex="0"></textarea>') |
165 |
165 |
166 |
166 |
167 def test_filefield(self): |
167 def test_filefield(self): |
168 class FFForm(EntityFieldsForm): |
168 class FFForm(EntityFieldsForm): |
169 data = FileField(format_field=StringField(name='data_format', max_length=50), |
169 data = FileField(format_field=StringField(name='data_format', max_length=50), |
170 encoding_field=StringField(name='data_encoding', max_length=20)) |
170 encoding_field=StringField(name='data_encoding', max_length=20)) |
171 file = self.add_entity('File', name=u"pouet.txt", data_encoding=u'UTF-8', |
171 file = self.add_entity('File', name=u"pouet.txt", data_encoding=u'UTF-8', |
172 data=Binary('new widgets system')) |
172 data=Binary('new widgets system')) |
173 form = FFForm(self.req, redirect_path='perdu.com', entity=file) |
173 form = FFForm(self.req, redirect_path='perdu.com', entity=file) |
174 self.assertTextEquals(self._render_entity_field('data', form), |
174 self.assertTextEquals(self._render_entity_field('data', form), |
175 '''<input id="data:%(eid)s" name="data:%(eid)s" tabindex="0" type="file" value=""/> |
175 '''<input id="data:%(eid)s" name="data:%(eid)s" tabindex="0" type="file" value=""></input> |
176 <a href="javascript: toggleVisibility('data:%(eid)s-advanced')" title="show advanced fields"><img src="http://testing.fr/cubicweb/data/puce_down.png" alt="show advanced fields"/></a> |
176 <a href="javascript: toggleVisibility('data:%(eid)s-advanced')" title="show advanced fields"><img src="http://testing.fr/cubicweb/data/puce_down.png" alt="show advanced fields"/></a> |
177 <div id="data:%(eid)s-advanced" class="hidden"> |
177 <div id="data:%(eid)s-advanced" class="hidden"> |
178 <label for="data_format:%(eid)s">data_format</label><input id="data_format:%(eid)s" maxlength="50" name="data_format:%(eid)s" size="45" tabindex="1" type="text" value="text/plain"/><br/> |
178 <label for="data_format:%(eid)s">data_format</label><input id="data_format:%(eid)s" maxlength="50" name="data_format:%(eid)s" size="45" tabindex="1" type="text" value="text/plain"></input><br/> |
179 <label for="data_encoding:%(eid)s">data_encoding</label><input id="data_encoding:%(eid)s" maxlength="20" name="data_encoding:%(eid)s" size="20" tabindex="2" type="text" value="UTF-8"/><br/> |
179 <label for="data_encoding:%(eid)s">data_encoding</label><input id="data_encoding:%(eid)s" maxlength="20" name="data_encoding:%(eid)s" size="20" tabindex="2" type="text" value="UTF-8"></input><br/> |
180 </div> |
180 </div> |
181 <br/> |
181 <br/> |
182 <input name="data:%(eid)s__detach" type="checkbox"/> |
182 <input name="data:%(eid)s__detach" type="checkbox"></input> |
183 detach attached file |
183 detach attached file |
184 ''' % {'eid': file.eid}) |
184 ''' % {'eid': file.eid}) |
185 |
185 |
186 |
186 |
187 def test_editablefilefield(self): |
187 def test_editablefilefield(self): |
194 return 'text/plain' |
194 return 'text/plain' |
195 file = self.add_entity('File', name=u"pouet.txt", data_encoding=u'UTF-8', |
195 file = self.add_entity('File', name=u"pouet.txt", data_encoding=u'UTF-8', |
196 data=Binary('new widgets system')) |
196 data=Binary('new widgets system')) |
197 form = EFFForm(self.req, redirect_path='perdu.com', entity=file) |
197 form = EFFForm(self.req, redirect_path='perdu.com', entity=file) |
198 self.assertTextEquals(self._render_entity_field('data', form), |
198 self.assertTextEquals(self._render_entity_field('data', form), |
199 '''<input id="data:%(eid)s" name="data:%(eid)s" tabindex="0" type="file" value=""/> |
199 '''<input id="data:%(eid)s" name="data:%(eid)s" tabindex="0" type="file" value=""></input> |
200 <a href="javascript: toggleVisibility('data:%(eid)s-advanced')" title="show advanced fields"><img src="http://testing.fr/cubicweb/data/puce_down.png" alt="show advanced fields"/></a> |
200 <a href="javascript: toggleVisibility('data:%(eid)s-advanced')" title="show advanced fields"><img src="http://testing.fr/cubicweb/data/puce_down.png" alt="show advanced fields"/></a> |
201 <div id="data:%(eid)s-advanced" class="hidden"> |
201 <div id="data:%(eid)s-advanced" class="hidden"> |
202 <label for="data_format:%(eid)s">data_format</label><input id="data_format:%(eid)s" maxlength="50" name="data_format:%(eid)s" size="45" tabindex="1" type="text" value="text/plain"/><br/> |
202 <label for="data_format:%(eid)s">data_format</label><input id="data_format:%(eid)s" maxlength="50" name="data_format:%(eid)s" size="45" tabindex="1" type="text" value="text/plain"></input><br/> |
203 <label for="data_encoding:%(eid)s">data_encoding</label><input id="data_encoding:%(eid)s" maxlength="20" name="data_encoding:%(eid)s" size="20" tabindex="2" type="text" value="UTF-8"/><br/> |
203 <label for="data_encoding:%(eid)s">data_encoding</label><input id="data_encoding:%(eid)s" maxlength="20" name="data_encoding:%(eid)s" size="20" tabindex="2" type="text" value="UTF-8"></input><br/> |
204 </div> |
204 </div> |
205 <br/> |
205 <br/> |
206 <input name="data:%(eid)s__detach" type="checkbox"/> |
206 <input name="data:%(eid)s__detach" type="checkbox"></input> |
207 detach attached file |
207 detach attached file |
208 <p><b>You can either submit a new file using the browse button above, or choose to remove already uploaded file by checking the "detach attached file" check-box, or edit file content online with the widget below.</b></p> |
208 <p><b>You can either submit a new file using the browse button above, or choose to remove already uploaded file by checking the "detach attached file" check-box, or edit file content online with the widget below.</b></p> |
209 <textarea cols="80" name="data:%(eid)s" onkeyup="autogrow(this)" rows="3" tabindex="3">new widgets system</textarea>''' % {'eid': file.eid}) |
209 <textarea cols="80" name="data:%(eid)s" onkeyup="autogrow(this)" rows="3" tabindex="3">new widgets system</textarea>''' % {'eid': file.eid}) |
210 |
210 |
211 |
211 |
212 def test_passwordfield(self): |
212 def test_passwordfield(self): |
213 class PFForm(EntityFieldsForm): |
213 class PFForm(EntityFieldsForm): |
214 upassword = StringField(widget=PasswordInput) |
214 upassword = StringField(widget=PasswordInput) |
215 form = PFForm(self.req, redirect_path='perdu.com', entity=self.entity) |
215 form = PFForm(self.req, redirect_path='perdu.com', entity=self.entity) |
216 self.assertTextEquals(self._render_entity_field('upassword', form), |
216 self.assertTextEquals(self._render_entity_field('upassword', form), |
217 '''<input id="upassword:%(eid)s" name="upassword:%(eid)s" tabindex="0" type="password" value="__cubicweb_internal_field__"/> |
217 '''<input id="upassword:%(eid)s" name="upassword:%(eid)s" tabindex="0" type="password" value="__cubicweb_internal_field__"></input> |
218 <br/> |
218 <br/> |
219 <input name="upassword-confirm:%(eid)s" tabindex="0" type="password" value="__cubicweb_internal_field__"/> |
219 <input name="upassword-confirm:%(eid)s" tabindex="0" type="password" value="__cubicweb_internal_field__"></input> |
220 |
220 |
221 <span class="emphasis">confirm password</span>''' % {'eid': self.entity.eid}) |
221 <span class="emphasis">confirm password</span>''' % {'eid': self.entity.eid}) |
222 |
222 |
223 |
223 |
224 def test_datefield(self): |
224 def test_datefield(self): |