Exemplo n.º 1
0
 def test_user_get_all_empty(self):
     from balistos.models.user import User
     user = User.get_by_username('test_user')
     Session.delete(user)
     Session.flush()
     self.assertEqual(0, User.get_all().count())
     self.assertIsNone(User.get_by_username('test_user'))
Exemplo n.º 2
0
def remove_playlist_clip(playlist, youtube_video_id):
    """
    Remove clip from playlist

    :param    playlist: playlist we want to delete clip from
    :type     playlist: balistos.models.Playlist
    :param    clip:     youtube video id we want to delete from playlist
    :type     clip:     [clip type]

    :returns  True if removed, False otherwise
    :rtype    boolean
    """

    pclip = PlaylistClip.get_by_playlist_and_clip(
        playlist,
        Clip.get(youtube_video_id)
    )
    if not pclip:
        return False

    state = pclip.state
    Session.delete(pclip)

    if state == 2:
        next_pclip = PlaylistClip.get_queue_playlist_clip(playlist)
        play_next_clip(playlist, pclip, next_pclip)
    elif state == 1:
        active_pclip = PlaylistClip.get_active_playlist_clip(playlist)
        set_next_in_queue(playlist, active_pclip.clip.youtube_video_id)
    return True
Exemplo n.º 3
0
 def test_playlist_get_all_empty(self):
     from balistos.models.playlist import Playlist
     playlist = Playlist.get('test_playlist')
     Session.delete(playlist)
     Session.flush()
     self.assertEqual(0, Playlist.get_all().count())
     self.assertIsNone(Playlist.get('test_playlist'))
Exemplo n.º 4
0
 def test_pclip_get_all_empty(self):
     from balistos.models.clip import PlaylistClip
     pclips = PlaylistClip.get_all()
     for pclip in pclips:
         Session.delete(pclip)
     Session.flush()
     self.assertEqual(0, PlaylistClip.get_all().count())
     self.assertEqual(0, PlaylistClip.get_all().count())
Exemplo n.º 5
0
 def test_clip_get_all_empty(self):
     from balistos.models.clip import Clip
     clips = Clip.get_all()
     for clip in clips:
         Session.delete(clip)
     Session.flush()
     self.assertEqual(0, Clip.get_all().count())
     self.assertIsNone(Clip.get('cpV0ygkmhP4'))
Exemplo n.º 6
0
 def delete(self):
     # If the comment has replies it will only marked as deleted
     if len(self.replies):
         self.comment = "<DELETED>"
         self.deleted = True
     # If note it will fully deleted
     else:
         DBSession.delete(self)
Exemplo n.º 7
0
def handle_deletion(data):
    """Handle a Twitter status."""
    
    id_ = data['delete']['status']['id']
    tweet = Tweet.query.get(id_)
    if tweet:
        Session.delete(tweet)
    
    # XXX debug.
    logger.info('Deleted %d' % id_)
Exemplo n.º 8
0
 def test_populate_columns_entry_without_user(self):
     self.config.testing_securitypolicy(userid='*****@*****.**',
                                        permissive=False)
     Session.delete(User.by_id(3))
     Session.flush()
     view = self._make_view()
     self.assertEqual(view.columns['comment'], u'unread entry')
     self.assertEqual(view.columns['event_type_id'],
                      'User Changed Password')
     self.assertEqual(view.columns['user_id'], None)
     self.assertEqual(view.columns['action'], None)
Exemplo n.º 9
0
def artifakt_before_flush(session, *_):
    """When deleting a bundle certain contained artifacts should also be deleted"""
    for obj in session.deleted:
        if type(obj) is Artifakt:
            if obj.is_bundle:
                for af in obj.artifacts:
                    if not set(af.bundles) - {obj}:  # If the artifact would not be in a bundle anymore
                        if not af.keep_alive:
                            DBSession.delete(af)
            else:  # Safety checks. We try to prevent reaching this in the views.
                if obj.bundles:
                    raise ValueError("Won't delete {} (belongs to bundle)".format(obj.sha1))
Exemplo n.º 10
0
def play_next_clip(playlist, active_pclip, next_pclip):
    """
    Play next clip (clip in queue) in playlist

    :param    playlist: current playlist
    :type     playlist: balistos.models.playlist.Playlist
    """
    if next_pclip:
        youtube_video_id = next_pclip.clip.youtube_video_id
        Session.delete(active_pclip)
        Session.flush()
        active_pclip = next_pclip
        active_pclip.state = 2
        active_pclip.started = datetime.now()
        Session.flush()
        next_pclip = set_next_in_queue(
            playlist,
            youtube_video_id,
        )
        Session.flush()
        return active_pclip, next_pclip