def get(self, *args):
            news = News.get_by_id(long(args[0]))

            if news:
                news.delete()

            self.redirect('/news')
        def post(self, ident):
            news = News.get_by_id(long(ident))
            news.title = self.request.get("title")
            news.short_description = self.request.get("short_description")
            news.description = self.request.get("description")

            if self.request.get("image"):
                news.image = db.Blob(images.resize(self.request.get("image"), 300))

            db.put(news)
            self.redirect("/news")
def getNews(ident):
    news = News.get_by_id(long(ident))

    jsonEventInfo = {}
    jsonEventInfo['title'] = news.title
    jsonEventInfo['short_description'] = news.short_description
    jsonEventInfo['description'] = news.description
    
    if news.image:
        jsonEventInfo['image_link'] = '/news/images/' + str(ident)

    news = jsonEventInfo
    return news
        def get(self, ident):
            news = News.get_by_id(long(ident))
            self.response.headers['Content-Type'] = 'application/json'

            data = {
                "title": news.title,
                "short_description": news.short_description,
                "description": news.description,
                "created_at": news.created_at.strftime('%d-%m-%Y'),
                "image": base64.b64encode(str(news.image))
            }
            
            jsonNewsData = json.dumps(data)
            self.response.write(jsonNewsData)
 def test_edit_news(self):
     news = News(title="News", short_description="Short Description", description="Description1")
     news.put()
     ident = news.key().id()
     params = {
        'title': "News",
        'short_description': "Short Description",
        'description': "Description2"
     }
     
     path = "/news/edit/" + str(news.key().id())
     response = self.testapp.post(path, params)
     
     news = News.get_by_id(ident)
     
     self.assertEqual(1, News.all().count())
     self.assertEqual(302, response.status_int)
     self.assertEqual("Description2", str(news.description))
        def get(self, ident):
            news = News.get_by_id(long(ident))

            if news.image:
                self.response.headers['Content-Type'] = 'image/*'
                self.response.out.write(news.image)