Exemplo n.º 1
0
    def create_item(self, item_params):
        try:
            target_tree_item = TreeItem.objects.get(name=u'Импорт')
        except TreeItem.DoesNotExist:
            target_tree_item = TreeItem(parent_id=None, name=u'Импорт')
            target_tree_item.save()
            target_section = Section(is_meta_item=False)
            target_section.save()
            target_tree_item.section = target_section
            target_tree_item.save()

        new_tree_item = TreeItem(name=item_params['name'][:200],
                                 parent=target_tree_item)
        new_item = Item(
            price=item_params['price'],
            identifier=item_params['identifier'],
            quantity=item_params['quantity'],
        )
        new_tree_item.save()
        new_item.save()
        new_tree_item.item = new_item
        new_tree_item.save()
Exemplo n.º 2
0
 def create_item(self, item_params):
     try:
         target_tree_item = TreeItem.objects.get(name=u'Импорт')
     except TreeItem.DoesNotExist:
         target_tree_item = TreeItem(parent_id=None, name=u'Импорт')
         target_tree_item.save()
         target_section = Section(is_meta_item=False)
         target_section.save()
         target_tree_item.section = target_section
         target_tree_item.save()
         
     new_tree_item = TreeItem(name = item_params['name'][:200],
         parent=target_tree_item)
     new_item = Item(
         price = item_params['price'],
         identifier = item_params['identifier'],
         quantity = item_params['quantity'],
     )
     new_tree_item.save()
     new_item.save()
     new_tree_item.item = new_item
     new_tree_item.save()