Exemple #1
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'))
Exemple #2
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)
Exemple #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)
Exemple #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)