def post(self):
        mode = self.request.GET.get("mode", self.request.url.split("/")[-1].split('?')[0])
        if mode == "creertirage":
            lebody = json.loads(self.request.body)
            pseudo = str(lebody.get('pseudo')).lower()
            pseudo = pseudo.replace(" ", "")
            existe = Tirage.query(Tirage.nomtirage == pseudo).get()
            if existe == None:
                nomtirage = ""
            else:
                nomtirage = existe.nomtirage
            if pseudo != "" and pseudo != None and pseudo != "none" and pseudo != nomtirage:
                tirage = Tirage(nomtirage=pseudo)
                tirage.put()
                response = {
                    'message': 'ok'
                }
                self.response.write(jsonEncode.encode(response))
            else:
                if pseudo == "none":
                    response = {
                        'message': 'none'
                    }
                else:
                    response = {
                        'message': 'ko'
                    }

                self.response.write(jsonEncode.encode(response))
 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))
 def get(self):
     response = { 'tirages': [] }
     tirages = Tirage.query().order(-Tirage.datecreation).fetch()
     for tirage in tirages:
         response['tirages'].append({
             'nomtirage': tirage.nomtirage,
             'datecreation': str(tirage.datecreation)[0:19]
         })
     self.response.write(jsonEncode.encode(response))
Exemple #4
0
 def post(self):
     mode = self.request.GET.get("mode", self.request.url.split("/")[-1].split('?')[0])
     if mode == 'connexion':
         self.setSessionParameter('user','crancer')
     elif mode == 'affuser':
         user = self.getSessionUser()
         response = {
             'user': user
         }
         self.response.write(jsonEncode.encode(response))
Exemple #5
0
    def get(self):
        key = self.request.url.split('/')[-1]
        response = {}
        ## get a list of plants
        if key == 'list':
            plantes, more = plante_manager.list()
            response = {'plantes': plantes, 'more': more}
        ## get on plant with given key
        else:
            plante = plante_manager.get(key)
            response = {
                'plante': plante,
            }

        self.response.write(jsonEncode.encode(response))
 def post(self):
     mode = self.request.GET.get("mode", self.request.url.split("/")[-1].split('?')[0])
     if mode == 'importcsv':
         url = 'https://docs.google.com/spreadsheets/d/1CZ6uqK4Z-7QYxC8PH5F-o_hco6-N9FIMjWwYUsRH19c/export?format=csv'
         rep = urllib2.urlopen(url)
         moncsv = csv.reader(rep)
         for row in moncsv:
             num = row[0]
             num = str(num).replace("'", "")
             nom = str(row[1]).replace(" ", "")
             pokemon = Pokemon(numero=int(num),
                               nompokemon=nom)
             pokemon.put()
     if mode == 'getall':
         response = { 'pokemons': [] }
         pokemons = Pokemon.query().fetch()
         response['pokemons'] = pokemons
         self.response.write(jsonEncode.encode(response))
