def post(self):
     mode = self.request.GET.get("mode", self.request.url.split("/")[-1].split('?')[0])
     if mode == 'addDresseur':
         lebody = json.loads(self.request.body)
         if str(lebody.get('nomig')) != "" and str(lebody.get('codeami')) != "" and str(lebody.get('tirage')) != "" and lebody.get('nomig') != None and lebody.get('codeami') != None and lebody.get('tirage') != None:
             tirage = Tirage.query(Tirage.nomtirage == lebody.get('tirage')).get()
             letirage = tirage.key
             dresseur = Dresseur(tirage=letirage,
                                 nomig=lebody.get('nomig'),
                                 codeami=lebody.get('codeami'))
             dresseur.put()
             response = {
                 'message': 'ok'
             }
         else:
             response = {
                 'message': 'ko'
             }
         self.response.write(jsonEncode.encode(response))
     elif mode == 'tirageAlea':
         lebody = json.loads(self.request.body)
         response = { 'dresseurs': [] }
         tirage = Tirage.query(Tirage.nomtirage == lebody.get('tirage')).get()
         letirage = tirage.key
         dresseurs = Dresseur.query(Dresseur.tirage == letirage).fetch()
         response['dresseurs'] = dresseurs
         self.response.write(jsonEncode.encode(response))
Beispiel #2
0
def QueryByNomTirage(nomtirage):
    query = Tirage.query(Tirage.nomtirage == nomtirage).fetch()

    return query.key