Example #1
0
    def save(self):

        Utilisateur.create(nom=self.name.data,
                           prenom=self.firstname.data,
                           pseudo=self.username.data,
                           email=self.email.data,
                           password=Utilisateur.hash_password(
                               self.password.data))
Example #2
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         user = listUser.get()
         
         if user.password == self.request.get("password"):
         
             listMeetUp = MeetUp.all()
             listMeetUp.ancestor(user.key())
             list = []
             
             for meetUp in listMeetUp.run():
                 listeParticipant = []
                 
                 if not meetUp.supprimer == "true":
                     
                     if self.request.get("withInfo") == "1":
                         
                         for participant in meetUp.listParticipant:
                             a = Utilisateur.all()
                             a.filter("username ="******"listMeetUp"    : list
             }
                 
             self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
             self.response.out.write(response)
             
                     
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #3
0
    def get(self):
        try:
            listUser = Utilisateur.all()
            listUser.filter("username ="******"moi"))
            me = listUser.get()
            
            listUser = Utilisateur.all()
            listUser.filter("username ="******"ajoute"))
            theFriend = listUser.get()
            
            #On s'assure que ce soit la bonne personne
            if me is not None and theFriend is not None and me.password == self.request.get("password"):
                #On s'assure qu'elle n'essaye pas de s'ajouté elle même
                if me.username != theFriend.username: 

                    listeDemande = me.listDemande
                    
                    nouvelleListDemande = []
                    nouvelAmi = None
                    
                    #On met à jour la liste des demandes et on va chercher le nouvel ami
                    for demande in listeDemande:
                        if demande == theFriend.username:
                            nouvelAmi = theFriend.username
                        else:
                            nouvelleListDemande.append(demande)
                    
                    #On ajoute le nouvel ami
                    listeAmi = me.listAmi
                    if nouvelAmi is not None:
                        listeAmi.append(nouvelAmi)
                    
                    me.listAmi = listeAmi
                    me.listDemande = nouvelleListDemande
                    me.put()
                    
                    #on s'ajoute comme ami
                    theFriend.listAmi.append(me.username)
                    theFriend.put()
                    
                    response = {
                        MSG_RESULT : MSG_SUCCESS,
                        "message" : "Ami ajouté!"
                    }
            
            self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
            self.response.out.write(json.dumps(response))
            
        except Exception, ex:
            logging.error(ex)
            self.error(500)
Example #4
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"username"))
         me = listUser.get()
         
         #On ajoute la notification à la liste des notifications
         listNotif = me.listNotification
         listNotif.append(self.request.get("notif"))
         me.listNotification = listNotif
         
         me.put()
         
         response = {
             MSG_RESULT : MSG_SUCCESS,
             "message" : "Notification envoyée"
         }
 
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(json.dumps(response))
         
         
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #5
0
 def get(self):
     try:
         q = Utilisateur.all()
         q.filter('username ='******'amis' : me.listAmi,
                 'demande' : me.listDemande,
                 'nom' : me.nom,
                 'prenom' : me.prenom,
                 'username' : me.username,
                 'listMeetUp' : me.listMeetUp
             }
         else:
             response = {
                 MSG_RESULT : MSG_ERROR,
                 'message' : 'L\'utilisateur n\'existe pas.'
             }
         
         
         self.response.headers["Content-Type"] = 'application/json'
         self.response.out.write(json.dumps(response))
     
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #6
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         me = listUser.get()
         
         if me.password == self.resquest.get("password"):
             #On va chercher les notifications puis on les supprimes puisqu'on les a lu
             listeNotification = me.listNotification
             me.listNotification = []
             
             me.put()
             
             response = {
                 MSG_RESULT : MSG_SUCCESS,
                 "notif" : listeNotification
             }
     
             self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
             self.response.out.write(json.dumps(response))
         
     
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #7
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         me = listUser.get()
         
         #On s'assure que c'est les bonnes personnes
         if me is not None and me.password == self.request.get("password"):
                 
             #On fait la demande d'amitier uniquement si elle n'est pas déjà la
             continuer = 1
             for calendar in me.listCalendar:
                 if self.request.get("ajoute") == calendar:
                     continuer = 0
             
             if continuer:
                 me.listCalendar.append(self.request.get("ajoute"))
                 me.put()
             
             
             response = {
                 MSG_RESULT : MSG_SUCCESS,
                 "message" : "Agenda ajouté!"
             }
         
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(json.dumps(response))
         
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #8
0
    def get(self):
        try:
            listUser = Utilisateur.all()
            listUser.filter("username ="******"moi"))
            user = listUser.get()
            
            
            if user.password == self.request.get("password"):
                
                idMeetUp = self.request.get("supprime")
                
                listMeetUp = MeetUp.all()
                listMeetUp.ancestor(user.key())
                
                #On parcours les meetup de l'utilisateur, si le meetup est la on le supprime
                for meetUp in listMeetUp.run():
                    if str(meetUp.key()) == idMeetUp:
                        db.delete(meetUp)
                        
                response = {
                    MSG_RESULT : MSG_SUCCESS,
                    "message"    : "Le MeetUp a été supprimé!"
                }
                    
                self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
                self.response.out.write(response)

        except Exception, ex:
            logging.error(ex)
            self.error(500)
