Merge lp:~aaronp/software-center/fix-794060-oneiric into lp:software-center

Proposed by Aaron Peachey
Status: Merged
Merged at revision: 1856
Proposed branch: lp:~aaronp/software-center/fix-794060-oneiric
Merge into: lp:software-center
Diff against target: 158 lines (+57/-12)
5 files modified
debian/changelog (+8/-1)
softwarecenter/backend/reviews.py (+3/-3)
softwarecenter/ui/gtk/appdetailsview_gtk.py (+16/-3)
softwarecenter/ui/gtk/widgets/reviews.py (+29/-4)
utils/submit_review.py (+1/-1)
To merge this branch: bzr merge lp:~aaronp/software-center/fix-794060-oneiric
Reviewer Review Type Date Requested Status
software-store-developers Pending
Review via email: mp+65118@code.launchpad.net

Description of the change

same as v4.0 fix for bug lp: #794060, written for trunk

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-06-17 22:17:12 +0000
3+++ debian/changelog 2011-06-19 10:48:35 +0000
4@@ -37,7 +37,14 @@
5 - use "normalize_package_description()" here for the description
6 building
7
8- -- Gary Lasker <gary.lasker@canonical.com> Fri, 17 Jun 2011 18:15:52 -0400
9+ [ Aaron Peachey ]
10+ * softwarecenter/backend/reviews.py,
11+ softwarecenter/ui/gtk/appdetailsview_gtk.py,
12+ softwarecenter/ui/gtk/widgets/reviews.py:
13+ - fix duplication of reviews after user has submitted
14+ usefulness, flagged or submitted a review (LP: #794060)
15+
16+ -- Aaron Peachey <alpeachey@gmail.com> Sun, 19 Jun 2011 20:41:40 +1000
17
18 software-center (4.1.5) oneiric; urgency=low
19
20
21=== modified file 'softwarecenter/backend/reviews.py'
22--- softwarecenter/backend/reviews.py 2011-06-01 08:04:32 +0000
23+++ softwarecenter/backend/reviews.py 2011-06-19 10:48:35 +0000
24@@ -366,7 +366,7 @@
25 if str(review.id) == str(review_id):
26 # remove the one we don't want to see anymore
27 self._reviews[app].remove(review)
28- callback(app, self._reviews[app])
29+ callback(app, self._reviews[app], None, 'remove', review)
30 break
31
32 def _on_submit_usefulness_finished(self, pid, status, (review_id, is_useful, stdout_fd, callback)):
33@@ -389,7 +389,7 @@
34 review.usefulness_total = getattr(review, "usefulness_total", 0) + 1
35 if is_useful:
36 review.usefulness_favorable = getattr(review, "usefulness_favorable", 0) + 1
37- callback(app, self._reviews[app], useful_votes)
38+ callback(app, self._reviews[app], useful_votes, 'replace', review)
39 break
40 else:
41 LOG.debug("submit usefulness id=%s failed with exitcode %s" % (
42@@ -398,7 +398,7 @@
43 for review in reviews:
44 if str(review.id) == str(review_id):
45 review.usefulness_submit_error = exitcode
46- callback(app, self._reviews[app])
47+ callback(app, self._reviews[app], None, 'replace', review)
48 break
49
50
51
52=== modified file 'softwarecenter/ui/gtk/appdetailsview_gtk.py'
53--- softwarecenter/ui/gtk/appdetailsview_gtk.py 2011-06-17 14:55:07 +0000
54+++ softwarecenter/ui/gtk/appdetailsview_gtk.py 2011-06-19 10:48:35 +0000
55@@ -805,6 +805,13 @@
56 self.app, self._reviews_ready_callback,
57 page=self._reviews_server_page,
58 language=self._reviews_server_language)
59+
60+ def _review_update_single(self, action, review):
61+ if action == 'replace':
62+ self.reviews.replace_review(review)
63+ elif action == 'remove':
64+ self.reviews.remove_review(review)
65+ return
66
67 def _update_review_stats_widget(self, stats):
68 if stats:
69@@ -817,7 +824,8 @@
70 else:
71 self.review_stats_widget.hide()
72
73- def _reviews_ready_callback(self, app, reviews_data, my_votes=None):
74+ def _reviews_ready_callback(self, app, reviews_data, my_votes=None,
75+ action=None, single_review=None):
76 """ callback when new reviews are ready, cleans out the
77 old ones
78 """
79@@ -850,8 +858,13 @@
80 if my_votes:
81 self.reviews.update_useful_votes(my_votes)
82
83- for review in reviews_data:
84- self.reviews.add_review(review)
85+ if action:
86+ self._review_update_single(action, single_review)
87+ else:
88+ curr_list = self.reviews.get_all_review_ids()
89+ for review in reviews_data:
90+ if not review.id in curr_list:
91+ self.reviews.add_review(review)
92 self.reviews.configure_reviews_ui()
93
94 def on_weblive_progress(self, weblive, progress):
95
96=== modified file 'softwarecenter/ui/gtk/widgets/reviews.py'
97--- softwarecenter/ui/gtk/widgets/reviews.py 2011-06-05 22:50:04 +0000
98+++ softwarecenter/ui/gtk/widgets/reviews.py 2011-06-19 10:48:35 +0000
99@@ -869,10 +869,13 @@
100 button.show()
101 self.vbox.pack_start(button)
102
103- # only show the "More" button if there is a chance that there
104- # are more
105- if self.reviews and len(self.reviews) % REVIEWS_BATCH_PAGE_SIZE == 0:
106- button = gtk.Button(_("Show more reviews"))
107+ # aaronp: removed check to see if the length of reviews is divisible by
108+ # the batch size to allow proper fixing of LP: #794060 as when a review
109+ # is submitted and appears in the list, the pagination will break this
110+ # check and make it unreliable
111+ # if self.reviews and len(self.reviews) % REVIEWS_BATCH_PAGE_SIZE == 0:
112+ if self.reviews:
113+ button = gtk.Button(_("Check for more reviews"))
114 button.connect("clicked", self._on_more_reviews_clicked)
115 button.show()
116 self.vbox.pack_start(button)
117@@ -891,6 +894,28 @@
118 def add_review(self, review):
119 self.reviews.append(review)
120 return
121+
122+ def replace_review(self, review):
123+ for r in self.reviews:
124+ if r.id == review.id:
125+ pos = self.reviews.index(r)
126+ self.reviews.remove(r)
127+ self.reviews.insert(pos, review)
128+ break
129+ return
130+
131+ def remove_review(self, review):
132+ for r in self.reviews:
133+ if r.id == review.id:
134+ self.reviews.remove(r)
135+ break
136+ return
137+
138+ def get_all_review_ids(self):
139+ ids = []
140+ for review in self.reviews:
141+ ids.append(review.id)
142+ return ids
143
144 def clear(self):
145 self.reviews = []
146
147=== modified file 'utils/submit_review.py'
148--- utils/submit_review.py 2011-06-06 08:49:12 +0000
149+++ utils/submit_review.py 2011-06-19 10:48:35 +0000
150@@ -606,7 +606,7 @@
151 try:
152 icon = self.icons.load_icon(iconname, self.APP_ICON_SIZE, 0)
153 except:
154- icon = self.icons.load_icon(Icons.MISSING_APP_ICON, self.APP_ICON_SIZE, 0)
155+ icon = self.icons.load_icon(Icons.MISSING_APP, self.APP_ICON_SIZE, 0)
156 self.review_appicon.set_from_pixbuf(icon)
157
158 # title

Subscribers

People subscribed via source and target branches