Changes for refactor of references view, add unique keys for some tables
References sites table updated so we can filter by site later, added timestamp to tunes so they can be sorted in certain contexts, enforced uniqueness on some tables that were causing issues
This commit is contained in:
parent
064e672ab7
commit
507531fbff
7 changed files with 252 additions and 10 deletions
|
|
@ -65,7 +65,7 @@ def list_references(tune_id):
|
|||
def add_reference(tune_id):
|
||||
db.get_or_404(Tune, tune_id)
|
||||
data = request.get_json(force=True)
|
||||
ref = Reference(tune_id=tune_id, link=data.get("link"), site=data.get("site"))
|
||||
ref = Reference(tune_id=tune_id, link=data.get("link"), site_id=data.get("site_id"))
|
||||
db.session.add(ref)
|
||||
db.session.flush()
|
||||
for m in data.get("musicians", []):
|
||||
|
|
@ -81,7 +81,7 @@ def add_reference(tune_id):
|
|||
def update_reference(tune_id, ref_id):
|
||||
ref = db.get_or_404(Reference, ref_id)
|
||||
data = request.get_json(force=True)
|
||||
for field in ("link", "site"):
|
||||
for field in ("link", "site_id"):
|
||||
if field in data:
|
||||
setattr(ref, field, data[field])
|
||||
db.session.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue