Merge lp:~diegosarmentero/ubuntuone-control-panel/over-quota into lp:ubuntuone-control-panel

Proposed by Diego Sarmentero
Status: Merged
Approved by: Roberto Alsina
Approved revision: 223
Merged at revision: 225
Proposed branch: lp:~diegosarmentero/ubuntuone-control-panel/over-quota
Merge into: lp:ubuntuone-control-panel
Diff against target: 133 lines (+63/-2)
4 files modified
data/qt/controlpanel.ui (+6/-0)
data/qt/ubuntuone.qss (+5/-1)
ubuntuone/controlpanel/gui/qt/controlpanel.py (+28/-1)
ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py (+24/-0)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-control-panel/over-quota
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+74837@code.launchpad.net

Commit message

- Show special legends to the user when s/he has run out of quota (LP: #828983).

Description of the change

Show special legends to the user when s/he has run out of quota.

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

== Python Lint Notices ==

ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py:
    124: [C0111, ControlPanelTestCase.test_update_over_quota] Missing docstring
    126: [W0212, ControlPanelTestCase.test_update_over_quota] Access to a protected member _update_quota of a client class
    133: [C0111, ControlPanelTestCase.test_update_quota_in_range] Missing docstring
    135: [W0212, ControlPanelTestCase.test_update_quota_in_range] Access to a protected member _update_quota of a client class

review: Needs Fixing
219. By Diego Sarmentero

Changed over quota color.
merge.

220. By Diego Sarmentero

Fixed lint issues.
Improved code in update_quota

221. By Diego Sarmentero

Grouped together some styles.

222. By Diego Sarmentero

Grouped together the PROPER style now.

223. By Diego Sarmentero

Removed font size.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

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

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/qt/controlpanel.ui'
2--- data/qt/controlpanel.ui 2011-09-06 15:56:06 +0000
3+++ data/qt/controlpanel.ui 2011-09-09 18:53:28 +0000
4@@ -132,6 +132,9 @@
5 <property name="text">
6 <string notr="true"/>
7 </property>
8+ <property name="OverQuota" stdset="0">
9+ <bool>false</bool>
10+ </property>
11 </widget>
12 </item>
13 <item>
14@@ -144,6 +147,9 @@
15 <property name="text">
16 <string/>
17 </property>
18+ <property name="OverQuota" stdset="0">
19+ <bool>false</bool>
20+ </property>
21 </widget>
22 </item>
23 </layout>
24
25=== modified file 'data/qt/ubuntuone.qss'
26--- data/qt/ubuntuone.qss 2011-09-07 11:26:48 +0000
27+++ data/qt/ubuntuone.qss 2011-09-09 18:53:28 +0000
28@@ -241,6 +241,10 @@
29 min-height: 48px;
30 }
31
32+QLabel[OverQuota="false"] {
33+ color: #333333;
34+}
35+
36 QLabel#other_devices_label {
37 font: bold 16px;
38 }
39@@ -262,8 +266,8 @@
40 font-size: 10px;
41 }
42
43+QLabel[OverQuota="true"],
44 QLabel#warning_label {
45- font: bold 14px;
46 color: #df2d1f;
47 }
48
49
50=== modified file 'ubuntuone/controlpanel/gui/qt/controlpanel.py'
51--- ubuntuone/controlpanel/gui/qt/controlpanel.py 2011-09-09 00:11:12 +0000
52+++ ubuntuone/controlpanel/gui/qt/controlpanel.py 2011-09-09 18:53:28 +0000
53@@ -32,6 +32,7 @@
54 GET_SUPPORT_LINK,
55 GREETING,
56 PERCENTAGE_LABEL,
57+ QUOTA_THRESHOLD,
58 TWITTER_LINK,
59 USAGE_LABEL,
60 )
61@@ -93,10 +94,36 @@
62
63 used = int(info['quota_used'])
64 total = int(info['quota_total'])
65- percentage = {'percentage': PERCENTAGE_STYLE % ((used / total) * 100)}
66+ percentage_value = ((used / total) * 100)
67+ percentage = {'percentage': PERCENTAGE_STYLE % percentage_value}
68 data = {'used': humanize(used), 'total': humanize(total)}
69 self.ui.percentage_usage_label.setText(PERCENTAGE_LABEL % percentage)
70 self.ui.quota_usage_label.setText(USAGE_LABEL % data)
71+ self._update_quota({'percentage': percentage_value})
72+
73+ @log_call(logger.debug)
74+ def _update_quota(self, data=None):
75+ """Update the quota info."""
76+ fraction = 0.0
77+ if data is not None:
78+ fraction = data.get('percentage', 0.0) / 100
79+ if fraction > 0 and fraction < 0.05:
80+ fraction = 0.05
81+ else:
82+ fraction = round(fraction, 2)
83+
84+ logger.debug('ManagementPanel: updating quota to %r.', fraction)
85+ self.ui.percentage_usage_label.setProperty("OverQuota",
86+ fraction >= QUOTA_THRESHOLD)
87+ self.ui.quota_usage_label.setProperty("OverQuota",
88+ fraction >= QUOTA_THRESHOLD)
89+ self.ui.percentage_usage_label.style().unpolish(
90+ self.ui.percentage_usage_label)
91+ self.ui.percentage_usage_label.style().polish(
92+ self.ui.percentage_usage_label)
93+ self.ui.quota_usage_label.style().unpolish(
94+ self.ui.quota_usage_label)
95+ self.ui.quota_usage_label.style().polish(self.ui.quota_usage_label)
96
97 @QtCore.pyqtSlot()
98 def on_twitter_button_clicked(self):
99
100=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py'
101--- ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2011-09-08 19:37:50 +0000
102+++ ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2011-09-09 18:53:28 +0000
103@@ -121,6 +121,30 @@
104 msg = gui.PERCENTAGE_LABEL % percentage_usage
105 self.assertEqual(self.ui.ui.percentage_usage_label.text(), msg)
106
107+ def test_update_over_quota(self):
108+ """Check the labels state when the user exceed the quota."""
109+ percentage_value = 100
110+ # pylint: disable=W0212
111+ self.ui._update_quota({'percentage': percentage_value})
112+ # pylint: enable=W0212
113+
114+ self.assertTrue(
115+ self.ui.ui.percentage_usage_label.property("OverQuota").toBool())
116+ self.assertTrue(
117+ self.ui.ui.quota_usage_label.property("OverQuota").toBool())
118+
119+ def test_update_quota_in_range(self):
120+ """Check the labels state when the quota is under the threshold."""
121+ percentage_value = 50
122+ # pylint: disable=W0212
123+ self.ui._update_quota({'percentage': percentage_value})
124+ # pylint: enable=W0212
125+
126+ self.assertFalse(
127+ self.ui.ui.percentage_usage_label.property("OverQuota").toBool())
128+ self.assertFalse(
129+ self.ui.ui.quota_usage_label.property("OverQuota").toBool())
130+
131 def test_on_local_device_removed(self):
132 """On DeviesPanel's localDeviceRemoved, emit credentialsNotFound."""
133 self.ui.ui.devices_tab.localDeviceRemoved.emit()

Subscribers

People subscribed via source and target branches