Merge lp:~chipaca/ubuntu-sso-client/reload-captcha into lp:ubuntu-sso-client

Proposed by John Lenton
Status: Merged
Approved by: Vincenzo Di Somma
Approved revision: 591
Merged at revision: 592
Proposed branch: lp:~chipaca/ubuntu-sso-client/reload-captcha
Merge into: lp:ubuntu-sso-client
Diff against target: 284 lines (+119/-40)
3 files modified
data/ui.glade (+87/-33)
ubuntu_sso/gui.py (+15/-7)
ubuntu_sso/tests/test_gui.py (+17/-0)
To merge this branch: bzr merge lp:~chipaca/ubuntu-sso-client/reload-captcha
Reviewer Review Type Date Requested Status
Vincenzo Di Somma (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+33703@code.launchpad.net

Description of the change

* added a reload button for the captcha (LP: #616459).

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Gorgeous.

review: Approve
592. By John Lenton

tweaks and cleanups as per nessa

593. By John Lenton

added a tooltip to the reload button

Revision history for this message
Vincenzo Di Somma (vds) wrote :

Works! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/ui.glade'
--- data/ui.glade 2010-08-25 18:12:58 +0000
+++ data/ui.glade 2010-08-25 22:30:57 +0000
@@ -59,9 +59,6 @@
59 <property name="visible">True</property>59 <property name="visible">True</property>
60 <property name="spacing">10</property>60 <property name="spacing">10</property>
61 <child>61 <child>
62 <placeholder/>
63 </child>
64 <child>
65 <object class="GtkLabel" id="name_warning_label">62 <object class="GtkLabel" id="name_warning_label">
66 <property name="visible">True</property>63 <property name="visible">True</property>
67 <property name="wrap">True</property>64 <property name="wrap">True</property>
@@ -126,6 +123,9 @@
126 </packing>123 </packing>
127 </child>124 </child>
128 <child>125 <child>
126 <placeholder/>
127 </child>
128 <child>
129 <object class="GtkLabel" id="password_warning_label">129 <object class="GtkLabel" id="password_warning_label">
130 <property name="visible">True</property>130 <property name="visible">True</property>
131 <property name="wrap">True</property>131 <property name="wrap">True</property>
@@ -135,30 +135,81 @@
135 </packing>135 </packing>
136 </child>136 </child>
137 <child>137 <child>
138 <placeholder/>138 <object class="GtkHBox" id="hbox1">
139 </child>139 <property name="visible">True</property>
140 <child>140 <child>
141 <object class="GtkEventBox" id="captcha_loading">141 <object class="GtkVBox" id="captcha_vbox">
142 <property name="width_request">300</property>142 <property name="visible">True</property>
143 <property name="height_request">60</property>143 <property name="homogeneous">True</property>
144 <property name="visible">True</property>144 <child>
145 <child>145 <object class="GtkEventBox" id="captcha_loading">
146 <placeholder/>146 <property name="width_request">300</property>
147 </child>147 <property name="height_request">60</property>
148 </object>148 <property name="visible">True</property>
149 <packing>149 <child>
150 <property name="expand">False</property>150 <placeholder/>
151 <property name="fill">False</property>151 </child>
152 <property name="position">8</property>152 </object>
153 </packing>153 <packing>
154 </child>154 <property name="expand">False</property>
155 <child>155 <property name="fill">False</property>
156 <object class="GtkImage" id="captcha_image">156 <property name="position">0</property>
157 <property name="visible">True</property>157 </packing>
158 <property name="stock">gtk-missing-image</property>158 </child>
159 </object>159 <child>
160 <packing>160 <object class="GtkImage" id="captcha_image">
161 <property name="position">9</property>161 <property name="width_request">300</property>
162 <property name="height_request">60</property>
163 <property name="visible">True</property>
164 <property name="stock">gtk-missing-image</property>
165 </object>
166 <packing>
167 <property name="position">1</property>
168 </packing>
169 </child>
170 </object>
171 <packing>
172 <property name="position">0</property>
173 </packing>
174 </child>
175 <child>
176 <object class="GtkVBox" id="vbox1">
177 <property name="visible">True</property>
178 <child>
179 <object class="GtkButton" id="captcha_reload_button">
180 <property name="visible">True</property>
181 <property name="can_focus">True</property>
182 <property name="receives_default">True</property>
183 <property name="relief">none</property>
184 <property name="focus_on_click">False</property>
185 <signal name="clicked" handler="on_captcha_reload_button_clicked"/>
186 <child>
187 <object class="GtkImage" id="image1">
188 <property name="visible">True</property>
189 <property name="icon_name">reload</property>
190 </object>
191 </child>
192 </object>
193 <packing>
194 <property name="expand">False</property>
195 <property name="position">0</property>
196 </packing>
197 </child>
198 <child>
199 <placeholder/>
200 </child>
201 <child>
202 <placeholder/>
203 </child>
204 </object>
205 <packing>
206 <property name="expand">False</property>
207 <property name="position">1</property>
208 </packing>
209 </child>
210 </object>
211 <packing>
212 <property name="position">7</property>
162 </packing>213 </packing>
163 </child>214 </child>
164 <child>215 <child>
@@ -179,7 +230,7 @@
179 </child>230 </child>
180 </object>231 </object>
181 <packing>232 <packing>
182 <property name="position">10</property>233 <property name="position">8</property>
183 </packing>234 </packing>
184 </child>235 </child>
185 <child>236 <child>
@@ -193,7 +244,7 @@
193 </object>244 </object>
194 <packing>245 <packing>
195 <property name="expand">False</property>246 <property name="expand">False</property>
196 <property name="position">11</property>247 <property name="position">9</property>
197 </packing>248 </packing>
198 </child>249 </child>
199 <child>250 <child>
@@ -231,7 +282,7 @@
231 </object>282 </object>
232 <packing>283 <packing>
233 <property name="expand">False</property>284 <property name="expand">False</property>
234 <property name="position">12</property>285 <property name="position">10</property>
235 </packing>286 </packing>
236 </child>287 </child>
237 <child>288 <child>
@@ -240,7 +291,7 @@
240 <property name="wrap">True</property>291 <property name="wrap">True</property>
241 </object>292 </object>
242 <packing>293 <packing>
243 <property name="position">13</property>294 <property name="position">11</property>
244 </packing>295 </packing>
245 </child>296 </child>
246 <child>297 <child>
@@ -280,7 +331,7 @@
280 </object>331 </object>
281 <packing>332 <packing>
282 <property name="expand">False</property>333 <property name="expand">False</property>
283 <property name="position">14</property>334 <property name="position">12</property>
284 </packing>335 </packing>
285 </child>336 </child>
286 <child>337 <child>
@@ -295,9 +346,12 @@
295 </object>346 </object>
296 <packing>347 <packing>
297 <property name="expand">False</property>348 <property name="expand">False</property>
298 <property name="position">15</property>349 <property name="position">13</property>
299 </packing>350 </packing>
300 </child>351 </child>
352 <child>
353 <placeholder/>
354 </child>
301 </object>355 </object>
302 <object class="GtkVBox" id="processing_vbox">356 <object class="GtkVBox" id="processing_vbox">
303 <property name="visible">True</property>357 <property name="visible">True</property>
304358
=== modified file 'ubuntu_sso/gui.py'
--- ubuntu_sso/gui.py 2010-08-25 18:12:58 +0000
+++ ubuntu_sso/gui.py 2010-08-25 22:30:57 +0000
@@ -214,6 +214,7 @@
214 'An example is shown below.')214 'An example is shown below.')
215 YES_TO_TC = _('I agree with the %(app_name)s ') # Terms&Conditions button215 YES_TO_TC = _('I agree with the %(app_name)s ') # Terms&Conditions button
216 YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.')216 YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.')
217 CAPTCHA_RELOAD_TOOLTIP = _('Reload')
217218
218 def __init__(self, app_name, tc_uri, help_text,219 def __init__(self, app_name, tc_uri, help_text,
219 window_id=0, login_only=False, close_callback=None):220 window_id=0, login_only=False, close_callback=None):
@@ -274,6 +275,7 @@
274 assert getattr(self, name) is not None275 assert getattr(self, name) is not None
275276
276 self.window.set_icon_name('ubuntu-logo')277 self.window.set_icon_name('ubuntu-logo')
278 self.captcha_reload_button.set_tooltip_text(self.CAPTCHA_RELOAD_TOOLTIP)
277279
278 self.bus = dbus.SessionBus()280 self.bus = dbus.SessionBus()
279 self.bus.add_signal_receiver = self._log(self.bus.add_signal_receiver)281 self.bus.add_signal_receiver = self._log(self.bus.add_signal_receiver)
@@ -434,6 +436,14 @@
434 else:436 else:
435 page.hide()437 page.hide()
436438
439 def _generate_captcha(self):
440 """Ask for a new captcha; update the ui to reflect the fact."""
441 logger.info('Calling generate_captcha with filename path at %r',
442 self._captcha_filename)
443 self.backend.generate_captcha(self.app_name, self._captcha_filename,
444 reply_handler=NO_OP, error_handler=NO_OP)
445 self._set_captcha_loading()
446
437 def _set_captcha_loading(self):447 def _set_captcha_loading(self):
438 """Present a spinner to the user while the captcha is downloaded."""448 """Present a spinner to the user while the captcha is downloaded."""
439 self.captcha_image.hide()449 self.captcha_image.hide()
@@ -472,7 +482,7 @@
472 self.password_help_label.set_markup(help_msg)482 self.password_help_label.set_markup(help_msg)
473483
474 if not os.path.exists(self._captcha_filename):484 if not os.path.exists(self._captcha_filename):
475 self._set_captcha_loading()485 self._generate_captcha()
476 else:486 else:
477 self._set_captcha_image()487 self._set_captcha_image()
478488
@@ -486,12 +496,6 @@
486 self.tc_hbox.hide_all()496 self.tc_hbox.hide_all()
487 self.login_button.set_label(self.LOGIN_BUTTON_LABEL)497 self.login_button.set_label(self.LOGIN_BUTTON_LABEL)
488498
489 logger.info('Calling generate_captcha with filename path at %r',
490 self._captcha_filename)
491 f = self.backend.generate_captcha
492 f(self.app_name, self._captcha_filename,
493 reply_handler=NO_OP, error_handler=NO_OP)
494
495 return self.enter_details_vbox499 return self.enter_details_vbox
496500
497 def _build_tc_page(self):501 def _build_tc_page(self):
@@ -817,6 +821,10 @@
817 browser.destroy()821 browser.destroy()
818 del browser822 del browser
819823
824 def on_captcha_reload_button_clicked(self, *args, **kwargs):
825 """User clicked the reload captcha button."""
826 self._generate_captcha()
827
820 # backend callbacks828 # backend callbacks
821829
822 @log_call830 @log_call
823831
=== modified file 'ubuntu_sso/tests/test_gui.py'
--- ubuntu_sso/tests/test_gui.py 2010-08-25 18:12:58 +0000
+++ ubuntu_sso/tests/test_gui.py 2010-08-25 22:30:57 +0000
@@ -711,6 +711,23 @@
711 self.assertTrue(self.ui.captcha_image.get_property('visible'))711 self.assertTrue(self.ui.captcha_image.get_property('visible'))
712 self.assertEqual(self._called, ((self.ui._captcha_filename,), {}))712 self.assertEqual(self._called, ((self.ui._captcha_filename,), {}))
713713
714 def test_captcha_reload_button_visible(self):
715 """The captcha reload button is initially visible."""
716 self.assertTrue(self.ui.captcha_reload_button.get_visible(),
717 "The captcha button is not visible")
718
719 def test_captcha_reload_button_reloads_captcha(self):
720 """The captcha reload button loads a new captcha."""
721 self.ui.on_captcha_generated(app_name=APP_NAME, captcha_id=CAPTCHA_ID)
722 self.patch(self.ui, '_generate_captcha', self._set_called)
723 self.ui.captcha_reload_button.clicked()
724 self.assertEqual(self._called, ((), {}))
725
726 def test_captcha_reload_button_has_tooltip(self):
727 """The captcha reload button has a tooltip."""
728 self.assertEqual(self.ui.captcha_reload_button.get_tooltip_text(),
729 self.ui.CAPTCHA_RELOAD_TOOLTIP)
730
714 def test_login_button_has_correct_wording(self):731 def test_login_button_has_correct_wording(self):
715 """The sign in button has the proper wording."""732 """The sign in button has the proper wording."""
716 actual = self.ui.login_button.get_label()733 actual = self.ui.login_button.get_label()

Subscribers

People subscribed via source and target branches