Example #9
0
	def get(self):
		try:
			self.response.headers["Content-Type"] = 'application/json'
			q = Utilisateur.all()
			q.filter('username !=', self.request.get("username"))
			result = q.get(keys_only=True)
			
			if result is not None:
				listePers = []
				for p in result:
					persInJson = to_dict(p.username)
					listePers.append(persInJson)
			
				response = {
					MSG_RESULT : MSG_SUCCESS,
					'personnes' : listePers
				}
			else:
				reponse = {
					MSG_RESULT : MSG_ERROR,
					'message' : 'Il n\'y a pas d\'autres usagers.'
				}
			self.response.out.write(json.dumps(response))
		
		except Exception, ex:
			logging.error(ex)
			self.error(500)
Example #10
0
 def get(self):
     try:
         listMeetUp = MeetUp.all()
         
         response = {
             MSG_RESULT : MSG_SUCCESS,
             MSG_KEY    : "Le meetUp n'existe pas."
         }
         
         for meetUp in listMeetUp:
             if not meetUp.supprimer == "true" :
                 
                 listeParticipant = []
                 
                 for participant in meetUp.listParticipant:
                     a = Utilisateur.all()
                     a.filter("username ="******"info"    : info
                 }
                 
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(json.dumps(response))
     
     except Exception, ex:
         logging.error(ex)
         self.error(500)
         
         response = {
             MSG_RESULT : MSG_SUCCESS,
             MSG_KEY    : str(ex)
         }
                 
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(json.dumps(response))
Example #11
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         user = listUser.get()
         arrayDateMin = None
         arrayDateMax = None
         
         if user.password == self.request.get("password"):
             if self.request.get("dateMin") != "" :
                 dateMin = self.request.get("dateMin")
                 arrayDateMin = dateMin.split('-')
             
             if self.request.get("dateMax") != "" :
                 dateMax = self.request.get("dateMax")
                 arrayDateMax = dateMax.split('-')
             
             listMeetUp = MeetUp.all()
             listMeetUp.ancestor(user.key())
             
             response = {
                 MSG_RESULT : MSG_SUCCESS,
                 MSG_KEY    : "Le meetUp n'existe pas."
             }
             
             for meetUp in listMeetUp:
                 
                 if str(meetUp.key()) == self.request.get("meetUp") and not meetUp.supprimer == "true" :
                     
                     #On entre les données
                     if self.request.get("nom") != "" :
                         meetUp.nom = self.request.get("nom")
                     if self.request.get("lieu") != "" :
                         meetUp.lieu = self.request.get("lieu")
                     if self.request.get("duree") != "" :
                         meetUp.duree = int(self.request.get("duree"))
                     if self.request.get("heureMin") != "" :
                         meetUp.heureMin = int(self.request.get("heureMin"))
                     if self.request.get("heureMax") != "" :
                         meetUp.heureMax = int(self.request.get("heureMax"))
                     if arrayDateMin is not None:
                         meetUp.dateMin = date(int(arrayDateMin[0]), int(arrayDateMin[1]), int(arrayDateMin[2]))
                         meetUp.dateMax = date(int(arrayDateMax[0]), int(arrayDateMax[1]), int(arrayDateMax[2]))
                     
                     meetUp.put()
             
                     response = {
                         MSG_RESULT : MSG_SUCCESS,
                         "message"    : "Le meet up à bien été mis à jour!"
                     }
                     
             self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
             self.response.out.write(json.dumps(response))
     
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #12
0
def is_admin(current_user):
    current_user = session.get('user_id')
    user = Utilisateur.get(Utilisateur.id == current_user)
    if user.level == 'admin':
        return True
    elif user.level == 'user':
        return False
    else:
        return redirect(url_for('index'))
