Merge lp:~nataliabidart/ubuntuone-control-panel/improve-share-name into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 63
Merged at revision: 63
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/improve-share-name
Merge into: lp:ubuntuone-control-panel
Prerequisite: lp:~nataliabidart/ubuntuone-control-panel/share-subs
Diff against target: 392 lines (+112/-32)
8 files modified
ubuntuone/controlpanel/backend.py (+13/-5)
ubuntuone/controlpanel/dbus_client.py (+16/-0)
ubuntuone/controlpanel/gtk/gui.py (+12/-4)
ubuntuone/controlpanel/gtk/tests/__init__.py (+2/-2)
ubuntuone/controlpanel/gtk/tests/test_gui.py (+2/-0)
ubuntuone/controlpanel/integrationtests/test_dbus_client_sd.py (+28/-0)
ubuntuone/controlpanel/tests/__init__.py (+11/-9)
ubuntuone/controlpanel/tests/test_backend.py (+28/-12)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/improve-share-name
Reviewer Review Type Date Requested Status
Roberto Alsina (community) fieldtest natty Approve
Martin Albisetti (community) Approve
Review via email: mp+49270@code.launchpad.net

Commit message

- Share names are now improved (LP: #716431).

To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) wrote :

86 + NAME_NOT_SET = _('[unknown user name]')

I would capitalise that to "Unknown user name", and maybe drop the brackets.

