示例#1
0
    def get(self):
        user = None

        if self.logged_in:
            user = self.current_user
            
        newPoints = yield PointRoot.getRecentCurrentPoints_async(user)        
        featuredPoint = FeaturedPoint.getFeaturedPoint()
        
        # GET RECENTLY VIEWED
        if user:
            recentlyViewedPoints = user.getRecentlyViewed()
            user.getActiveNotifications()
        else:
            recentlyViewedPoints = []
        
        template_values = {
            'recentlyActive': newPoints,
            'recentlyViewed': recentlyViewedPoints,
            'featuredPoint': featuredPoint,
            'user': user,
            'showManifesto': 1,
            'thresholds': constants.SCORETHRESHOLDS,
            'currentArea':self.session.get('currentArea'),
            'currentAreaDisplayName':self.session.get('currentAreaDisplayName')
        }
        self.response.out.write(self.template_render('index.html', template_values))
示例#2
0
 def mutate(self, info, id):
     user = info.context.current_user
     point, point_root = PointModel.getCurrentByRootKey(id)
     if user.isAdmin:
         if FeaturedPoint.setFeatured(point_root.key):
             return MakeFeatured(point=point, point_root=point_root)
         else:
             raise Exception(str('make featured failed:'))
     else:
         raise Exception(str('non admin user tried to set featured point'))
示例#3
0
    def makeFeatured(self):
        result = {"result": False}
        try:
            if self.current_user and self.current_user.isAdmin:
                point, pointRoot = Point.getCurrentByUrl(self.request.get("urlToEdit"))
                if not pointRoot:
                    result["error"] = "Not able to find point by URL"
                if FeaturedPoint.setFeatured(pointRoot.key):
                    result = {"result": True}
            else:
                result = {"result": False, "error": "Permission denied!"}
        except Exception as e:
            result = {"result": False, "error": str(e)}

        resultJSON = json.dumps(result)
        self.response.headers["Content-Type"] = "application/json; charset=utf-8"
        self.response.out.write(resultJSON)
示例#4
0
 def makeFeatured(self):
     result = {'result': False}
     try:
         if self.current_user and self.current_user.isAdmin:    
             point, pointRoot = Point.getCurrentByUrl(self.request.get('urlToEdit'))
             if not pointRoot:
                 result['error'] = 'Not able to find point by URL'
             if FeaturedPoint.setFeatured(pointRoot.key):
                 result = {'result': True}
         else:
             result = {'result': False, 'error': 'Permission denied!'}
     except Exception as e:
         result = {'result': False, 'error': str(e)}  
          
     resultJSON = json.dumps(result)    
     self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
     self.response.out.write(resultJSON)
示例#5
0
 def getMainPageLeft(self):
     
     newPoints = PointRoot.getRecentCurrentPoints()
     featuredPoint = FeaturedPoint.getFeaturedPoint()
         
     vals = {
         'recentlyActive': newPoints,
         'featuredPoint': featuredPoint,
         'user': self.current_user
     }
     self.response.headers["Content-Type"] = 'application/json; charset=utf-8'        
     html = self.template_render('mainPageLeftColumn.html', vals)
     resultJSON = json.dumps({
         'result': True,
         'html': html,
     }) 
     self.response.out.write(resultJSON) 
示例#6
0
    def makeFeatured(self):
        result = {'result': False}
        try:
            if self.current_user and self.current_user.isAdmin:
                point, pointRoot = Point.getCurrentByUrl(
                    self.request.get('urlToEdit'))
                if not pointRoot:
                    result['error'] = 'Not able to find point by URL'
                if FeaturedPoint.setFeatured(pointRoot.key):
                    result = {'result': True}
            else:
                result = {'result': False, 'error': 'Permission denied!'}
        except Exception as e:
            result = {'result': False, 'error': str(e)}

        resultJSON = json.dumps(result)
        self.response.headers[
            "Content-Type"] = 'application/json; charset=utf-8'
        self.response.out.write(resultJSON)
示例#7
0
 def resolve_featuredPoint(self, info, **args):
     return FeaturedPoint.getFeaturedPoint()