Example #13
0
    def get(self):
        try:
            listUser = Utilisateur.all()
            listUser.filter("username ="******"moi"))
            me = listUser.get()
            
            listUser = Utilisateur.all()
            listUser.filter("username ="******"demande"))
            theFriend = listUser.get()
            
            #On s'assure que c'est les bonnes personnes
            if me is not None and theFriend is not None and me.password == self.request.get("password"):
                #On s'assure qu'il n'essaye pas de se demander lui même
                if me.username != theFriend.username: 

                    listeDemande = theFriend.listDemande
                    listNotif = theFriend.listNotification
                    
                    #On fait la demande d'amitier uniquement si elle n'est pas déjà la
                    continuer = 1
                    for demande in listeDemande:
                        if demande == me.username:
                            continuer = 0
                    
                    if continuer:
                        listeDemande.append(me.username)
                        theFriend.listDemande = listeDemande
                        
                        theFriend.listNotification.append('Vous avez une nouvelle demande d\'ami!')
                        
                    theFriend.put()
                    
                    
                    response = {
                        MSG_RESULT : MSG_SUCCESS,
                        "message" : "Demande effectuée!"
                    }
            
            self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
            self.response.out.write(json.dumps(response))
            
        except Exception, ex:
            logging.error(ex)
            self.error(500)
Example #14
0
def createUser():
    """ User creation """
    try:
        if "username" in session:
            if request.method == 'POST':
                myUser = Utilisateur(firstname=request.form["inputFirstName"],
                                     lastname=request.form["inputLastName"],
                                     username=request.form["inputUserName"],
                                     password=request.form["inputPassword"],
                                     email=request.form["inputEmail"])
                myUser.save()
                flash('User saved !!! ', 'message')
                return redirect(url_for('listeUser'))
            if request.method == 'GET':
                return render_template('newuser.html')
        else:
            flash('Unknown user !!! ', 'error')
            return render_template('login.html')
    except:
        return redirect(url_for('appError'))
Example #15
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         me = listUser.get()
         meetUp = db.get(self.request.get("meetUp"))
         
         
         if me.password == self.request.get("password"):
             
             #J'enlève la demande d'invitation
             listeDemandeMeetUp = []
             for demandeMeetUp in me.listDemandeMeetUp:
                 if demandeMeetUp != str(meetUp.key()):
                     listeDemandeMeetUp.append(demandeMeetUp)
                     
             me.listDemandeMeetUp = listeDemandeMeetUp
             
             listeMeetUp = []
             for unMeetUp in me.listMeetUp:
                 if unMeetUp != str(meetUp.key()):
                     listeMeetUp.append(unMeetUp)
                     
             me.listMeetUp = listeMeetUp
             
             me.put()
             
             
             listeParticipant = []
             for participant in meetUp.listParticipant:
                 if participant != me.username:
                     listeParticipant.append(participant)
             
             meetUp.listParticipant = listeParticipant
             
             meetUp.put()
             
             
             
         response = {
             MSG_RESULT : MSG_SUCCESS,
             "message"    : "Votre refus de participation a été enregistrée"
         }
             
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(response)
             
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #16
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         me = listUser.get()
         meetUp = db.get(self.request.get("meetUp"))
         
         #On vérifie que j'ai bien été invité au meetUp
         isInvite = 0
         for invitation in me.listDemandeMeetUp:
             if invitation == str(meetUp.key()):
                 isInvite = 1
         
         if me.password == self.request.get("password") and isInvite:
             #J'ajoute le meetup des mes meet up
             listeMeetUp = me.listMeetUp
             listeMeetUp.append(str(meetUp.key()))
             me.listMeetUp = listeMeetUp
             
             #J'enlève la demande d'invitation
             listeDemandeMeetUp = []
             for demandeMeetUp in me.listDemandeMeetUp:
                 if demandeMeetUp != str(meetUp.key()):
                     listeDemandeMeetUp.append(demandeMeetUp)
                     
             me.listDemandeMeetUp = listeDemandeMeetUp
             
             me.put()
             
             #Je me met comme participant dans le meetUp
             listeParticipant = meetUp.listParticipant
             listeParticipant.append(me.username)
             meetUp.listParticipant = listeParticipant
             meetUp.put()
             
         response = {
             MSG_RESULT : MSG_SUCCESS,
             "message"    : "Votre participation a été enregistrée"
         }
             
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(response)
             
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #17
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         me = listUser.get()
         
         idMeetUp = self.request.get("meetUp")
         meetUp = db.get(self.request.get("meetUp"))
         
         if me.password == self.request.get("password"):
             #J'enleve le MeetUp de mes MeetUp
             listeMeetUp = []
             for meetUp in me.listMeetUp:
                 if meetUp != idMeetUp:
                     listeMeetUp.append(meetUp)
             
             listeDemandeMeetUp = []
             for demande in me.listDemandeMeetUp:
                 if demande != idMeetUp:
                     listeDemandeMeetUp.append(demande)
                 
             me.listDemandeMeetUp = listeDemandeMeetUp
             me.listMeetUp = listeMeetUp
             me.put()
             
             #Je m'enlève des participants
             listeParticipant = []
             for participant in meetUp.listParticipant:
                 if participant != me.username:
                     listeParticipant.append(participant)
             
             meetUp.listParticipant = listeParticipant
             meetUp.put()
             
             response = {
                 MSG_RESULT : MSG_SUCCESS,
                 "message"    : "Votre participation a été supprimée"
             }
                 
             self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
             self.response.out.write(response)
      
     except Exception, ex:
         logging.error(ex)
         self.error(500)   