Branch looks good :)

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve (fieldtest natty)
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/backend.py'
2--- ubuntuone/controlpanel/backend.py 2011-02-10 18:49:00 +0000
3+++ ubuntuone/controlpanel/backend.py 2011-02-10 18:49:00 +0000
4@@ -67,6 +67,7 @@
5 ROOT_TYPE = u'ROOT'
6 FOLDER_TYPE = u'UDF'
7 SHARE_TYPE = u'SHARE'
8+ NAME_NOT_SET = u'ENAMENOTSET'
9
10 def __init__(self):
11 """Initialize the webclient."""
12@@ -340,6 +341,8 @@
13
14 account = yield self.account_info()
15 root_dir = yield dbus_client.get_root_dir()
16+ shares_dir = yield dbus_client.get_shares_dir()
17+ shares_dir_link = yield dbus_client.get_shares_dir_link()
18 folders = yield dbus_client.get_folders()
19 shares = yield dbus_client.get_shares()
20
21@@ -360,10 +363,15 @@
22 if not bool(share['accepted']):
23 continue
24
25+ nicer_path = share[u'path'].replace(shares_dir, shares_dir_link)
26+ share[u'path'] = nicer_path
27+
28 username = share['other_visible_name']
29- key = (username if username else share['other_username'],
30- share['free_bytes'])
31- shares_result[key].append(share)
32+ if not username:
33+ username = u'%s (%s)' % (share['other_username'],
34+ self.NAME_NOT_SET)
35+
36+ shares_result[username].append(share)
37
38 for folder in folders:
39 folder[u'type'] = self.FOLDER_TYPE
40@@ -374,8 +382,8 @@
41
42 result = [(u'', unicode(free_bytes), [root_volume] + folders)]
43
44- for (other_username, free_bytes), shares in shares_result.iteritems():
45- result.append((other_username, free_bytes, shares))
46+ for other_username, shares in shares_result.iteritems():
47+ result.append((other_username, shares[0][u'free_bytes'], shares))
48
49 returnValue(result)
50
51
52=== modified file 'ubuntuone/controlpanel/dbus_client.py'
53--- ubuntuone/controlpanel/dbus_client.py 2011-02-10 18:49:00 +0000
54+++ ubuntuone/controlpanel/dbus_client.py 2011-02-10 18:49:00 +0000
55@@ -221,6 +221,22 @@
56 return d
57
58
59+def get_shares_dir():
60+ """Retrieve the shares information from syncdaemon."""
61+ d = defer.Deferred()
62+ proxy = get_syncdaemon_proxy("/", sd_dbus_iface.DBUS_IFACE_SYNC_NAME)
63+ proxy.get_sharesdir(reply_handler=d.callback, error_handler=d.errback)
64+ return d
65+
66+
67+def get_shares_dir_link():
68+ """Retrieve the shares information from syncdaemon."""
69+ d = defer.Deferred()
70+ proxy = get_syncdaemon_proxy("/", sd_dbus_iface.DBUS_IFACE_SYNC_NAME)
71+ proxy.get_sharesdir_link(reply_handler=d.callback, error_handler=d.errback)
72+ return d
73+
74+
75 def get_folders():
76 """Retrieve the folders information from syncdaemon."""
77 d = defer.Deferred()
78
79=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
80--- ubuntuone/controlpanel/gtk/gui.py 2011-02-10 18:49:00 +0000
81+++ ubuntuone/controlpanel/gtk/gui.py 2011-02-10 18:49:00 +0000
82@@ -431,6 +431,7 @@
83 '<span foreground="grey">%s</span>'
84 ROOT = '%s - <span foreground="%s" font_size="small">%s</span>'
85 NO_VOLUMES = _('No folders to show.')
86+ NAME_NOT_SET = _('[unknown user name]')
87
88 def __init__(self, main_window=None):
89 UbuntuOneBin.__init__(self)
90@@ -467,6 +468,9 @@
91 empty_row = ('', False, '', False, False, gtk.ICON_SIZE_MENU, None)
92
93 for name, free_bytes, volumes in info:
94+ if backend.ControlBackend.NAME_NOT_SET in name:
95+ name = self.NAME_NOT_SET
96+
97 if name:
98 name = name + "'s"
99 icon_name = self.SHARE_ICON_NAME
100@@ -486,15 +490,19 @@
101 volumes.sort(key=operator.itemgetter('path'))
102 for volume in volumes:
103 sensitive = True
104- path = self._process_path(volume['path'])
105- is_root = volume['type'] == backend.ControlBackend.ROOT_TYPE
106+ path = self._process_path(volume[u'path'])
107+
108+ is_root = volume[u'type'] == backend.ControlBackend.ROOT_TYPE
109+ is_share = volume[u'type'] == backend.ControlBackend.SHARE_TYPE
110
111 if is_root:
112 sensitive = False
113 path = self.ROOT % (path, ORANGE, self.ALWAYS_SUBSCRIBED)
114+ elif is_share:
115+ path = volume[u'name']
116
117- row = (path, bool(volume['subscribed']), icon_name, True,
118- sensitive, gtk.ICON_SIZE_MENU, volume['volume_id'])
119+ row = (path, bool(volume[u'subscribed']), icon_name, True,
120+ sensitive, gtk.ICON_SIZE_MENU, volume[u'volume_id'])
121
122 if is_root: # root should go first!
123 self.volumes_store.prepend(treeiter, row)
124
125=== modified file 'ubuntuone/controlpanel/gtk/tests/__init__.py'
126--- ubuntuone/controlpanel/gtk/tests/__init__.py 2011-01-24 22:14:53 +0000
127+++ ubuntuone/controlpanel/gtk/tests/__init__.py 2011-02-10 18:49:00 +0000
128@@ -45,11 +45,11 @@
129 ]
130
131 FAKE_SHARES_INFO = [
132- {u'volume_id': u'1234',
133+ {u'volume_id': u'1234', u'name': u'do',
134 u'path': u'/home/tester/.local/share/ubuntuone/shares/do from Other User',
135 u'subscribed': u'', u'type': u'SHARE'},
136
137- {u'volume_id': u'5678',
138+ {u'volume_id': u'5678', u'name': u're',
139 u'path': u'/home/tester/.local/share/ubuntuone/shares/re from Other User',
140 u'subscribed': u'True', u'type': u'SHARE'},
141 ]
142
143=== modified file 'ubuntuone/controlpanel/gtk/tests/test_gui.py'
144--- ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-02-10 18:49:00 +0000
145+++ ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-02-10 18:49:00 +0000
146@@ -869,6 +869,8 @@
147 sensitive = False
148 path = self.ui.ROOT % (path, gui.ORANGE,
149 self.ui.ALWAYS_SUBSCRIBED)
150+ elif volume['type'] == 'SHARE':
151+ path = volume['name']
152
153 self.assertEqual(row[0], path)
154 self.assertEqual(row[1], bool(volume['subscribed']))
155
156=== modified file 'ubuntuone/controlpanel/integrationtests/test_dbus_client_sd.py'
157--- ubuntuone/controlpanel/integrationtests/test_dbus_client_sd.py 2011-02-10 18:49:00 +0000
158+++ ubuntuone/controlpanel/integrationtests/test_dbus_client_sd.py 2011-02-10 18:49:00 +0000
159@@ -701,6 +701,8 @@
160 """A mock object that mimicks syncdaemon."""
161
162 ROOT_DIR = u'/yadda/yoda/Test me'
163+ SHARES_DIR = u'/yadda/yoda/.hidden/ugly/dir/name/shares'
164+ SHARES_DIR_LINK = u'/yadda/yoda/Test me/Shared With Me'
165
166 @dbus.service.method(sd_dbus_iface.DBUS_IFACE_SYNC_NAME,
167 in_signature='', out_signature='s')
168@@ -708,6 +710,18 @@
169 """Return the root dir/mount point."""
170 return self.ROOT_DIR
171
172+ @dbus.service.method(sd_dbus_iface.DBUS_IFACE_SYNC_NAME,
173+ in_signature='', out_signature='s')
174+ def get_sharesdir(self):
175+ """Return the shares dir/mount point."""
176+ return self.SHARES_DIR
177+
178+ @dbus.service.method(sd_dbus_iface.DBUS_IFACE_SYNC_NAME,
179+ in_signature='', out_signature='s')
180+ def get_sharesdir_link(self):
181+ """Return the root dir/mount point."""
182+ return self.SHARES_DIR_LINK
183+
184
185 class BasicTestCase(DBusClientTestCase):
186 """Test for the basic dbus client methods."""
187@@ -723,3 +737,17 @@
188 root = yield dbus_client.get_root_dir()
189
190 self.assertEqual(MockDBusSyncDaemon.ROOT_DIR, root)
191+
192+ @inlineCallbacks
193+ def test_get_shares_dir(self):
194+ """Retrieve current syncdaemon shares dir."""
195+ result = yield dbus_client.get_shares_dir()
196+
197+ self.assertEqual(MockDBusSyncDaemon.SHARES_DIR, result)
198+
199+ @inlineCallbacks
200+ def test_get_shares_dir_link(self):
201+ """Retrieve current syncdaemon shares dir."""
202+ result = yield dbus_client.get_shares_dir_link()
203+
204+ self.assertEqual(MockDBusSyncDaemon.SHARES_DIR_LINK, result)
205
206=== modified file 'ubuntuone/controlpanel/tests/__init__.py'
207--- ubuntuone/controlpanel/tests/__init__.py 2011-02-10 18:49:00 +0000
208+++ ubuntuone/controlpanel/tests/__init__.py 2011-02-10 18:49:00 +0000
209@@ -161,7 +161,9 @@
210 u'volume_id': u'1deb2874-3d28-46ae-9999-d5f48de9f460'},
211 ]
212
213-SHARE_PATH = u'/home/tester/.local/share/ubuntuone/shares/%s'
214+ROOT_PATH = u'/home/tester/Ubuntu One'
215+SHARES_PATH = u'/home/tester/.local/share/ubuntuone/shares'
216+SHARES_PATH_LINK = ROOT_PATH + u'/Shared With Me'
217
218 SAMPLE_SHARES = [
219
220@@ -174,7 +176,7 @@
221 u'node_id': u'c483f419-ed28-490a-825d-a8c074e2d795',
222 u'other_username': u'otheruser',
223 u'other_visible_name': u'Other User',
224- u'path': SHARE_PATH % u're from Other User',
225+ u'path': SHARES_PATH + u'/re from Other User',
226 u'type': u'Share',
227 u'volume_id': u'4a1b263b-a2b3-4f66-9e66-4cd18050810d'},
228
229@@ -187,7 +189,7 @@
230 u'node_id': u'84544ea4-aefe-4f91-9bb9-ed7b0a805baf',
231 u'other_username': u'otheruser',
232 u'other_visible_name': u'Other User',
233- u'path': SHARE_PATH % u'do from Other User',
234+ u'path': SHARES_PATH + u'/do from Other User',
235 u'type': u'Share',
236 u'volume_id': u'7d130dfe-98b2-4bd5-8708-9eeba9838ac0'},
237
238@@ -200,7 +202,7 @@
239 u'node_id': u'ca3a1cec-09d2-485e-9685-1a5180bd6441',
240 u'volume_id': u'f1f1741f-ba49-46ef-b682-816c97e6e3d6',
241 u'free_bytes': u'2146703403',
242- u'path': SHARE_PATH % u'yadda from ',
243+ u'path': SHARES_PATH + u'/yadda from ',
244 u'accepted': u'True',
245 u'type': u'Share'},
246
247@@ -216,7 +218,7 @@
248 u'volume_id':
249 u'a73f889d-ffd3-4447-b351-f0d8130d1e1a',
250 u'free_bytes': u'2146703403',
251- u'path': SHARE_PATH % u'images from ',
252+ u'path': SHARES_PATH + u'/images from ',
253 u'accepted': u'True',
254 u'type': u'Share'},
255
256@@ -230,7 +232,7 @@
257 u'volume_id':
258 u'64b43c96-6c7c-4135-994f-03a1a3774512',
259 u'free_bytes': u'108786811673',
260- u'path': SHARE_PATH % u'read-only from A Sharing User',
261+ u'path': SHARES_PATH + u'/read-only from A Sharing User',
262 u'accepted': u'True',
263 u'type': u'Share'},
264
265@@ -243,7 +245,7 @@
266 u'node_id': u'e95662f7-9979-4745-8c21-8edaf893f143',
267 u'volume_id': u'8896e8f8-57a3-4bf9-8558-fc54b7a3a777',
268 u'free_bytes': u'108786811673',
269- u'path': SHARE_PATH % u'read-write from A Sharing User',
270+ u'path': SHARES_PATH + u'/read-write from A Sharing User',
271 u'accepted': u'True',
272 u'type': u'Share'},
273
274@@ -255,7 +257,7 @@
275 u'node_id': u'67b61c92-855c-49d8-8e09-6d201d15c999',
276 u'other_username': u'bad guy',
277 u'other_visible_name': u'',
278- u'path': u'/home/nessita/.local/share/ubuntuone/shares/unaccepted from ',
279+ u'path': SHARES_PATH + u'/unaccepted from ',
280 u'subscribed': u'',
281 u'type': u'Share',
282 u'volume_id': u'19963c95-c684-48db-8668-ebe6d820d5c3'},
283@@ -270,7 +272,7 @@
284 u'node_id': u'31e47530-9448-4f03-b4dc-4154fdf35225',
285 u'other_username': u'otheruser',
286 u'other_visible_name': u'Other User',
287- u'path': u'/home/tester/Ubuntu One/bar',
288+ u'path': ROOT_PATH + u'/bar',
289 u'type': u'Shared',
290 u'volume_id': u'79584900-517f-4dff-b2f3-20e8c1e79365'},
291 ]
292
293=== modified file 'ubuntuone/controlpanel/tests/test_backend.py'
294--- ubuntuone/controlpanel/tests/test_backend.py 2011-02-10 18:49:00 +0000
295+++ ubuntuone/controlpanel/tests/test_backend.py 2011-02-10 18:49:00 +0000
296@@ -44,6 +44,7 @@
297 EXPECTED_ACCOUNT_INFO,
298 EXPECTED_ACCOUNT_INFO_WITH_CURRENT_PLAN,
299 EXPECTED_DEVICES_INFO,
300+ ROOT_PATH,
301 SAMPLE_ACCOUNT_NO_CURRENT_PLAN,
302 SAMPLE_ACCOUNT_WITH_CURRENT_PLAN,
303 SAMPLE_DEVICES_JSON,
304@@ -51,6 +52,8 @@
305 SAMPLE_QUOTA_JSON,
306 SAMPLE_SHARED,
307 SAMPLE_SHARES,
308+ SHARES_PATH,
309+ SHARES_PATH_LINK,
310 TOKEN,
311 )
312 from ubuntuone.controlpanel.webclient import WebClientError
313@@ -90,7 +93,6 @@
314 subscribed_folders = []
315 subscribed_shares = []
316 actions = []
317- root_dir = u'/home/tester/Something/Pepe Mosquito'
318
319 def get_credentials(self):
320 """Return the mock credentials."""
321@@ -148,7 +150,15 @@
322
323 def get_root_dir(self):
324 """Grab the root dir."""
325- return self.root_dir
326+ return ROOT_PATH
327+
328+ def get_shares_dir(self):
329+ """Grab the shares dir."""
330+ return SHARES_PATH
331+
332+ def get_shares_dir_link(self):
333+ """Grab the shares dir."""
334+ return SHARES_PATH_LINK
335
336 def get_folders(self):
337 """Grab list of folders."""
338@@ -395,8 +405,7 @@
339 free_bytes = int(result['quota_total']) - int(result['quota_used'])
340
341 # get root dir info
342- root_dir = MockDBusClient.root_dir
343- root_volume = {u'volume_id': u'', u'path': root_dir,
344+ root_volume = {u'volume_id': u'', u'path': ROOT_PATH,
345 u'subscribed': 'True', u'type': self.be.ROOT_TYPE}
346
347 # get shares and group by sharing user
348@@ -406,20 +415,28 @@
349 if not bool(share['accepted']):
350 continue
351
352+ share = share.copy()
353+
354+ nicer_path = share[u'path'].replace(SHARES_PATH, SHARES_PATH_LINK)
355+ share[u'path'] = nicer_path
356+ share[u'type'] = self.be.SHARE_TYPE
357+
358 username = share['other_visible_name']
359- key = (username if username else share['other_username'],
360- share['free_bytes'])
361- share[u'type'] = self.be.SHARE_TYPE
362- shares[key].append(share)
363+ if not username:
364+ username = share['other_username'] + \
365+ ' (%s)' % self.be.NAME_NOT_SET
366+
367+ shares[username].append(share)
368
369 folders = []
370 for folder in SAMPLE_FOLDERS:
371+ folder = folder.copy()
372 folder[u'type'] = self.be.FOLDER_TYPE
373 folders.append(folder)
374
375 expected = [(u'', unicode(free_bytes), [root_volume] + folders)]
376- for (other_user, free_bytes), data in shares.iteritems():
377- expected.append((other_user, free_bytes, data))
378+ for other_user, data in shares.iteritems():
379+ expected.append((other_user, data[0][u'free_bytes'], data))
380
381 result = yield self.be.volumes_info()
382 self.assertEqual(result, expected)
383@@ -434,8 +451,7 @@
384 def test_volumes_are_cached(self):
385 """The volume list is cached."""
386 # get root dir info
387- root_dir = MockDBusClient.root_dir
388- root_volume = {u'volume_id': u'', u'path': root_dir,
389+ root_volume = {u'volume_id': u'', u'path': ROOT_PATH,
390 u'subscribed': 'True', u'type': self.be.ROOT_TYPE}
391 expected = {u'': root_volume}
392 for volume in SAMPLE_SHARES + SAMPLE_FOLDERS:

Subscribers

People subscribed via source and target branches