in rabbitmq/AtomResponderProcessor.py [0:0]
def get_or_create_record(self, atomid:str, projectid:str, commissionId:int) -> (DeliverableAsset, bool):
"""
tries to look up a pre-existing asset with the same atom id.
if that can't be found, tries to find a Deliverable bundle for the given project
if that can't be found, then it creates a deliverable bundle from the provided information and saves it to the db
once a bundle is available, it creates a new DeliverableAsset and returns it WITHOUT saving
:param atomid: the atom uuid
:param projectid: (string representation of) the numeric projectlocker project id
:param commissionId: the numeric commission id
:return: a DeliverableAsset
"""
try:
asset = DeliverableAsset.objects.get(atom_id=atomid)
logger.info("Found pre-existing asset id {} for atom id {}".format(asset.pk, atomid))
return asset, False
except DeliverableAsset.DoesNotExist:
pass
##if we get here, there is no DeliverableAsset attached to the given id
logger.info("No pre-existing asset for atom id {}, creating one".format(atomid))
if projectid is None:
bundle = self.get_or_create_unattached_bundle()
else:
bundle = self.get_or_create_bundle(projectid, commissionId)
timezone = pytz.timezone("UTC")
timestamp = timezone.localize(datetime.now()).isoformat()
asset = DeliverableAsset(
type=AssetChoices.DELIVERABLE_ASSET_TYPE_VIDEO_PUBLISHED_ATOM_FILE,
atom_id=atomid,
deliverable=bundle,
changed_dt=timestamp,
)
return asset, True