Esempio n. 1
0
File: core.py Progetto: myAlike/Mark
 def __create_or_update_manufactory(self, ignore_errs=False):
     try:
         self.__verify_field(self.clean_data, 'manufactory', str)
         manufactory = self.clean_data.get('manufactory')
         if not len(self.response['error']) or ignore_errs == True:  # no processing when there's no error happend
             obj_exist = models.Manufactory.objects.filter(manufactory=manufactory)
             if obj_exist:
                 obj = obj_exist[0]
             else:  # create a new one
                 obj = models.Manufactory(manufactory=manufactory)
                 obj.save()
             self.asset_obj.manufactory = obj
             self.asset_obj.save()
     except Exception as e:
         self.response_msg('error', 'ObjectCreationException', 'Object [manufactory] %s' % str(e))
Esempio n. 2
0
 def __create_or_update_manufactory(self, ignore_errs=False):
     try:
         #进行代码检测
         self.__verify_field(self.clean_data, 'manufactory', str)
         #从数据里获取制造商信息
         manufactory = self.clean_data.get('manufactory')
         print(manufactory)
         if not len(self.response['error']) or ignore_errs == True:
             obj_exist = models.Manufactory.objects.filter(
                 manufactory=manufactory)
             #判断这个制造商存在不存在
             if obj_exist:
                 obj = obj_exist[0]
             else:
                 #不存在插入
                 obj = models.Manufactory(manufactory=manufactory)
                 obj.save()
             self.asset_obj.manufactory = obj
             self.asset_obj.save()
     except Exception as e:
         self.response_msg('error', '对象创建异常',
                           'Object [manufactory] %s' % str(e))
Esempio n. 3
0
 def __create_or_update_manufactory(self, ignore_errs=False):
     """
     创建制造
     :param ignore_errs:
     :return:
     """
     try:
         self.__verify_field(self.clean_data, 'manufactory', str)
         manufactory = self.clean_data.get('manufactory')
         if not len(self.response['error']
                    ) or ignore_errs == True:  # 没有处理的时候或没有错误发生
             obj_exist = models.Manufactory.objects.filter(
                 manufactory=manufactory)
             if obj_exist:  # 如果制造商不存在则创建
                 obj = obj_exist[0]
             else:  # create a new one
                 obj = models.Manufactory(manufactory=manufactory)
                 obj.save()
             self.asset_obj.manufactory = obj
             self.asset_obj.save()
     except Exception as e:
         self.response_msg('error', 'ObjectCreationException',
                           'Object [manufactory] %s' % str(e))