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
def get(self): p = Publicacion.recupera(self.request) autor = users.get_current_user().email() yaMeGusta = Like.query(Like.autor == autor, Like.publicacion == p.key) if yaMeGusta.count() == 0: like = Like(autor=autor, publicacion=p.key) like.put() time.sleep(1) return self.redirect("/")
def post(self, post_id): key = db.Key.from_path('Post', int(post_id), parent=blog_key()) post = db.get(key) if not post: self.error(404) return """ On posting comment, new comment tuple is created and stored, with relationship data of user and post. """ c = "" if (self.user): # On clicking like, post-like value increases. if (self.request.get('like') and self.request.get('like') == "update"): likes = db.GqlQuery("select * from Like where post_id = " + post_id + " and user_id = " + str(self.user.key().id())) if self.user.key().id() == post.user_id: self.redirect("/blog/" + post_id + "?error=You cannot like your " + "post.!!") return elif likes.count() == 0: l = Like(parent=blog_key(), user_id=self.user.key().id(), post_id=int(post_id)) l.put() # On commenting, it creates new comment tuple if (self.request.get('comment')): c = Comment(parent=blog_key(), user_id=self.user.key().id(), post_id=int(post_id), comment=self.request.get('comment')) c.put() else: self.redirect("/login?error=You need to login before " + "performing edit, like or commenting.!!") return comments = db.GqlQuery("select * from Comment where post_id = " + post_id + "order by created desc") likes = db.GqlQuery("select * from Like where post_id=" + post_id) self.render("permalink.html", post=post, comments=comments, noOfLikes=likes.count(), new=c)
def get(self): usr, url_usr, userActual = Utilities.checkUser() if userActual is None: return self.redirect("/") try: if usr: tuit = Tuit.getTuit(self.request) if not Like.exists(userActual.key, tuit.key): like = Like(tuit=tuit.key, user=userActual.key) like.put() time.sleep(2) finally: return self.redirect("/tuits/list")
def post(self): imagen = self.request.GET["id"] nombre = self.request.get("edNombre", "") email = self.request.get("edEmail", "") if len(nombre) < 0 or not(nombre) or len(email) < 0 or not(email): return self.redirect("/") else: usr = users.get_current_user() user = mgt_usr.retrieve(usr) print("EL PRINT ESTA AQUI!!!!!", user.key) like = Like(usuario=user.key, imagen=ndb.Key(urlsafe=imagen)) like.put() time.sleep(1) return self.redirect("/")