Beispiel #1
0
 def _create_or_update_manufactory(self):
     manufactory = self.asset_data.get("essential_information").get(
         "manufactory")
     manufactory_obj = models.Manufactory.objects.filter(
         name=manufactory).first()
     if manufactory_obj:
         return manufactory_obj
     else:
         new_manufatory = models.Manufactory(name=manufactory)
         new_manufatory.save()
         return new_manufatory
Beispiel #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')
         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) )
Beispiel #3
0
 def __create_or_update_manufactory(self, ignore_errs=False):
     try:
         self.__verify_field(self.data, "manufactory", str)
         manufactory = self.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:
                 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))