Esempio n. 1
0
def _create_part(creator_profile, asset_data, part_info_data, sn):
    part_info = PartInfo(**part_info_data)
    part_info.save(user=creator_profile.user)
    asset = Asset(part_info=part_info,
                  sn=sn.strip(),
                  created_by=creator_profile,
                  **asset_data)
    asset.save(user=creator_profile.user)
    return asset.id
Esempio n. 2
0
def _create_part(creator_profile, asset_data, part_info_data, sn):
    part_info = PartInfo(**part_info_data)
    part_info.save(user=creator_profile.user)
    asset = Asset(
        part_info=part_info,
        sn=sn.strip(),
        created_by=creator_profile,
        **asset_data
    )
    asset.save(user=creator_profile.user)
    return asset.id
Esempio n. 3
0
def _update_part_info(user, asset, part_info_data):
    if not asset.part_info:
        part_info = PartInfo()
    else:
        part_info = asset.part_info
    part_info.device = part_info_data.get('device')
    part_info.source_device = part_info_data.get('source_device')
    part_info.barcode_salvaged = part_info_data.get('barcode_salvaged')
    part_info.save(user=user)
    asset.part_info = part_info
    asset.part_info.save(user=user)
    return asset
Esempio n. 4
0
def _update_part_info(user, asset, part_info_data):
    if not asset.part_info:
        part_info = PartInfo()
    else:
        part_info = asset.part_info
    part_info.device = part_info_data.get('device')
    part_info.source_device = part_info_data.get('source_device')
    part_info.barcode_salvaged = part_info_data.get('barcode_salvaged')
    part_info.save(user=user)
    asset.part_info = part_info
    asset.part_info.save(user=user)
    return asset
Esempio n. 5
0
 def create_part_info(self):
     part_info = PartInfo()
     part_info.source_device = self.asset
     part_info.device = self.asset
     part_info.save(user=self.request.user)
     return part_info
Esempio n. 6
0
 def create_part_info(self):
     part_info = PartInfo()
     part_info.source_device = self.asset
     part_info.device = self.asset
     part_info.save(user=self.request.user)
     return part_info