Example #1
0
 def delete(self, **kwargs):
     """Delete Location record."""
     iloc_search = InternalLocationSearch()
     iloc_search_res = iloc_search.search_by_location_pid(
         location_pid=self["pid"])
     if iloc_search_res.count():
         raise RecordHasReferencesError(
             record_type="Location",
             record_id=self["pid"],
             ref_type="Internal Location",
             ref_ids=sorted([res["pid"] for res in iloc_search_res.scan()]),
         )
     return super().delete(**kwargs)
Example #2
0
def index_internal_location_after_location_indexed(loc_pid):
    """Index internal locations pointing to location."""
    log_func = partial(_log,
                       origin_rec_type='Location',
                       origin_recid=loc_pid,
                       dest_rec_type='InternalLocation')

    log_func(msg=MSG_ORIGIN)
    for iloc in InternalLocationSearch().search_by_location_pid(
            location_pid=loc_pid).scan():
        iloc_pid = iloc["pid"]
        _index_record_by_pid(InternalLocation, iloc_pid, log_func)