Пример #1
0
    def post(self, user_name, ranking_id):

        user = User.get_by_name(user_name)
        ranking = Ranking.get_by_id(int(ranking_id))
        ranking.like(user)

        if not user:
            self.error(404)
        if self.get_current_user():
            self.write(str(ranking.number_of_likes))
        else:
            self.redirect("/signup")
Пример #2
0
    def get(self, ranking_id):
        ranking = Ranking.get_by_id(int(ranking_id))
        if not ranking:
            self.error(404)
            return

        user = self.get_current_user()
        if user:
            is_sorted = ranking.is_sorted_by(user)
            self.render("ranking.html", user=ranking.user, ranking=ranking, is_sorted=is_sorted, current_user=user)
        else:
            self.redirect("/signup")
Пример #3
0
 def post(self, user_name, ranking_id): 
     
     user = User.get_by_name(user_name)
     ranking = Ranking.get_by_id(int(ranking_id))
     ranking.like(user)
     
     if not user:
         self.error(404)
     if self.get_current_user():
         self.write(str(ranking.number_of_likes))
     else:
         self.redirect("/signup")
Пример #4
0
    def post(self, ranking_id):
        
        user = self.get_current_user()
        ranking = Ranking.get_by_id(int(ranking_id))

        if user in ranking.get_users():
            self.response.out.write('You have already submitted this ranking!')
            return

        ranking_json = json.loads(self.request.get('ranking'))
        vote = Vote(user=user, parent=ranking, ranks=ranking_json["ranks"])
        vote.put()
        ranking.update(vote)
        self.redirect('/ranking/'+str(ranking_id))