Example #18
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"username"))
         user  = listUser.get()
         
         response = {
             MSG_RESULT : MSG_SUCCESS,
             "message" : "Agenda affiché!",
             "username" : user.username,
             "first_name" : user.nom,
             "last_name" : user.prenom,
             "calendars" : user.listCalendar
         }
         
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(json.dumps(response))
         
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #19
0
 def get(self):
     try:
         
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         me = listUser.get()
         
         friendToDelete = self.request.get("supprime")
         
         if me is not None and friendToDelete is not None and me.password == self.request.get("password"):
         
             listeAmi = []
             #On met à jour la liste des amis
             if me.listAmi is not None:
                 for ami in me.listAmi:
                     if ami != friendToDelete:
                         listeAmi.append(ami)
             
             listeDemande = []
             #On met à jour la liste des demandes
             for ami in me.listDemande:
                 if ami != friendToDelete:
                     listeDemande.append(ami)
             
             me.listAmi = listeAmi
             me.listDemande = listeDemande
             
             me.put()
             
             response = {
                 MSG_RESULT : MSG_SUCCESS,
                 "message" : "Ami supprimé!"
             }
     
             self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
             self.response.out.write(json.dumps(response))
         
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #20
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         user = listUser.get()
         
         if user.password == self.request.get("password"):
             dateMin = self.request.get("dateMin")
             arrayDateMin = dateMin.split('-')
             
             dateMax = self.request.get("dateMax")
             arrayDateMax = dateMax.split('-')
             
             #On inisialise le meetUp
             meetUp = MeetUp(parent=user)
             
             #On entre les données
             meetUp.nom = self.request.get("nom")
             meetUp.lieu = self.request.get("lieu")
             meetUp.duree = int(self.request.get("duree"))
             meetUp.heureMin = int(self.request.get("heureMin"))
             meetUp.heureMax = int(self.request.get("heureMax"))
             meetUp.dateMin = date(int(arrayDateMin[0]), int(arrayDateMin[1]), int(arrayDateMin[2]))
             meetUp.dateMax = date(int(arrayDateMax[0]), int(arrayDateMax[1]), int(arrayDateMax[2]))
             meetUp.supprimer = "false"
             
             meetUp.put()
             
             response = {
                 MSG_RESULT : MSG_SUCCESS,
                 MSG_KEY    : str(meetUp.key())
             }
                 
             self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
             self.response.out.write(json.dumps(response))
     
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #21
0
 def get(self):
     try:
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         user = listUser.get()
         
         if user.password == self.request.get("password"):
         
             listMeetUp = MeetUp.all()
             listMeetUp.ancestor(user.key())
             
             for meetUp in listMeetUp.run():
                 unMeetUp = {
                     'key': str(meetUp.key()),
                     'nom': str(meetUp.nom),
                     'lieu': str(meetUp.lieu),
                     'duree': str(meetUp.duree),
                     'heureMin': str(meetUp.heureMin),
                     'heureMax': str(meetUp.heureMax),
                     'dateMax': str(meetUp.dateMax),
                     'participant': meetUp.listParticipant
                 }
                 
                 list.append(unMeetUp)
             
             response = {
                 MSG_RESULT : MSG_SUCCESS,
                 "listMeetUp"    : list
             }
                 
             self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
             self.response.out.write(response)
             
                     
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #22
0
	def get(self):
		try:
			self.response.headers["Content-Type"] = 'application/json'
			q = Utilisateur.all()
			q.filter('username ='******'amis' : listeAmis
				}
			else:
				response = {
					MSG_RESULT : MSG_ERROR.
					'message' : 'L\'utilisateur n\'existe pas.'
				}
			
			self.response.out.write(json.dumps(response))
		
		except Exception, ex:
			logging.error(ex)
			self.error(500)
