Commit 4352b081251a34f01cfd7f537a26b59bd0f577bc

Authored by Tiago Bortoletto Vaz
1 parent ae5b1cdb
Exists in master and in 1 other branch add_vagrant

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 45  
46 46 class Package:
47 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 52 json_source = "http://dde.debian.net/dde/q/udd/packages/all/%s?t=json" % pkg #FIXME: url goes to config
49 53 json_data = json.load(urllib.urlopen(json_source))
50 54 # parsing tags:
... ... @@ -52,7 +56,7 @@ class Package:
52 56 json_data['r']['tag'] = tags
53 57 # formatting long description
54 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 61 def _debtags_list_to_dict(self, debtags_list):
58 62 """ in:
... ... @@ -230,14 +234,20 @@ class AppRecommender:
230 234 recommendation = self._recommends(request)
231 235 ### Getting package summary (short description) ###
232 236 pkg_summaries = {}
  237 + pkg_details = []
233 238 cache = apt.Cache()
234 239 for strategy, result in recommendation.items():
235 240 for pkg in result:
236 241 try:
237 242 pkg_summaries[pkg] = cache[pkg].candidate.summary
  243 + pkg_details.append(Package().get_details_from_dde(pkg))
238 244 except:
239 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 251 FeedbackForm(request.selected_strategies),request)
242 252  
243 253 def _recommends(self,request):
... ... @@ -276,7 +286,7 @@ render = web.template.render(&#39;templates/&#39;, base=&#39;layout&#39;)
276 286 render_plain = web.template.render('templates/')
277 287  
278 288 urls = ('/', 'Index',
279   - '/apprec', 'AppRecommender',
  289 + '/apprec', 'AppRecommender',
280 290 '/thanks', 'Thanks',
281 291 '/support', 'Support',
282 292 '/about', 'About',
... ...