def get(self): from django.utils import simplejson as json from models import Celebrity from jsmin import jsmin celebrities = Celebrity.get_latest() celebrities_list = [dict(tag=c.slug, count=c.vote_count) for c in celebrities] self.response.headers['Content-Type'] = 'application/json' self.response.out.write(jsmin(json.dumps(celebrities_list)))
def setUp(self): self.external_url = 'http://23.253.252.30' app = get_app('testsdb') self.app = app.test_client() db.create_all() self.speeding = Crime("Speeding", "www.speeding.com", "Goin' real real fast!") self.ched = Celebrity(name='Ched', description='Actor', twitter_handle='@Ched', birthday=date(1900,1,1), wiki_url='ched.wiki', imdb_url='ched.imdb', picture_url='ched.picture') self.charge1 = Charge(date=date(2000,1,1), location='Austin, Texas', description='Driving Fast!', classification='Class A misdemeanor', crime = self.speeding, celebrity = self.ched) self.cr1 = Crime("1") self.cr2 = Crime("2") self.ce1 = Celebrity("1") self.ce2 = Celebrity("2")
def post(self): from models import Celebrity name = self.request.get('name') celebrity = Celebrity.up_vote_or_insert(name=name) self.get()