def showHome(self): """ Sets up template data and renders homepage template. """ homepage = Config.get('homepage') features = Config.get('features') locationData = mLocation.getSimpleLocationDictionary(self.db) allIdeasData = mIdea.getMostRecentIdeas(self.db, homepage['num_recent_ideas']); locations = dict(data = locationData, json = json.dumps(locationData)) allIdeas = dict(data = allIdeasData, json = json.dumps(allIdeasData)) news = self.getNewsItems() if (bool(features.get('is_display_leaderboard'))): leaderboardProjects = mProject.getLeaderboardProjects(self.db, 6) self.template_data['leaderboard'] = leaderboardProjects if (bool(features.get('is_display_featured_projects'))): featuredProjects = mProject.getFeaturedProjects(self.db, 6) self.template_data['featured_projects'] = featuredProjects if (bool(features.get('is_community_leaders_displayed'))): community_leaders = self.orm.query(models.CommunityLeader) \ .order_by('`order`') \ .all() self.template_data['community_leaders'] = community_leaders self.template_data['locations'] = locations self.template_data['all_ideas'] = allIdeas self.template_data['news'] = news return self.render('home', {'locations':locations, 'all_ideas':allIdeas})
def showAccountPage(self): if (self.user and self.user.data): self.user.updateAccountPageVisit() userActivity = self.user.getActivityDictionary() locations = mLocation.getSimpleLocationDictionary(self.db) self.template_data['user_activity'] = dict( data=userActivity, json=json.dumps(userActivity)) self.template_data['locations'] = dict(json=json.dumps(locations), data=locations) connected_fb = False connected_tw = False s = SessionHolder.get_session() if s.user_id: check_fb = "select * from facebook_user where user_id = $id" res_fb = list(self.db.query(check_fb, {'id': s.user_id})) if len(res_fb) == 1: connected_fb = True check_tw = "select * from twitter_user where user_id = $id" res_tw = list(self.db.query(check_tw, {'id': s.user_id})) if len(res_tw) == 1: connected_tw = True return self.render( 'useraccount', { 'connected_fb': connected_fb, 'connected_tw': connected_tw, 'test': True }) else: log.error("*** attempt to access account page without user object") # quick fix to avoid error when logging in too quickly self.redirect("/")
def showHome(self): """ Sets up template data and renders homepage template. """ homepage = Config.get("homepage") features = Config.get("features") locationData = mLocation.getSimpleLocationDictionary(self.db) allIdeasData = mIdea.getMostRecentIdeas(self.db, homepage["num_recent_ideas"]) locations = dict(data=locationData, json=json.dumps(locationData)) allIdeas = dict(data=allIdeasData, json=json.dumps(allIdeasData)) news = self.getNewsItems() if bool(features.get("is_display_leaderboard")): leaderboardProjects = mProject.getLeaderboardProjects(self.db, 6) self.template_data["leaderboard"] = leaderboardProjects if bool(features.get("is_display_featured_projects")): featuredProjects = mProject.getFeaturedProjects(self.db, 6) self.template_data["featured_projects"] = featuredProjects if bool(features.get("is_community_leaders_displayed")): community_leaders = self.orm.query(models.CommunityLeader).order_by("`order`").all() self.template_data["community_leaders"] = community_leaders self.template_data["locations"] = locations self.template_data["all_ideas"] = allIdeas self.template_data["news"] = news return self.render("home", {"locations": locations, "all_ideas": allIdeas})
def showSearch(self): if (self.request('main_text')): return False terms = self.request('terms').split(',') if self.request('terms') else [] limit = int(self.request('n')) if self.request('n') else 6 offset = int(self.request('offset')) if self.request('offset') else 0 locationId = self.request('location_id') self.template_data['search_terms'] = self.request('terms') self.template_data['search_location_id'] = locationId projects = mProject.searchProjects(self.db, terms, locationId, limit, offset) resources = mProjectResource.searchProjectResources(self.db, terms, locationId, limit, offset) ideas = mIdea.searchIdeas(self.db, terms, locationId, limit, offset) results = dict(projects = projects, resources = resources, ideas = ideas) self.template_data['results'] = dict(json = json.dumps(results), data = results) total_count = dict(projects = mProject.searchProjectsCount(self.db, terms, locationId), resources = mProjectResource.searchProjectResourcesCount(self.db, terms, locationId), ideas = mIdea.searchIdeasCount(self.db, terms, locationId)) self.template_data['total_count'] = dict(json = json.dumps(total_count), data = total_count) locations_list = mLocation.getSimpleLocationDictionary(self.db) self.template_data['locations'] = dict(json = json.dumps(locations_list), data = locations_list) locationData = self.getLocationData() self.template_data['locations_scored'] = json.dumps(locationData) self.template_data['max_score'] = locationData[0]['score'] return self.render('search')
def showAccountPage(self): if (self.user and self.user.data): self.user.updateAccountPageVisit() userActivity = self.user.getActivityDictionary() locations = mLocation.getSimpleLocationDictionary(self.db) self.template_data['user_activity'] = dict(data = userActivity, json = json.dumps(userActivity)) self.template_data['locations'] = dict(json = json.dumps(locations), data = locations) connected_fb = False connected_tw = False s = SessionHolder.get_session() if s.user_id: check_fb = "select * from facebook_user where user_id = $id" res_fb = list(self.db.query(check_fb, {'id':s.user_id })) if len(res_fb) == 1: connected_fb = True check_tw = "select * from twitter_user where user_id = $id" res_tw = list(self.db.query(check_tw, {'id':s.user_id })) if len(res_tw) == 1: connected_tw = True return self.render('useraccount', {'connected_fb':connected_fb, 'connected_tw':connected_tw, 'test':True}) else: log.error("*** attempt to access account page without user object") # quick fix to avoid error when logging in too quickly self.redirect("/")
def showMobile(self, isBlackBerry = False): locationData = mLocation.getSimpleLocationDictionary(self.db) locations = dict(data =locationData, json = json.dumps(locationData)) self.template_data['locations'] = locations t = 'bb' if isBlackBerry else 'mobile' return self.render(t)
def showMobile(self, isBlackBerry=False): locationData = mLocation.getSimpleLocationDictionary(self.db) locations = dict(data=locationData, json=json.dumps(locationData)) self.template_data['locations'] = locations t = 'bb' if isBlackBerry else 'mobile' return self.render(t)
def GET(self, action=None): if (action == 'keywords'): return self.getKeywordsJSON() elif (action == 'similar'): return self.getSimilarProjectsJSON() elif (action == 'resources'): return self.getSimilarResourcesJSON() else: locations_data = mLocation.getSimpleLocationDictionary(self.db) locations = dict(json = json.dumps(locations_data), data = locations_data) return self.render('create', {'locations':locations})
def showProfilePage(self, userId): user = mUser.User(self.db, userId) if (user.data): userActivity = user.getProfileActivityDictionary() locations_list = mLocation.getSimpleLocationDictionary(self.db) self.template_data['user_activity'] = dict( data=userActivity, json=json.dumps(userActivity)) self.template_data['locations'] = dict( json=json.dumps(locations_list), data=locations_list) if (self.user and (self.user.isModerator or self.user.isAdmin)): self.template_data['user_profile_email'] = user.email return self.render('useraccount') else: # user doesn't exist/is inactive return self.not_found()
def showProfilePage(self, userId): user = mUser.User(self.db, userId) if (user.data): userActivity = user.getProfileActivityDictionary() locations_list = mLocation.getSimpleLocationDictionary(self.db) self.template_data['user_activity'] = dict(data = userActivity, json = json.dumps(userActivity)) self.template_data['locations'] = dict(json = json.dumps(locations_list), data = locations_list) if (self.user and (self.user.isModerator or self.user.isAdmin)): self.template_data['user_profile_email'] = user.email return self.render('useraccount') else: # user doesn't exist/is inactive return self.not_found()
def showHome(self): """ Sets up template data and renders homepage template. """ homepage = Config.get('homepage') features = Config.get('features') locationData = mLocation.getSimpleLocationDictionary(self.db) allIdeasData = mIdea.getMostRecentIdeas(self.db, homepage['num_recent_ideas']) locations = dict(data=locationData, json=json.dumps(locationData)) allIdeas = dict(data=allIdeasData, json=json.dumps(allIdeasData)) news = self.getNewsItems() if (bool(features.get('is_display_leaderboard'))): leaderboardProjects = mProject.getLeaderboardProjects(self.db, 6) self.template_data['leaderboard'] = leaderboardProjects if (bool(features.get('is_display_featured_projects'))): featuredProjects = mProject.getFeaturedProjects(self.db, 6) self.template_data['featured_projects'] = featuredProjects if (bool(features.get('is_community_leaders_displayed'))): community_leaders = self.orm.query(models.CommunityLeader) \ .order_by('`order`') \ .all() self.template_data['community_leaders'] = community_leaders self.template_data['locations'] = locations self.template_data['all_ideas'] = allIdeas self.template_data['news'] = news return self.render('home', { 'locations': locations, 'all_ideas': allIdeas })
def showAddResource(self): locationData = mLocation.getSimpleLocationDictionary(self.db) locations = dict(data=locationData, json=json.dumps(locationData)) self.template_data['locations'] = locations return self.render('resource')
def showAddResource(self): locationData = mLocation.getSimpleLocationDictionary(self.db) locations = dict(data = locationData, json = json.dumps(locationData)) self.template_data['locations'] = locations return self.render('resource')