def post(self): self.set_header("Content-Type", "application/json") r = {'code': 500} photo_id = self.get_argument('photo_id') if photo_id: photo = Photo.get(photo_id) if photo: photo.inc_like_count() r = { 'code': 200, 'like_count': photo.like_count, 'photo_id': photo_id } self.write(r) self.finish()
def photo(self): return self.photo_id and Photo.get(self.photo_id)
def cover_link(self): p = Photo.get(album_id=self.id) return p.link if p else ''