"""Rights Attribute related logic.""" from backend.models.rights_attribute_query import RightsAttributeQuery from backend.models.track_rights_attribute_persister import \ TrackRightsAttributePersister def get_rights_attributes(): """Get rights attributes from DB. Returns: list of rights attributes """ return RightsAttributeQuery.get_rights_attributes() def get_suggested_rights_attributes(tuid): """Get suggested rights attributes from DB. Returns: list of suggested rights attributes """ return RightsAttributeQuery.get_suggested_rights_attributes(tuid) def get_track_rights_attributes(tuid): """Get rights attributes for the given tuid from DB. Returns: list of rights attribute ids """ return RightsAttributeQuery.get_track_rights_attributes(tuid) def get_track_rights_attributes_edits(tuid): """Get rights attributes edits for the given tuid from DB. Returns: list of rights attribute ids """ return RightsAttributeQuery.get_track_rights_attributes_edits(tuid) def update_track_rights_attributes(tracks, orchard_identity_id): """Update the rights attributes for a set of tracks. Args: tracks: The list of tuid / rights attribute combinations to set orchard_identity_id: The orchard identity id Returns: response.Response: success message or database error """ return TrackRightsAttributePersister.sync_track_rights_attributes( tracks=tracks, orchard_identity_id=orchard_identity_id) def update_track_rights_attributes_edits(tracks): """Update the rights attributes edits for a set of tracks. Args: tracks: The list of tuid / rights attribute combinations to set Returns: response.Response: success message or database error """ return TrackRightsAttributePersister.sync_track_rights_attributes_edits(tracks=tracks) def write_rights_attribute_suggestions(unique_track_id, suggestions, user_uuid, review_queue_id): """Write a suggestion record for a track's suggested rights attributes. Args: unique_track_id (int): The track primary key. suggestions (list): The full suggestion items from the model. user_uuid (str): The user UUID from Orchard-Identity-Id header. review_queue_id (int): The review queue ID from the request. """ TrackRightsAttributePersister.write_rights_attribute_suggestions( unique_track_id=unique_track_id, suggestions=suggestions, user_uuid=user_uuid, review_queue_id=review_queue_id, ) def bulk_delete_track_rights_attributes(tuids): """Delete the track rights attributes for multiple tracks.""" TrackRightsAttributePersister.bulk_delete_track_rights_attributes(tuids=tuids)