def __create_ram(self): ram_info = self.clean_data.get('ram') if ram_info: for ram_item in ram_info: try: self._type_validation(ram_item, 'capacity', int) if not len(self.response['error'] ): #no processing when there's no error happend data_set = { 'asset_id': self.asset_obj.id, 'slot': ram_item.get("slot"), 'sn': ram_item.get('sn'), 'capacity': ram_item.get('capacity'), 'manufactory': ram_item.get('manufactory'), 'model': ram_item.get('model'), } obj = models.RAM(**data_set) obj.save() except Exception as e: print(e) self.response_msg('error', 'CreationException', 'Object [ram] %s' % str(e)) else: self.response_msg('error', 'LackOfData', '提交的内容没有 RAM 信息')
def __create_ram_component(self): ram_info = self.clean_data.get('ram') if ram_info: for ram_item in ram_info: try: self.__verify_field(ram_item, 'capacity', int) if not len(self.response['error'] ): #no processing when there's no error happend data_set = { 'asset_id': self.asset_obj.id, 'slot': ram_item.get("slot"), 'sn': ram_item.get('sn'), 'capacity': ram_item.get('capacity'), 'model': ram_item.get('model'), } obj = models.RAM(**data_set) obj.save() except Exception as e: self.response_msg('error', 'ObjectCreationException', 'Object [ram] %s' % str(e)) else: self.response_msg( 'error', 'LackOfData', 'RAM info is not provied in your reporting data')