Commit 4352b081251a34f01cfd7f537a26b59bd0f577bc
1 parent
ae5b1cdb
Exists in
master
and in
1 other branch
Using Package class for getting DDE info
Showing
1 changed file
with
13 additions
and
3 deletions
Show diff stats
src/web/server.py
| @@ -45,6 +45,10 @@ class Thanks: | @@ -45,6 +45,10 @@ class Thanks: | ||
| 45 | 45 | ||
| 46 | class Package: | 46 | class Package: |
| 47 | def GET(self, pkg): | 47 | def GET(self, pkg): |
| 48 | + result = self.get_details_from_dde(pkg) | ||
| 49 | + return render_plain.package(result) | ||
| 50 | + | ||
| 51 | + def get_details_from_dde(self, pkg): | ||
| 48 | json_source = "http://dde.debian.net/dde/q/udd/packages/all/%s?t=json" % pkg #FIXME: url goes to config | 52 | json_source = "http://dde.debian.net/dde/q/udd/packages/all/%s?t=json" % pkg #FIXME: url goes to config |
| 49 | json_data = json.load(urllib.urlopen(json_source)) | 53 | json_data = json.load(urllib.urlopen(json_source)) |
| 50 | # parsing tags: | 54 | # parsing tags: |
| @@ -52,7 +56,7 @@ class Package: | @@ -52,7 +56,7 @@ class Package: | ||
| 52 | json_data['r']['tag'] = tags | 56 | json_data['r']['tag'] = tags |
| 53 | # formatting long description | 57 | # formatting long description |
| 54 | json_data['r']['long_description'] = json_data['r']['long_description'].replace(' .\n','').replace('\n','<br />') | 58 | json_data['r']['long_description'] = json_data['r']['long_description'].replace(' .\n','').replace('\n','<br />') |
| 55 | - return render_plain.package(json_data['r']) | 59 | + return json_data['r'] |
| 56 | 60 | ||
| 57 | def _debtags_list_to_dict(self, debtags_list): | 61 | def _debtags_list_to_dict(self, debtags_list): |
| 58 | """ in: | 62 | """ in: |
| @@ -230,14 +234,20 @@ class AppRecommender: | @@ -230,14 +234,20 @@ class AppRecommender: | ||
| 230 | recommendation = self._recommends(request) | 234 | recommendation = self._recommends(request) |
| 231 | ### Getting package summary (short description) ### | 235 | ### Getting package summary (short description) ### |
| 232 | pkg_summaries = {} | 236 | pkg_summaries = {} |
| 237 | + pkg_details = [] | ||
| 233 | cache = apt.Cache() | 238 | cache = apt.Cache() |
| 234 | for strategy, result in recommendation.items(): | 239 | for strategy, result in recommendation.items(): |
| 235 | for pkg in result: | 240 | for pkg in result: |
| 236 | try: | 241 | try: |
| 237 | pkg_summaries[pkg] = cache[pkg].candidate.summary | 242 | pkg_summaries[pkg] = cache[pkg].candidate.summary |
| 243 | + pkg_details.append(Package().get_details_from_dde(pkg)) | ||
| 238 | except: | 244 | except: |
| 239 | pkg_summaries[pkg] = "" | 245 | pkg_summaries[pkg] = "" |
| 240 | - return render.apprec(recommendation, pkg_summaries, | 246 | + |
| 247 | + ### Temporarily rendering *survey* rather than *apprec* ### | ||
| 248 | + #return render.apprec(recommendation, pkg_summaries, | ||
| 249 | + # FeedbackForm(request.selected_strategies),request) | ||
| 250 | + return render_plain.survey(recommendation, pkg_details, | ||
| 241 | FeedbackForm(request.selected_strategies),request) | 251 | FeedbackForm(request.selected_strategies),request) |
| 242 | 252 | ||
| 243 | def _recommends(self,request): | 253 | def _recommends(self,request): |
| @@ -276,7 +286,7 @@ render = web.template.render('templates/', base='layout') | @@ -276,7 +286,7 @@ render = web.template.render('templates/', base='layout') | ||
| 276 | render_plain = web.template.render('templates/') | 286 | render_plain = web.template.render('templates/') |
| 277 | 287 | ||
| 278 | urls = ('/', 'Index', | 288 | urls = ('/', 'Index', |
| 279 | - '/apprec', 'AppRecommender', | 289 | + '/apprec', 'AppRecommender', |
| 280 | '/thanks', 'Thanks', | 290 | '/thanks', 'Thanks', |
| 281 | '/support', 'Support', | 291 | '/support', 'Support', |
| 282 | '/about', 'About', | 292 | '/about', 'About', |