Exemplo n.º 1
0
 def vote(self, pli_id, direc):
     if not "voted_arr" in session: session["voted_arr"] = []
     voted = session["voted_arr"]
     if User.is_admin() or not pli_id in voted:
         v = Vote(playlist_item_id=pli_id, user_id=User.current_id(), direction=direc)
         v.save()
         voted.append(pli_id)
         session["voted_arr"] = voted  
         self.update_subscribers()
         return common.buildDialogResponse("Thanks for the input!", 200)
     else:
         return common.buildDialogResponse("Nice try sucka! You already voted", 409)
Exemplo n.º 2
0
    def add_track(self, prov_id, user_id, special):
        
        #make sure it's in the DB
        t = MusicLibrary.get_track(provider_id=prov_id)
        
        if not User.is_admin() and self._numTracksFromUser(user_id) > 1:
            return common.buildDialogResponse("You can only have 2 songs on the playlist at once :(", 409)

        if self.playlist().contains_track(t.id):
            return common.buildDialogResponse("Someone already added that one (but you can go vote it up).", 409)
        
        PlaylistItem(track_id=t.id, location_id=self.id, user_id=user_id, date_added=str(datetime.now()), special=special).save()
        self.update_subscribers()
        return common.buildDialogResponse("Song added!", 200)
Exemplo n.º 3
0
def login():
    if request.form["method"] == "facebook":
        usr = User.facebook_login(request.form["fbid"], request.form["fbat"])
        if usr:
            return usr.to_json()
        else:
            return common.buildDialogResponse("Invalid login", 401)
Exemplo n.º 4
0
 def decorated_function(*args, **kwargs):
     if not User.is_admin():
         return common.buildDialogResponse("Admins only", 401)
     return f(*args, **kwargs)
Exemplo n.º 5
0
 def decorated_function(*args, **kwargs):
     if User.current_id() is None:
         return common.buildDialogResponse("Please log in.", 401)
     return f(*args, **kwargs)