def delete_version(cls, version_id): version = Version().get(version_id, links=True) if version is None: raise NotFoundException() # remove the version from storage first version.remove() # then remove the singer and re-index any related objects VersionIndex.delete_by_id(version.id)
def delete_song(cls, song_id): song = Song().get(song_id, links=True) if song is None: raise NotFoundException() # remove the song from storage first song.remove() # deleting a song also deletes all the associated versions for v in song.versions: version = Version().get(v, links=True) version.remove() # then remove the singer and re-index any related objects SongIndex.delete_by_id(song.id)
def create_version(cls, version_json, singer, song): if version_json is None: return None # create the version object and save it to the store version = Version({"version" : version_json}) if singer is not None: version.singer = singer if song is not None: version.song = song version.save() # call the indexing process, and index this object and all # related ones VersionIndex.by_id(version.id, cascade=True) return version
def update_version(cls, version_id, version_json=None, singer=None, song=None): # retrieve and update the version object in the desired way version = Version().get(version_id, links=True) if version is None: raise NotFoundException() if version_json is not None: version.patch_version(version_json, replace_all=True, keep_id=True) if singer is not None: version.singer = singer if song is not None: version.song = song version.save() # call the indexing process, and index this object and all related ones VersionIndex.by_id(version.id, cascade=True) return version
""" LV1.1 Falkirk Fair Scots Rab Morrison Hamish Henderson 1962.05 School of Scottish Studies Sound Archive, SA1962.016.A9 Falkirk 10368 Fragments only bothy; farm; bawdy http://www.tobarandualchais.co.uk/fullrecord/23006/1 LV1.2 Falkirk Fair Scots Mickey McDaid Jimmy McBride 1985.02 Jimmy McBride, 'My Parents Reared Me Tenderly', 1985, pp. 37-38 Falkirk 10368 Only complete version known. bothy; farm http://www.itma.ie/inishowen/song/falkirk_fair_mickey_mcdaid LV2.1 Dumfries Hiring Fair Scots Stravaig (group) Phyllis Martin [unknown] Movin' on' CD Album [CDTRAX074], 1994 Dumfries bothy; farm LV2.2 Dumfries Hiring Fair Scots Peter Fairbairn Sheila Douglas 1995 Come Gie's a Sang', Sheila Douglas, 1995, p. 31 Dumfries 11283 bothy; farm LV3.1 The Boreland of Balmaghie Parker of the Boreland Scots Jack McCaig James Brown c. 2000 Footstompin' forum: http://www.footstompin.com/forum/1/21451/1 Castle Douglas Boreland of Balmaghie bothy; farm http://www.footstompin.com/forum/1/21451/1 [YES] LV4.1 Andrew Lammie Scots Sheila Stewart Hamish Henderson 1953 School of Scottish Studies Sound Archive, SA1953.238.A7 Fyvie Mill of Tifty 98 1018 233 Fragment only. Other instances of same singer's version: [other urls] love; tragedy; murder http://www.tobarandualchais.co.uk/fullrecord/26090/1 LV4.2 Andrew Lammie Mill o Tifty's Annie Scots Jeannie Robertson Hamish Henderson & Jean Ritchie 1953.09 School of Scottish Studies Sound Archive, SA1953.197.5 Fyvie Mill of Tifty 98 1018 233 21 verses. love; tragedy; murder http://www.tobarandualchais.co.uk/fullrecord/24187/1 / http://canmore.rcahms.gov.uk/en/site/19194/details/mill+of+tifty+waterwheel/ [Yes] LV5.1 The Bonnie Hoose o Airlie Scots Jeannie Robertson Hamish Henderson & Jean Ritchie 1952 School of Scottish Studies Sound Archive, SA1952.043.A10 Airlie, Angus 794 233 199 6 verses. murder; castle; arson http://www.tobarandualchais.co.uk/fullrecord/49656/1 LV6.1 The Laird o Drum Scots Jeannie Robertson Hamish Henderson & Jean Ritchie 1962.05 School of Scottish Studies Sound Archive, SA1962.013.A11 Drum Castle, Drumoak, Aberdeenshire 247 835 236 Fragment only. marriage; social class http://www.tobarandualchais.co.uk/fullrecord/23305/1 [Yes] LV7.1 The Cauld Water Well Scots / English Hamish Robb Local Voices 2013.08.24 Local Voices Sound Archive [local ref] Dundee No other source known. Also recorded but with fewer verses on Local Voices Sound Archive refs [refs.] wishing well; river """ # Falkirk Fair (LV1.1) version = Version() version.lv_id = "LV1.1" version.title = "Falkirk Fair" version.language = "Scots" version.singer = singer_ids[0] # Rab Morrison version.collector = "Hamish Henderson" version.collected_date = "1962-05" version.source = "School of Scottish Studies Sound Archive, SA1962.016.A9" version.add_location(name="Falkirk") version.add_reference("ROUD", "10368") version.comments = "Fragments only" version.tags = ["bothy", "farm", "bawdy"] version.media_url = "http://www.tobarandualchais.co.uk/fullrecord/23006/1" # version.lyrics = "" # version.photo_url = "" version.song = song_ids[0]
# record the song-to-song relationships required rel = _normalise(row[6]) if rel is not None: SONG_SONG_MAP.append((slv_id, rel)) # save the object via the web API (to test it) resp = requests.post(api + "/songs", data=json.dumps({"song" : song.data.get("song")})) print "saved song", resp.json().get("id") # record the id and map it to the lvid for later use id = resp.json().get("id") SONG_LV_ID_MAP[slv_id] = id # now lift the version out of this row version = Version() vlv_id = _normalise(row[8]) version.lv_id = vlv_id sid = SONG_LV_ID_MAP.get(vlv_id.split(".")[0]) version.song = sid vtitle = _normalise(row[9]) if vtitle is not None: version.title = vtitle valt = _normalise(row[10]) if valt is not None: version.alternative_title = valt