Exemple #1
0
    def get(self):
        try:
            id = self.request.GET["id"]
            user = ndb.Key(urlsafe=id).get()
            try:
                creak = self.request.get("idcreak", "").strip()
                creak = ndb.Key(urlsafe=creak).get()
            except:
                creak = None

            if creak:
                p = "RC from "+creak.name+" "+creak.surname+" @"+creak.user+" \r\n  "
                user.creaks = user.creaks + 1
                user.put()
                if user.username != creak.user:
                    notification = Notification(user=creak.user,msg="@"+user.username+" recreak your creak: '"+creak.creak+"'",read=0)
                    notification.put()
                    time.sleep(1)

                cr = Creak(creak=p+creak.creak, user=user.username, name=user.name, surname=user.surname)
                cr.put()
                self.redirect("/welcome?id="+id)
            else:
                self.response.write("An error occurred.")
                return
        except:
            self.response.write("An id error occurred.")
            return
Exemple #2
0
 def get(self):
     try:
         id = self.request.GET["id"]
         user = ndb.Key(urlsafe=id).get()
 
         try:
             idcreak = self.request.GET["idcreak"]
             creak = ndb.Key(urlsafe=idcreak).get()
         except:
             creak = None
 
         if creak:
             like = Like(idcreak=creak.key.urlsafe(), iduser=user.username)
             like.put()
             time.sleep(1)
             if user.username != creak.user:
                 notification = Notification(user=creak.user,msg="@"+user.username+" liked your creak: '"+creak.creak+"'",read=0)
                 notification.put()
                 time.sleep(1)
             self.redirect("/welcome?id="+id)
         else:
             self.response.write("An error occurred.")
     except:
         self.response.write("An error occurred.")
         return