Esempio n. 1
0
 def post(self):
     request_data = AddPage.parser.parse_args()
     if PageModel.find_by_url(request_data['url']):
         return {"message": "Page already exists in database"}, 400
     page = PageModel(request_data['url'])
     try:
         page.save_to_db()
     except:
         return {"message": "An error occured"}, 500
     return {"message": "page added"}
Esempio n. 2
0
    def post(self):
        
        if authenticatedUser(sessions.Session()):

            page = PageModel(
                key_name = self.request.get('title').replace(' ','_'),
                title = self.request.get('title'),
                content = self.request.get('content'))
            
            page.put();

            self.redirect('/'+self.request.get('title').replace(' ','_')+'/')
            
        else:
            
            self.redirect('/login/')
Esempio n. 3
0
    def get(self, key_name):

        user = authenticatedUser(sessions.Session())
        page = PageModel.get_by_key_name(key_name,parent=None)

        template_values = {
            'menulinks': menuLinks(),
            'user': user,
            'page': page,          
        }

        path = os.path.join(os.path.dirname(__file__), 'editPage.html')
        self.response.out.write(template.render(path, template_values))
Esempio n. 4
0
 def delete(self):
     request_data = AddPage.parser.parse_args()
     page = PageModel.find_by_url(request_data['url'])
     if page:
         page.delete_from_db()
         return {
             "message":
             "page {} deleted from db".format(request_data['url'])
         }
     return {
         "message":
         "error - page {} doesnt exist in db".format(request_data['url'])
     }
Esempio n. 5
0
    def post(self,key_name):
   
        if authenticatedUser(sessions.Session()):

            page = PageModel.get_by_key_name(key_name,parent=None)
            page.key_name = self.request.get('title').replace(' ','_')
            page.title = self.request.get('title')
            page.updated = DateTimeProperty.now()
            page.content = self.request.get('content')
            page.put();
            
            self.redirect('/')
            
        else:
            
            self.redirect('/login/')
Esempio n. 6
0
    def get(self,key_name):
            
        page = PageModel.get_by_key_name(key_name, parent=None)

        user = authenticatedUser(sessions.Session())

        template_values = {
            'menulinks': menuLinks(),
            'page': page,
            'user': user,
            'key_name': key_name,
        }

        if (page):
            path = os.path.join(os.path.dirname(__file__), 'page.html')
            self.response.out.write(template.render(path, template_values))

        else:
            self.error(404)#('/'+key_name[:len(key_name)])
            path = os.path.join(os.path.dirname(__file__), '404.html')
            self.response.out.write(template.render(path, template_values))
Esempio n. 7
0
def menuLinks():
    
    MenuLink_query = PageModel.all()
    menulinks = MenuLink_query.fetch(10);
    return menulinks
Esempio n. 8
0
 def get(self,key_name):
     
     page = PageModel.get_by_key_name(key_name, parent=None)
     self.response.out.write(simplejson.dumps([page.to_dict()]))
Esempio n. 9
0
    def get(self, key_name):

        page = PageModel.get_by_key_name(key_name, parent=None)
        db.delete(page)

        self.redirect('/')
Esempio n. 10
0
 def get(self, id):
     page = PageModel.find_by_id(id)
     if page:
         return {"result": pagescheck([page.id, page.url])}
     return {'message': "page with id {} doesnt exist".format(id)}, 404
Esempio n. 11
0
 def post(self):
     pages = open("pages.txt", "r")
     for line in pages:
         page = PageModel(line.strip("\n"))
         page.save_to_db()
     return {"message": "database updated"}