Exemple #7
0
 def post(self):
     mode = self.request.GET.get(
         "mode",
         self.request.url.split("/")[-1].split('?')[0])
     if mode == 'importcsv':
         url = 'https://docs.google.com/spreadsheets/d/1CZ6uqK4Z-7QYxC8PH5F-o_hco6-N9FIMjWwYUsRH19c/export?format=csv'
         rep = urllib2.urlopen(url)
         moncsv = csv.reader(rep)
         for row in moncsv:
             num = row[0]
             num = str(num).replace("'", "")
             nom = str(row[1]).replace(" ", "")
             pokemon = Pokemon(numero=int(num), nompokemon=nom)
             pokemon.put()
     if mode == 'getall':
         response = {'pokemons': []}
         pokemons = Pokemon.query().fetch()
         response['pokemons'] = pokemons
         self.response.write(jsonEncode.encode(response))
 def post(self):
     mode = self.request.GET.get("mode", self.request.url.split("/")[-1].split('?')[0])
     if mode == 'connexion':
         lebody = json.loads(self.request.body)
         user = str(lebody.get('user')).lower()
         user = user.replace(" ", "")
         mdp = str(lebody.get('mdp')).lower()
         if user != "" and mdp != "" and user != None and mdp != None:
             connexionexiste = User.query(User.user == user and User.password == mdp).get()
             if connexionexiste != "" and connexionexiste != None:
                 self.setSessionParameter('user', user)
             else:
                 print('connexion existe pas')
         else:
             print('user et mot de pass non rempli')
     elif mode == 'affuser':
         user = self.getSessionUser()
         if user:
             response = {
                 'user': True
             }
         else:
             response = {
                 'user': False
             }
         self.response.write(jsonEncode.encode(response))
     elif mode == 'register':
         lebody = json.loads(self.request.body)
         user = str(lebody.get('user')).lower()
         user = user.replace(" ", "")
         mdp = str(lebody.get('mdp')).lower()
         if user != "" and mdp != "" and user != None and mdp != None:
             userexiste = User.query(User.user == user).get()
             if userexiste != "" and userexiste != None:
                 print('existe deja')
             else:
                 newuser = User(user=user, password=mdp)
                 newuser.put()
                 print('Ok creer')
 def post(self):
     mode = self.request.GET.get(
         "mode",
         self.request.url.split("/")[-1].split('?')[0])
     if mode == 'connexion':
         lebody = json.loads(self.request.body)
         user = str(lebody.get('user')).lower()
         user = user.replace(" ", "")
         mdp = str(lebody.get('mdp')).lower()
         if user != "" and mdp != "" and user != None and mdp != None:
             connexionexiste = User.query(User.user == user
                                          and User.password == mdp).get()
             if connexionexiste != "" and connexionexiste != None:
                 self.setSessionParameter('user', user)
             else:
                 print('connexion existe pas')
         else:
             print('user et mot de pass non rempli')
     elif mode == 'affuser':
         user = self.getSessionUser()
         if user:
             response = {'user': True}
         else:
             response = {'user': False}
         self.response.write(jsonEncode.encode(response))
     elif mode == 'register':
         lebody = json.loads(self.request.body)
         user = str(lebody.get('user')).lower()
         user = user.replace(" ", "")
         mdp = str(lebody.get('mdp')).lower()
         if user != "" and mdp != "" and user != None and mdp != None:
             userexiste = User.query(User.user == user).get()
             if userexiste != "" and userexiste != None:
                 print('existe deja')
             else:
                 newuser = User(user=user, password=mdp)
                 newuser.put()
                 print('Ok creer')
Exemple #10
0
    def post(self):
        key = self.request.url.split('/')[-1]
        response = {'message': 'Ajout potager'}
        if key == 'add':
            planteMessage = json.loads(self.request.body)
            plante = Plante()
            plante.name = planteMessage.get('nom', '')
            plante.famille = planteMessage.get('FamillePlante', '')
            plante.soleil = planteMessage.get('SoleilPlante', '')
            plante.type = planteMessage.get('TypePlante', '')
            plante.cycleCulture = planteMessage.get('cycleCulture', '')
            plante.hauteur = planteMessage.get('hauteurPlante', 0)
            plante.nbCarre = planteMessage.get('nbCarreRequis', 0)
            plante.qteCarre = planteMessage.get('quantiteCarre', 0)
            plante.recole = planteMessage.get('recolte:', [])
            plante.semis = planteMessage.get('semisTerre', [])
            plante.protection = planteMessage.get('semisTerreProtection', [])
            plante.sol = planteMessage.get('sol', '')
            plante.tpsOccupation = planteMessage.get('tempsOccupationCarre', 0)
            plante.tpsRotation = planteMessage.get('tempsRotationCarre', 0)
            plante.variete = planteMessage.get(' variete', '')
            plante_manager.put(plante)

        self.response.write(jsonEncode.encode(response))
Exemple #11
0
 def delete(self):
     id = self.request.url.split('/')[-1]
     response = {'message': 'Supression de la plante'}
     plante = plante_manager.get(id)
     plante_manager.delete(plante)
     self.response.write(jsonEncode.encode(response))
 def get(self):
     response = { 'dresseurs': [] }
     dresseurs = Dresseur.query().fetch()
     response['dresseurs'] = dresseurs
     self.response.write(jsonEncode.encode(response))
 def get(self):
     response = {'message': 'Hello World'}
     self.response.write(jsonEncode.encode(response))