Exemplo n.º 1
0
 def _rmentity(self, rmclass):
     for id in request.params.iterkeys():
         entity = Session.query(rmclass).get(id)
         if entity:
             Session.delete(entity)
     Session.commit()
     redirect_to(action='rmentities')
Exemplo n.º 2
0
 def remove_from_whitelist(self):
     for id in request.params.iterkeys():
         entry = Session.query(Whitelist).get(id)
         if entry:
             Session.delete(entry)
         Session.commit()
         redirect_to(action='manage_whitelist')
Exemplo n.º 3
0
 def delete(self, id):
     playlist = Session.query(Playlist).get(int(id))
     if playlist.ownerid != session["userid"]:
         abort(404, "Cannot delete another man's playlist!")
     Session.delete(playlist)
     Session.commit()
     return "1"
Exemplo n.º 4
0
    def delete(self,id):
        if not id:
            abort(400)
        user = Session.query(User).get(session['userid'])
        spot = Session.query(Spotlight).get(id)
        if not spot or not spot in user.spotlights:
            abort(404)

        Session.delete(spot)
        Session.commit()
        user.update_profile()
        return "1"
Exemplo n.º 5
0
    def save(self):
        if not (request.params.has_key("playlist") or request.params.has_key("songs")):
            abort(400, "playlist or songs parameter not provided")

        user = Session.query(User).get(session["userid"])

        playlist = int(request.params["playlist"])
        playlistobj = (
            Session.query(Playlist).filter(and_(Playlist.id == playlist, Playlist.ownerid == session["userid"])).first()
        )
        if not playlistobj:
            abort(400)

        songs = request.params["songs"]

        old_pl_songs = playlistobj.songs
        for old_pl_song in old_pl_songs:
            Session.delete(old_pl_song)
        Session.commit()

        if songs != "":
            i = 0
            for song in songs.split(","):
                try:
                    songid = int(song)
                    if not user.get_song_by_id(songid):
                        raise ValueError
                except ValueError:
                    abort(404)
                pl_song = PlaylistSong(playlist, i, songid)
                pl_song.playlist = playlistobj
                Session.save(pl_song)
                i += 1

        Session.commit()
        return "1"