Example #23
0
 def get(self):
     try:
         q = Utilisateur.all()
         q.filter('username ='******'demandes' : listeDemandes
             }
         else:
             response = {
                 MSG_RESULT : MSG_ERROR,
                 'message' : 'L\'utilisateur n\'existe pas.'
             }
         
         self.response.headers["Content-Type"] = 'application/json'
         self.response.out.write(json.dumps(response))
         
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #24
0
    finally:
        return utilisateur


def login_user(email: str, password: str) -> list:

    import time

    utilisateur = None
    try:
        utilisateur = session.query(Utilisateur).filter(
            Utilisateur.email == email, Utilisateur.password == password)
        list_users = list(utilisateur)
        if list_users != []:
            response = session.set_session(list_users[0])
            time.sleep(2.5)

    except Exception as error:
        return False
    finally:
        return list(utilisateur)


if __name__ == "__main__":
    user = Utilisateur(nom_complet="Kornelius",
                       email="*****@*****.**",
                       password="******",
                       adresse="ici",
                       type="admin")
    save_utilisateur(user)
Example #25
0
 def get(self):
     try:
         q = Utilisateur.all()
         q.filter('username ='******'amis' : listeAmis,
                 'demande' : me.listDemande
             }
             
             if self.request.get("withInfo") == "1":
                 listeAmisInfo = []
                 
                 
                 for ami in me.listAmi:
                     a = Utilisateur.all()
                     a.filter("username ="******"username ="******"Content-Type"] = 'application/json'
         self.response.out.write(json.dumps(response))
     
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #26
0
 def validate_username(self, field):
     user = Utilisateur.select().where(
         Utilisateur.pseudo == field.data).first()
     if user:
         raise ValidationError(_("This Username is already taken."))
Example #27
0
 def validate_email(self, field):
     email = Utilisateur.select().where(
         Utilisateur.email == field.data).first()
     if email:
         raise ValidationError(_("This E-Mail Address is already taken."))
