Beispiel #1
0
 def test_remove_photo_from_album(self):
     photo_id = 1
     album_id = 1
     crud.remove_photo_from_album(photo_id, album_id)
     photo = crud.get_photo_by_id(photo_id)
     album = crud.get_album_by_id(album_id)
     photos = album.photos
     self.assertNotIn(photo, photos)
Beispiel #2
0
def post_new_album(item: AlbumItem):
    artist = crud.get_artist_by_id(item.artist_id)
    if artist:
        new_album = crud.add_new_album(item.title, item.artist_id)
        new_album_id = new_album.lastrowid
        return crud.get_album_by_id(new_album_id)

    else:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND,
            detail={"error": "The given artist_id was not found."},
        )
Beispiel #3
0
def display_album(album_id):
    """Display photos in a selected album"""

    album = crud.get_album_by_id(album_id)
    albums = crud.get_albums_by_user_id(session.get('user_id'))
    photoalbum = album.photos

    global current_photo_list
    current_photo_list = photoalbum
    return render_template("album_details.html",
                           album=album,
                           albums=albums,
                           photoalbum=photoalbum)
Beispiel #4
0
def get_album_by_album_id(album_id):
    album = crud.get_album_by_id(album_id)
    return jsonify(album.to_dict())
Beispiel #5
0
def get_photos_by_album_id(album_id):
    album = crud.get_album_by_id(album_id)
    return jsonify([photo.to_dict() for photo in album.photos])
Beispiel #6
0
def get_album(album_id: int):
    return crud.get_album_by_id(album_id)
Beispiel #7
0
    def test_get_album_by_id(self):
        album = crud.get_album_by_id(1)

        assert album.album_id == 1