提交 1027e68a 编写于 作者: D Doug Farrell

Fixed problem with the albums link when no artist is supplied. Also added...

Fixed problem with the albums link when no artist is supplied. Also added raising an exception if no .env file is found
上级 259603a1
......@@ -36,7 +36,7 @@ def get_books_by_publisher(data, ascending=True):
def get_authors_by_publisher(data, ascending=True):
"""Returns the authors by the associated publisher as a Panda series
"""Returns the authors by the associated publisher as a pandas series
Args:
data: The pandas dataframe to get the data from
......
......@@ -38,14 +38,18 @@ class CreateAlbumForm(FlaskForm):
def albums(artist_id=None):
form = CreateAlbumForm()
# Get the artist
artist = (
db.session.query(Artist)
.filter(Artist.artist_id == artist_id)
.one_or_none()
)
form.artist.data = artist.name
# did we get an artist id?
if artist_id is not None:
# Get the artist
artist = (
db.session.query(Artist)
.filter(Artist.artist_id == artist_id)
.one_or_none()
)
form.artist.data = artist.name
# otherwise, no artist
else:
artist = None
# Is the form valid?
if form.validate_on_submit():
......
......@@ -4,7 +4,11 @@ from pathlib import Path
from dotenv import load_dotenv
# Load the environment variables from .env file
load_dotenv()
path = Path(__file__).parent / ".env"
if path.exists():
load_dotenv()
else:
raise IOError(".env file not found")
class Config:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册