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
1=== modified file 'data/ui.glade'
2--- data/ui.glade 2010-08-25 18:12:58 +0000
3+++ data/ui.glade 2010-08-25 22:30:57 +0000
4@@ -59,9 +59,6 @@
5 <property name="visible">True</property>
6 <property name="spacing">10</property>
7 <child>
8- <placeholder/>
9- </child>
10- <child>
11 <object class="GtkLabel" id="name_warning_label">
12 <property name="visible">True</property>
13 <property name="wrap">True</property>
14@@ -126,6 +123,9 @@
15 </packing>
16 </child>
17 <child>
18+ <placeholder/>
19+ </child>
20+ <child>
21 <object class="GtkLabel" id="password_warning_label">
22 <property name="visible">True</property>
23 <property name="wrap">True</property>
24@@ -135,30 +135,81 @@
25 </packing>
26 </child>
27 <child>
28- <placeholder/>
29- </child>
30- <child>
31- <object class="GtkEventBox" id="captcha_loading">
32- <property name="width_request">300</property>
33- <property name="height_request">60</property>
34- <property name="visible">True</property>
35- <child>
36- <placeholder/>
37- </child>
38- </object>
39- <packing>
40- <property name="expand">False</property>
41- <property name="fill">False</property>
42- <property name="position">8</property>
43- </packing>
44- </child>
45- <child>
46- <object class="GtkImage" id="captcha_image">
47- <property name="visible">True</property>
48- <property name="stock">gtk-missing-image</property>
49- </object>
50- <packing>
51- <property name="position">9</property>
52+ <object class="GtkHBox" id="hbox1">
53+ <property name="visible">True</property>
54+ <child>
55+ <object class="GtkVBox" id="captcha_vbox">
56+ <property name="visible">True</property>
57+ <property name="homogeneous">True</property>
58+ <child>
59+ <object class="GtkEventBox" id="captcha_loading">
60+ <property name="width_request">300</property>
61+ <property name="height_request">60</property>
62+ <property name="visible">True</property>
63+ <child>
64+ <placeholder/>
65+ </child>
66+ </object>
67+ <packing>
68+ <property name="expand">False</property>
69+ <property name="fill">False</property>
70+ <property name="position">0</property>
71+ </packing>
72+ </child>
73+ <child>
74+ <object class="GtkImage" id="captcha_image">
75+ <property name="width_request">300</property>
76+ <property name="height_request">60</property>
77+ <property name="visible">True</property>
78+ <property name="stock">gtk-missing-image</property>
79+ </object>
80+ <packing>
81+ <property name="position">1</property>
82+ </packing>
83+ </child>
84+ </object>
85+ <packing>
86+ <property name="position">0</property>
87+ </packing>
88+ </child>
89+ <child>
90+ <object class="GtkVBox" id="vbox1">
91+ <property name="visible">True</property>
92+ <child>
93+ <object class="GtkButton" id="captcha_reload_button">
94+ <property name="visible">True</property>
95+ <property name="can_focus">True</property>
96+ <property name="receives_default">True</property>
97+ <property name="relief">none</property>
98+ <property name="focus_on_click">False</property>
99+ <signal name="clicked" handler="on_captcha_reload_button_clicked"/>
100+ <child>
101+ <object class="GtkImage" id="image1">
102+ <property name="visible">True</property>
103+ <property name="icon_name">reload</property>
104+ </object>
105+ </child>
106+ </object>
107+ <packing>
108+ <property name="expand">False</property>
109+ <property name="position">0</property>
110+ </packing>
111+ </child>
112+ <child>
113+ <placeholder/>
114+ </child>
115+ <child>
116+ <placeholder/>
117+ </child>
118+ </object>
119+ <packing>
120+ <property name="expand">False</property>
121+ <property name="position">1</property>
122+ </packing>
123+ </child>
124+ </object>
125+ <packing>
126+ <property name="position">7</property>
127 </packing>
128 </child>
129 <child>
130@@ -179,7 +230,7 @@
131 </child>
132 </object>
133 <packing>
134- <property name="position">10</property>
135+ <property name="position">8</property>
136 </packing>
137 </child>
138 <child>
139@@ -193,7 +244,7 @@
140 </object>
141 <packing>
142 <property name="expand">False</property>
143- <property name="position">11</property>
144+ <property name="position">9</property>
145 </packing>
146 </child>
147 <child>
148@@ -231,7 +282,7 @@
149 </object>
150 <packing>
151 <property name="expand">False</property>
152- <property name="position">12</property>
153+ <property name="position">10</property>
154 </packing>
155 </child>
156 <child>
157@@ -240,7 +291,7 @@
158 <property name="wrap">True</property>
159 </object>
160 <packing>
161- <property name="position">13</property>
162+ <property name="position">11</property>
163 </packing>
164 </child>
165 <child>
166@@ -280,7 +331,7 @@
167 </object>
168 <packing>
169 <property name="expand">False</property>
170- <property name="position">14</property>
171+ <property name="position">12</property>
172 </packing>
173 </child>
174 <child>
175@@ -295,9 +346,12 @@
176 </object>
177 <packing>
178 <property name="expand">False</property>
179- <property name="position">15</property>
180+ <property name="position">13</property>
181 </packing>
182 </child>
183+ <child>
184+ <placeholder/>
185+ </child>
186 </object>
187 <object class="GtkVBox" id="processing_vbox">
188 <property name="visible">True</property>
189
190=== modified file 'ubuntu_sso/gui.py'
191--- ubuntu_sso/gui.py 2010-08-25 18:12:58 +0000
192+++ ubuntu_sso/gui.py 2010-08-25 22:30:57 +0000
193@@ -214,6 +214,7 @@
194 'An example is shown below.')
195 YES_TO_TC = _('I agree with the %(app_name)s ') # Terms&Conditions button
196 YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.')
197+ CAPTCHA_RELOAD_TOOLTIP = _('Reload')
198
199 def __init__(self, app_name, tc_uri, help_text,
200 window_id=0, login_only=False, close_callback=None):
201@@ -274,6 +275,7 @@
202 assert getattr(self, name) is not None
203
204 self.window.set_icon_name('ubuntu-logo')
205+ self.captcha_reload_button.set_tooltip_text(self.CAPTCHA_RELOAD_TOOLTIP)
206
207 self.bus = dbus.SessionBus()
208 self.bus.add_signal_receiver = self._log(self.bus.add_signal_receiver)
209@@ -434,6 +436,14 @@
210 else:
211 page.hide()
212
213+ def _generate_captcha(self):
214+ """Ask for a new captcha; update the ui to reflect the fact."""
215+ logger.info('Calling generate_captcha with filename path at %r',
216+ self._captcha_filename)
217+ self.backend.generate_captcha(self.app_name, self._captcha_filename,
218+ reply_handler=NO_OP, error_handler=NO_OP)
219+ self._set_captcha_loading()
220+
221 def _set_captcha_loading(self):
222 """Present a spinner to the user while the captcha is downloaded."""
223 self.captcha_image.hide()
224@@ -472,7 +482,7 @@
225 self.password_help_label.set_markup(help_msg)
226
227 if not os.path.exists(self._captcha_filename):
228- self._set_captcha_loading()
229+ self._generate_captcha()
230 else:
231 self._set_captcha_image()
232
233@@ -486,12 +496,6 @@
234 self.tc_hbox.hide_all()
235 self.login_button.set_label(self.LOGIN_BUTTON_LABEL)
236
237- logger.info('Calling generate_captcha with filename path at %r',
238- self._captcha_filename)
239- f = self.backend.generate_captcha
240- f(self.app_name, self._captcha_filename,
241- reply_handler=NO_OP, error_handler=NO_OP)
242-
243 return self.enter_details_vbox
244
245 def _build_tc_page(self):
246@@ -817,6 +821,10 @@
247 browser.destroy()
248 del browser
249
250+ def on_captcha_reload_button_clicked(self, *args, **kwargs):
251+ """User clicked the reload captcha button."""
252+ self._generate_captcha()
253+
254 # backend callbacks
255
256 @log_call
257
258=== modified file 'ubuntu_sso/tests/test_gui.py'
259--- ubuntu_sso/tests/test_gui.py 2010-08-25 18:12:58 +0000
260+++ ubuntu_sso/tests/test_gui.py 2010-08-25 22:30:57 +0000
261@@ -711,6 +711,23 @@
262 self.assertTrue(self.ui.captcha_image.get_property('visible'))
263 self.assertEqual(self._called, ((self.ui._captcha_filename,), {}))
264
265+ def test_captcha_reload_button_visible(self):
266+ """The captcha reload button is initially visible."""
267+ self.assertTrue(self.ui.captcha_reload_button.get_visible(),
268+ "The captcha button is not visible")
269+
270+ def test_captcha_reload_button_reloads_captcha(self):
271+ """The captcha reload button loads a new captcha."""
272+ self.ui.on_captcha_generated(app_name=APP_NAME, captcha_id=CAPTCHA_ID)
273+ self.patch(self.ui, '_generate_captcha', self._set_called)
274+ self.ui.captcha_reload_button.clicked()
275+ self.assertEqual(self._called, ((), {}))
276+
277+ def test_captcha_reload_button_has_tooltip(self):
278+ """The captcha reload button has a tooltip."""
279+ self.assertEqual(self.ui.captcha_reload_button.get_tooltip_text(),
280+ self.ui.CAPTCHA_RELOAD_TOOLTIP)
281+
282 def test_login_button_has_correct_wording(self):
283 """The sign in button has the proper wording."""
284 actual = self.ui.login_button.get_label()

Subscribers

People subscribed via source and target branches