Example #28
0
 def get(self):
     u = db.GqlQuery('SELECT * FROM Utilisateur where userID = :userID', userID=users.get_current_user().user_id())
     if u.get() is None:
         userID = users.get_current_user().user_id()
         userEmail = users.get_current_user().email()
         calendar_serv = SERVICECALENDAR
         youtube = SERVICEYOUTUBE
         calendar = {
             'summary': 'youNotify'
         }
         if decorator.has_credentials():
             http = decorator.http()
             request = calendar_serv.calendars().insert(body=calendar).execute(http=http)
             calendar_list = {
                 'id': request['id'],
                 "defaultReminders": [
                     {
                         "method": "sms",
                         "minutes": 0
                     },
                     {
                         "method": "popup",
                         "minutes": 0
                     }
                 ]
             }
             request = calendar_serv.calendarList().insert(body=calendar_list).execute(http=http)
             watch_later = youtube.channels().list(
                 part="id,contentDetails",
                 mine=True
             ).execute(http=http)
             watch_later = watch_later.get("items", [])
             playlist_id = watch_later[0]['contentDetails']['relatedPlaylists']['watchLater']
             calendarId = request['id']
             cred = decorator.get_credentials()
             utilisateur = Utilisateur(calendarID=calendarId, userID=userID, userEmail=userEmail, credential=cred,
                                       playlistID=playlist_id)
             utilisateur.put()
             now = datetime.now(pytz.timezone('UTC'))
             i = 1
             start = now + timedelta(minutes=i)
             i += 2
             end = now + timedelta(minutes=i)
             calendar = {
                 'summary': "Thanks for registering to YouNotify!",
                 'start': {
                     'dateTime': str(start.isoformat())
                 },
                 'end': {
                     'dateTime': str(end.isoformat())
                 }
             }
             calendar_serv.events().insert(
                 calendarId=calendarId,
                 body=calendar,
                 sendNotifications=True
             ).execute(http=http)
         else:
             self.redirect(decorator.authorize_url())
     else:
         self.redirect('/youtube')
     template_values = {}
     template = JINJA_ENVIRONMENT.get_template('templates/register.html')
     self.response.write(template.render(template_values))
Example #29
0
 def get(self):
     try:
         #On va chercher l'utilisateur
         listUser = Utilisateur.all()
         listUser.filter("username ="******"moi"))
         user = listUser.get()
         
         #On va chercher l'ami à ajouter
         listUser = Utilisateur.all()
         listUser.filter("username ="******"ami"))
         amiAjouter = listUser.get()
         
         
         idMeetUp = self.request.get("meetUp")
         motDePasse = self.request.get("password")
         
         response = {
             MSG_RESULT : MSG_ERROR,
             "message"    : "Vous n'avez pas les droits d\'accès"
         }
         
         isFriend = 0
         
         #On vérifie si l'ami existe
         if amiAjouter is not None:
             #On vérifie que l'ami à ajouter est bel et bien un ami de l'utilisateur
             for ami in user.listAmi:
                 if ami == amiAjouter.nom:
                     isFriend = 1
         else:
             response = {
                 MSG_RESULT : MSG_ERROR,
                 "message"    : "Cet ami n'existe pas"
             }
            
         #On parcours tous les meetup de l'utilisateur
         listMeetUp = MeetUp.all()
         listMeetUp.ancestor(user.key())
         for meetUp in listMeetUp.run():
             #Si l'utilisateur à le droit d'invité l'ami
             if str(meetUp.key()) == idMeetUp and user.password == motDePasse and isFriend:
                 listeInvitation = amiAjouter.listDemandeMeetUp
                 
                 #On vérifie si l'ami est à ajouter
                 aAjouter = 1
                 for invitation in listeInvitation:
                     if invitation == idMeetUp:
                         aAjouter = 0
                 
                 #On ajoute l'ami
                 if aAjouter:
                     listeInvitation.append(idMeetUp)
                     
                 amiAjouter.listDemandeMeetUp = listeInvitation
                 amiAjouter.put()
                 
                 response = {
                     MSG_RESULT : MSG_SUCCESS,
                     "message"    : "L'ami a été ajouté"
                 }
             
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(response)
         
     except Exception, ex:
         logging.error(ex)
         self.error(500)
Example #30
0
def admin_utils():
    utilisateur = Utilisateur.select(Utilisateur.email, Utilisateur.pseudo,
                                     Utilisateur.date_register,
                                     Utilisateur.reputation)
    return render_template('management_utilisateurs.html', loader=utilisateur)
Example #31
0
 def get(self):
     try:
         #On initialise l'utilisateur
         user = Utilisateur()
         
         user.username = self.request.get("username")
         user.password = self.request.get("password")
         user.nom = self.request.get("nom")
         user.prenom = self.request.get("prenom")
         user.listAmi = []
         user.listDemande = []
         user.listMeetUp = []
         
         
         q = Utilisateur.all()
         q.filter('username ='******'utilisateur existe"
             }
         else: #S'il n'y a pas d'utilisateur avec le même username on l'ajout
             user.put()
             
             response = {
                 MSG_RESULT : MSG_SUCCESS,
                 MSG_KEY : str(user.key())
             }
             
         self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
         self.response.out.write(json.dumps(response))
         
     except Exception, ex:
         logging.error(ex)
         self.error(500)