Commits

hoop committed 3470ace

Remove recommendation handler now that we access it via widget

  • Participants
  • Parent commits ab8eb67

Comments (0)

Files changed (3)

File handlers/recommendcolors.py

-
-"""Colors RequestHandler"""
-
-import config
-from random import randint
-from pymongo import ASCENDING,DESCENDING
-from MongoHelper import ObjectId
-from funcs import get_js
-from handlers.super import SuperHandler
-
-class RecommendHandler(SuperHandler):
-    """Make recommendation to user"""
-    def get(self):
-        profile = self.db.profiles.find_one(ObjectId(self.session['_id']))
-
-        scope = {'user_prefs':profile['prefs']}
-        mapf = get_js('js/vectorize.map.js')
-        reducef = get_js('js/vectorize.reduce.js')
-
-        # find max(x) where x is any attribute
-        maxes = dict()
-        for key in profile['prefs'].iterkeys():
-            if key not in maxes:
-                maxes[key] = [c['tags'][key] for c in self.db.candidates.find().sort('tags.'+key,DESCENDING).limit(1)][0]
-        scope['maxes'] = maxes
-
-        mr_col = self.db.candidates.map_reduce(mapf, reducef, scope=scope)
-        candidate_ids = [r['_id'] for r in mr_col.find().sort('value',ASCENDING).limit(10)]
-        candidates = [self.db.candidates.find_one(c) for c in candidate_ids]
-
-        return self.render('recommendcolors.html', candidates=candidates)
-

File templates/recommendcolors.html

-<html>
-<head>
-<title>Color Voting Demo</title>
-</head>
-<body>
-<h1>Maybe you'll like these</h1>
-{% for candidate in candidates %}
-{% set R = candidate['tags']['r'] %}
-{% set G = candidate['tags']['g'] %}
-{% set B = candidate['tags']['b'] %}
-<div style="background-color: rgb({{R}},{{G}},{{B}}); layer-background-color: rgb({{R}},{{G}},{{B}});"><pre>
-R = {{ R }}
-G = {{ G }}
-B = {{ B }}
-</pre>
-</div>
-{% end %}
-<a href="/">Back to voting</a>
-</body>
-</html>
 
         handlers = [
             (r'.*/$', ColorsHandler),             # Intro page, etc
-            (r'.*/recommend/$', RecommendHandler),
         ]
 
         tornado.web.Application.__init__(self,handlers,**cnf)