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
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] version.save(host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB, refresh=True) version_ids.append(version.id) # Falkirk Fair (LV1.2) version = Version() version.lv_id = "LV1.2" version.title = "Falkirk Fair" version.language = "Scots" version.singer = singer_ids[1] # Mickey McDaid version.collector = "Jimmy McBride" version.collected_date = "1985-02" version.source = "Jimmy McBride, 'My Parents Reared Me Tenderly', 1985, pp. 37-38" version.add_location(name="Falkirk") version.add_reference("ROUD", "10368") version.comments = "Only complete version known"