Exemple #1
0
 def create_or_update_categories(self, selector):
     categories = Category.objects.filter(active=True)
     category_by_name = {c.name.lower(): c for c in categories}
     category_by_css = {}
     for option in selector.xpath('//select[@name="category"]/option'):
         category_name = option.extract_first_value_with_xpath('./text()')
         if category_name == '':
             continue
         category_css_name = option.extract_first_value_with_xpath(
             './@value')
         lower_name = category_name.lower()
         if lower_name in category_by_name:
             cat = category_by_name.pop(lower_name)
             if not cat.active:
                 cat.name = category_name.capitalize()
                 cat.active = True
                 cat.save()
                 self.debug_info(
                     'Reactive category {0}'.format(category_name))
         else:
             cat = Category(name=category_name.capitalize(), active=True)
             cat.save()
             self.debug_info(
                 'Create new category {0}'.format(category_name))
         category_by_css[category_css_name] = cat
     self.category_by_css = category_by_css
 def testGetOrCreate2(self):
     category, created = Category.objects.get_or_create(name = 'someblogs2', parent = self.blogs)
     self.assertTrue(created)
     category, created = Category.objects.get_or_create(name = 'someblogs2', parent = self.blogs)
     self.assertFalse(created)
     cat = Category(name = 'someblogs3', parent = self.blogs)
     cat.save(force_insert = True)
    def testNewCategoryWithParent(self):
        """ Verify create with parent and change parent is ok """
        category = Category(name = 'level1', parent = self.blogs)
        self.assertNumQueries(1, category.save())
        self.assertEquals(category.parent.pk, self.blogs.pk)
        print category

        category2 = Category(name = 'level2', parent = category)
        self.assertNumQueries(1, category2.save())

        self.assertEquals(category2.parent.pk, category.pk)
        self.assertEquals(category2.root.pk, self.blogs.pk)

        category3 = Category(name = 'level1.2', parent = self.blogs)
        self.assertNumQueries(1, category3.save())

        category.parent = self.pingpong
        self.assertNumQueries(3, category.save())


        category2 = Category.objects.get(pk = category2.pk)
        category3 = Category.objects.get(pk = category3.pk)
        self.assertEquals(category2.root.pk, self.pingpong.pk)
        self.assertEquals(category2.parent.pk, category.pk)
        self.assertEquals(category3.root.pk, self.blogs.pk)
        self.assertEquals(category3.parent.pk, self.blogs.pk)
Exemple #4
0
class CategoryModelTests(TestCase):
    def setUp(self):
        self.category = CategoryFactory()
        self.my_category = Category(name="my_category")

    def test_should_throw_error_if_category_already_exists(self):
        with self.assertRaises(IntegrityError) as context_message:
            self.my_category.save()
            my_category_1 = Category(name="my_category")
            my_category_1.save()

    def test_should_throw_error_if_name_exceeds_100_character(self):
        with self.assertRaises(DataError) as context_message:
            CategoryFactory(name='Full Metal Havok More Sexy N Intelligent Than Spock And All The Superheroes Combined With Frostnova nova')

    def test_should_throw_error_if_category_order_is_a_negative_value(self):
        with self.assertRaises(IntegrityError) as context_message:
            self.my_category.order = -1
            self.my_category.save()

    def test_absolute_url(self):
        absolute_url = self.category.get_absolute_url()
        self.assertRegexpMatches(absolute_url,'things-we-do')

    def test_str(self):
        self.assertEqual(self.category.__str__(),'Things we do')
 def create_or_update_categories(self, response):
     json_result = loads(response.body.decode('utf8'))
     selector = scrapy.Selector(text=json_result['html'], type="html")
     categories = Category.objects.filter(active=True)
     category_by_name = {c.name.lower(): c for c in categories}
     category_by_css = {}
     for option in selector.xpath("//ul[contains(@class, 'dropdown-menu')]/li/a"):
         category_name = option.extract_first_value_with_xpath('./text()')
         if category_name == '':
             continue
         category_css_name = option.extract_first_value_with_xpath('./@value')
         lower_name = category_name.lower()
         if lower_name in category_by_name:
             cat = category_by_name.pop(lower_name)
             if not cat.active:
                 cat.name = category_name.capitalize()
                 cat.active = True
                 cat.save()
                 self.debug_info('Reactive category {0}'.format(category_name))
         else:
             cat = Category(name=category_name.capitalize(), active=True)
             cat.save()
             self.debug_info('Create new category {0}'.format(category_name))
         product_list_url = option.extract_first_value_with_xpath('./@href')
         url = urlparse.urljoin(self.__class__.catalogue_base_url, product_list_url)
         yield scrapy.http.Request(url, callback=self.create_or_update_products)
         category_by_css[category_css_name] = cat
     self.category_by_css = category_by_css
 def create_or_update_categories(self, response):
     json_result = loads(response.body.decode('utf8'))
     selector = scrapy.Selector(text=json_result['html'], type="html")
     categories = Category.objects.filter(active=True)
     category_by_name = {c.name.lower(): c for c in categories}
     category_by_css = {}
     for option in selector.xpath(
             "//ul[contains(@class, 'dropdown-menu')]/li/a"):
         category_name = option.extract_first_value_with_xpath('./text()')
         if category_name == '':
             continue
         category_css_name = option.extract_first_value_with_xpath(
             './@value')
         lower_name = category_name.lower()
         if lower_name in category_by_name:
             cat = category_by_name.pop(lower_name)
             if not cat.active:
                 cat.name = category_name.capitalize()
                 cat.active = True
                 cat.save()
                 self.debug_info(
                     'Reactive category {0}'.format(category_name))
         else:
             cat = Category(name=category_name.capitalize(), active=True)
             cat.save()
             self.debug_info(
                 'Create new category {0}'.format(category_name))
         product_list_url = option.extract_first_value_with_xpath('./@href')
         url = urlparse.urljoin(self.__class__.catalogue_base_url,
                                product_list_url)
         yield scrapy.http.Request(url,
                                   callback=self.create_or_update_products)
         category_by_css[category_css_name] = cat
     self.category_by_css = category_by_css
Exemple #7
0
def import_csv(request):
    if request.method == "POST":
        csv_file = request.FILES.get('csv_file')
        if not csv_file.name.endswith('.csv'):
            error = "Please add 'CSV' File!"
            link = request.META.get('HTTP_REFERER')
            context = {'error': error, 'link': link}
            return render(request, 'back/error.html', context=context)
        file_data = csv_file.read().decode('utf-8')
        lines = file_data.split("\n")  # alt satıra \n ile geçer
        lines.pop(
            0
        )  # burada biz gelen csv'de ilk satırda kolon isimleri olduğundan listeden çıkardık
        lines.pop(len(lines) - 1)  # son eleman '' döndüğünden çıkardık
        for line in lines:
            fields = line.split(
                ',')  # yan yana kolonlar birbirinden ',' ile ayrılır
            try:
                if len(Category.objects.filter(name=fields[0])
                       ) == 0:  # eğer o isimde bir kategori yoksa
                    cat = Category(name=fields[0], count=0)
                    cat.save()
            except:
                print("exception!!!")
    return redirect('panel:category_list')
Exemple #8
0
    def post(self, request):
        try:
            body: str = request.body.decode('utf-8')
            req_body: Dict = loads(body)
            try:
                Category.objects.get(name=req_body['name'])
                err_resp = {
                    'success': False,
                    'message':
                    f'Category with {req_body["name"]} already exists.'
                }
                return JsonResponse(data=err_resp, status=409)
            except Category.DoesNotExist:
                category = Category()
                category.name = req_body['name']
                category.type = req_body['type'] if req_body['type'] in [
                    'DEVICE',
                    'GARMENTS',
                    'ACCESSORIES',
                ] else 'DEVICE'
                category.save()

                data = category_serializer(category)
                return JsonResponse(data=data, status=201)
        except Exception as e:
            err_resp = {'success': False, 'message': str(e)}
            return JsonResponse(data=err_resp, status=500)
Exemple #9
0
class TestItemViewSet(TestCase):
    """
        All test functions into the TestItemViewSet are for ItemViewSet
    """

    def setUp(self):
        """
            Before each the test function
        """
        self.client = APIClient()

        # Create a fake todo item
        self.user = User(name='test', user_name='te-st',
                         email='*****@*****.**', age=20)
        self.user.save()

        self.category = Category(category_name=1)
        self.category.save()

        self.item_data = {
            'title': 'Test',
            'user': self.user.id,
            'category': self.category.id
        }

        # Fake post request
        self.response = self.client.post(
            '/api/todo/',
            self.item_data,
            format='json'
        )

    # Post Request
    def test_post_method(self):
        self.assertEqual(self.response.status_code, status.HTTP_201_CREATED)

    # Get Request
    def test_get_method(self):
        todo_count = Item.objects.count()
        response = self.client.get(
            '/api/todo/',
            format='json'
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(todo_count, len(response.data))

    # Retrieve Request
    def test_retrieve_method(self):
        todo_item = Item.objects.get(title='Test')
        response = self.client.get(
            '/api/todo/',
            kwargs={'pk': todo_item.id},
            format='json'
        )

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertContains(response, todo_item)
Exemple #10
0
def add_category(request):
    if request.method == 'POST':
        name = request.POST['name']
        cat_type = request.POST['cat_type']
        icon = request.FILES['icon']
        category = Category(name = name, cat_type = cat_type, icon = icon)
        if category:
           category.save()
           return redirect('category')
    return render(request, 'category/add-category.html')
def create_categories():

	Category.objects.all().delete()

	for pk, fields in categorias.iteritems():
		c = Category(pk=pk)
		c.name = fields['name']
		c.slug = fields['slug']
		c.description = fields['description']
		c.published = fields['active']
		c.save()
Exemple #12
0
def create(request):
    # If this is a post request we insert the person
    if request.POST:
        cat = Category(
            name=request.POST['name'],
        )
        cat.save()

    categories = Category.objects.all()
    context = {'categories': categories}
    messages.add_message(request, messages.INFO, 'Category Create Succesfully')              
    return render(request, 'all_categories.html', context) 
Exemple #13
0
 def post(self, request, format=None):
     users = Users.objects.get(id=request.data['users_id'])
     request.data['users'] = users
     serializer = Category(id=request.data['id'],
                           name=request.data['name'],
                           parent=request.data['parent'],
                           is_featured=request.data['is_featured'],
                           is_active=request.data['is_active'],
                           description=request.data['description'],
                           users=request.data['users'])
     if serializer:
         serializer.save()
         return Response("Added", status=status.HTTP_201_CREATED)
     return Response(serializer, status=status.HTTP_400_BAD_REQUEST)
Exemple #14
0
def save_or_update(req):
    msg = ''
    if req.method == 'POST':
        if int(req.POST["id"]) > 0:
            category = Category(id=req.POST["id"], type=req.POST["type"])
            msg = "Updation Operation Successfully...!"
            category.save()
        else:
            category = Category(type=req.POST["type"])
            msg = "Add Operation Successfully...!"
            category.save()

    return render(req, 'category.html', {
        "cat": dummy_category(),
        "note": msg,
        "categories": get_active_category()
    })
Exemple #15
0
class TestModel(TestCase):
    def setUp(self):
        self.title = 'Test title'

        self.user = User(
            name='test', user_name='te-st', email='*****@*****.**', age=20)
        self.user.save()

        self.category = Category(category_name=1)
        self.category.save()

        self.item = Item(title=self.title, user=self.user,
                         category=self.category)

    def test_item_model(self):
        old_item = Item.objects.count()
        self.item.save()
        new_item = Item.objects.count()
        self.assertNotEqual(old_item, new_item)
Exemple #16
0
    def test_create_product(self):
        category = Category(name='Category 1')
        category.save()
        product = Product.objects.create(name='product 1',
                                         slug='product-1',
                                         description='description',
                                         images='',
                                         price=600,
                                         stock=True,
                                         is_available=True,
                                         category=category)

        self.assertEqual(product.name, 'product 1')
        self.assertEqual(product.slug, 'product-1')
        self.assertEqual(product.description, 'description')
        self.assertEqual(product.images, '')
        self.assertEqual(product.price, 600)
        self.assertEqual(product.stock, True)
        self.assertEqual(product.is_available, True)
        self.assertEqual(product.category, category)
Exemple #17
0
 def POST(self, category_id=None):
     if category_id:
         category = Category.get_by_id(int(category_id))
     else:
         category = Category()
         max_sort_category = Category.all().order('-sort').get()
         if max_sort_category:
             # max_sort_category = max_sort_category.pop()
             max_sort = max_sort_category.sort
             if not max_sort:
                 max_sort = 0
         else:
             max_sort = 0
         category.sort = max_sort + 1
     
     inp = web.input()
     category.name = inp.name
     category.alias = inp.get('alias')
     category.save()
     
     clear_cache()
     return web.seeother('/admin/categories')
 def create_or_update_categories(self, selector):
     categories = Category.objects.filter(active=True)
     category_by_name = {c.name.lower(): c for c in categories}
     category_by_css = {}
     for option in selector.xpath('//select[@name="category"]/option'):
         category_name = option.extract_first_value_with_xpath('./text()')
         if category_name == '':
             continue
         category_css_name = option.extract_first_value_with_xpath('./@value')
         lower_name = category_name.lower()
         if lower_name in category_by_name:
             cat = category_by_name.pop(lower_name)
             if not cat.active:
                 cat.name = category_name.capitalize()
                 cat.active = True
                 cat.save()
                 self.debug_info('Reactive category {0}'.format(category_name))
         else:
             cat = Category(name=category_name.capitalize(), active=True)
             cat.save()
             self.debug_info('Create new category {0}'.format(category_name))
         category_by_css[category_css_name] = cat
     self.category_by_css = category_by_css
                     icon="headset",
                     description="Bocinas, Headsets, ...")
category9 = Category(name="Impresoras",
                     icon="printer",
                     description="Matriz, Laser, ...")
category10 = Category(name="Tarjetas de video",
                      icon="gpu",
                      description="NVIDIA, AMD, ...")
category11 = Category(name="Mobiliario",
                      icon="home",
                      description="Escritorios, sillas, ...")
category12 = Category(name="Gaming",
                      icon="videogame-asset",
                      description="Todo relacionado a gaming, con RGB ...")

category1.save()
category2.save()
category3.save()
category4.save()
category5.save()
category6.save()
category7.save()
category8.save()
category9.save()
category10.save()
category11.save()
category12.save()

# Products
r = requests.get(
    "https://images-na.ssl-images-amazon.com/images/I/41OI4C2VSrL.jpg")
Exemple #20
0
 def test_should_throw_error_if_category_already_exists(self):
     with self.assertRaises(IntegrityError) as context_message:
         self.my_category.save()
         my_category_1 = Category(name="my_category")
         my_category_1.save()
Exemple #21
0
def add_category(category_entry):
    print('Category:', category_entry['name'])
    item = Category(**category_entry)
    item.save()
 def testNewCategory(self):
     """ Verify category creating is ok """
     category = Category(name = 'test')
     category.save()
     self.assertNotEquals(category.root, None)
     self.assertEquals(category.root.pk, category.pk)
Exemple #23
0
    def handle(self, *args, **kwargs):
        #start_time = time.time()

        with open('outoutfile.json') as json_file:
            data = json.load(json_file)
            #print(data)
            i = 0
            for product in data:
                print(i)
                #print(product)
                title = product['title']
                description = product['description']
                category = product['category']
                try:
                    categoryObj = Category.objects.get(title=category)
                except:
                    categoryObj = Category(title=category, catalog_rep='A')
                    categoryObj.save()
                #dbProduct = Product(name= title,content=(description or ''), category=categoryObj)
                dbProductList = Product.objects.filter(name=title,
                                                       category=categoryObj)
                dbProduct = dbProductList.first()
                if dbProduct == None:
                    dbProduct = Product(category=categoryObj,
                                        name=title,
                                        content=(description or ''),
                                        buy_cost=0)
                    print('creating new product ', dbProduct.name,
                          'description: ', dbProduct.content)
                else:
                    dbProduct.content = description or ''
                    print('updating product ', dbProduct.name, 'description: ',
                          dbProduct.content)

                #print(dbProduct.name)
                #print(dbProduct.content)
                #print(dbProduct.category)
                dbProduct.save()

                if 'image1' in product:
                    dbImage1 = ProductImage(product=dbProduct)
                    with open(product['image1'], 'rb') as f:
                        image_data = File(f)
                        dbImage1.image.save(product['image1'], image_data,
                                            True)
                    dbImage1.save()

                if 'image2' in product:
                    dbImage1 = ProductImage(product=dbProduct)
                    with open(product['image2'], 'rb') as f:
                        image_data = File(f)
                        dbImage1.image.save(product['image2'], image_data,
                                            True)
                    dbImage1.save()

                colors = []
                if 'צבע' in product:
                    colors = product['צבע']
                else:
                    colors = ['no color']

                sizes = []
                if 'גודל' in product:
                    sizes = product['גודל']
                else:
                    sizes = ['one size']
                import itertools
                productStuckList = list(itertools.product(colors, sizes))
                #print(productStuckList)

                from provider.models import Provider

                try:
                    defultProvider = Provider.objects.all()[0]
                except:
                    defultProvider = Provider(name='defult provider')
                    defultProvider.save()

                from packingType.models import PackingType
                try:
                    defultPackingType = PackingType.objects.all()[0]
                except:
                    defultPackingType = PackingType(name='defult packing')
                    defultPackingType.save()

                for stock in productStuckList:
                    from stock.models import Stock

                    from productSize.models import ProductSize
                    dbProductSize = None
                    try:
                        dbProductSize = ProductSize.objects.get(size=stock[1])
                    except:
                        dbProductSize = ProductSize(size=stock[1])
                        dbProductSize.save()

                    from productColor.models import ProductColor
                    dbProductColor = None
                    try:
                        dbProductColor = ProductColor.objects.get(
                            name=stock[0])
                    except:
                        dbProductColor = ProductColor(name=stock[0])
                        dbProductColor.save()

                    stock, created = Stock.objects.update_or_create(
                        provider=defultProvider,
                        productSize=dbProductSize,
                        productColor=dbProductColor,
                        product=dbProduct,
                        packingType=defultPackingType)
                    print(created, stock.product, stock.productSize,
                          stock.productColor)
                    stock.save()

                i += 1

        #end_time = time.time()
        #print('imported in ' + (end_time - start_time) + ' seconds' )

        pass
Exemple #24
0
    def fill_db(self):
        now = datetime.datetime.now(tz=pytz.utc)
        last_week = now - datetime.timedelta(days=7)
        last_month = now - datetime.timedelta(days=31)

        c1 = Category(pk=1, name='Электроника')
        c1.save()
        c2 = Category(pk=2, name='Бытовая техника', parent=c1)
        c2.save()
        c3 = Category(pk=3, name='Телевизоры', parent=c1)
        c3.save()
        c4 = Category(pk=4, name='Телефоны', parent=c1)
        c4.save()
        c5 = Category(pk=5, name='Смартфоны', parent=c4)
        c5.save()
        c6 = Category(pk=6, name='Холодильники', parent=c2)
        c6.save()
        c7 = Category(pk=7, name='Стиральные машины', parent=c2)
        c7.save()
        c8 = Category(pk=8, name='Посудомоечные машины', parent=c2)
        c8.save()
        categories = (
            c1,
            c2,
            c3,
            c4,
            c5,
            c6,
            c7,
            c8,
        )

        stocks = (
            Stock(pk=1,
                  article=100,
                  category=categories[2],
                  name='Телевизор LG',
                  price=10000,
                  number=10),
            Stock(pk=2,
                  article=101,
                  category=categories[2],
                  name='Телевизор Samsung',
                  price=11000,
                  number=9),
            Stock(pk=3,
                  article=102,
                  category=categories[2],
                  name='Телевизор Sony',
                  price=12000,
                  number=20),
            Stock(pk=4,
                  article=103,
                  category=categories[6],
                  name='Стиральная машина LG',
                  price=10500,
                  number=5),
            Stock(pk=5,
                  article=104,
                  category=categories[4],
                  name='Смартфон Samsung Galaxy Note 8',
                  price=13000,
                  number=18),
            Stock(pk=6,
                  article=105,
                  category=categories[5],
                  name='Холодильник LG',
                  price=10000,
                  number=12),
            Stock(pk=7,
                  article=106,
                  category=categories[5],
                  name='Холодильник Samsung',
                  price=15000,
                  number=0),
        )

        Stock.objects.bulk_create(stocks)

        suppliers = (
            Supplier(pk=1,
                     organization='LG',
                     address='680000, Хабаровск, ул. Большая, 1-1',
                     phone_number='111111',
                     email='*****@*****.**',
                     legal_details='ИНН: 9909111111',
                     contact_info=('Контактное лицо: ' +
                                   'Сергей Иванович Сидоров')),
            Supplier(pk=2,
                     organization='Samsung',
                     address='680000, Хабаровск, ул. Большая, 1-2',
                     phone_number='111112',
                     email='*****@*****.**',
                     legal_details='ИНН: 9909111112',
                     contact_info=('Контактное лицо: ' +
                                   'Сергей Иванович Семенов')),
            Supplier(pk=3,
                     organization='Sony',
                     address='680000, Хабаровск, ул. Большая, 1-3',
                     phone_number='111113',
                     email='*****@*****.**',
                     legal_details='ИНН: 9909111113',
                     contact_info=('Контактное лицо: ' +
                                   'Сергей Иванович Петров')),
        )
        Supplier.objects.bulk_create(suppliers)

        for i in range(7):
            sc = SupplierCategory(supplier=suppliers[0],
                                  category=categories[i])
            sc.save()
            sc = SupplierCategory(supplier=suppliers[1],
                                  category=categories[i])
            sc.save()
        for i in range(6):
            sc = SupplierCategory(supplier=suppliers[2],
                                  category=categories[i])
            sc.save()

        customers = (
            Customer(pk=1,
                     full_name='Иван Иванович Иванов',
                     phone_number='222222',
                     email=settings.CLIENT_EMAIL,
                     contact_info=('Контактное лицо: ' +
                                   'Иван Иванович Иванов')),
            Customer(pk=2,
                     full_name='Петр Петрович Петров',
                     phone_number='222223',
                     email=settings.CLIENT_EMAIL,
                     contact_info=('Контактное лицо: ' +
                                   'Петр Петрович Петров')),
            Customer(pk=3,
                     full_name='Светлана Семеновна Семенова',
                     phone_number='222224',
                     email=settings.CLIENT_EMAIL,
                     contact_info=('Контактное лицо: ' +
                                   'Светлана Семеновна Семенова')),
            Customer(pk=4,
                     full_name='Анна Николаевна Николаева',
                     phone_number='222225',
                     email=settings.CLIENT_EMAIL,
                     contact_info=('Контактное лицо: ' +
                                   'Анна Николаевна Николаева')),
        )
        Customer.objects.bulk_create(customers)

        cargo = (
            Cargo(pk=1, supplier=suppliers[0], date=last_week),
            Cargo(pk=2, supplier=suppliers[0], date=last_month),
            Cargo(pk=3, supplier=suppliers[1], date=last_week),
            Cargo(pk=4, supplier=suppliers[1], date=last_week),
            Cargo(pk=5, supplier=suppliers[0], date=last_week),
        )

        Cargo.objects.bulk_create(cargo)

        CargoStock.objects.create(cargo=cargo[0], stock=stocks[0], number=10)
        CargoStock.objects.create(cargo=cargo[1], stock=stocks[3], number=5)
        CargoStock.objects.create(cargo=cargo[1], stock=stocks[5], number=15)
        CargoStock.objects.create(cargo=cargo[2], stock=stocks[0], number=10)
        CargoStock.objects.create(cargo=cargo[2], stock=stocks[4], number=20)
        CargoStock.objects.create(cargo=cargo[3], stock=stocks[6], number=10)
        CargoStock.objects.create(cargo=cargo[4], stock=stocks[6], number=10)

        shipments = (
            Shipment(pk=1, customer=customers[0], date=now),
            Shipment(pk=2, customer=customers[0], date=now),
            Shipment(pk=3, customer=customers[0], date=now),
            Shipment(pk=4, customer=customers[1], date=now),
            Shipment(pk=5, customer=customers[2], date=now),
            Shipment(pk=6, customer=customers[0], date=now),
            Shipment(pk=7, customer=customers[1], date=now),
            Shipment(pk=8, customer=customers[2], date=now),
        )

        Shipment.objects.bulk_create(shipments)

        ShipmentStock.objects.create(shipment=shipments[0],
                                     stock=stocks[6],
                                     number=10)
        ShipmentStock.objects.create(shipment=shipments[1],
                                     stock=stocks[4],
                                     number=1)
        ShipmentStock.objects.create(shipment=shipments[2],
                                     stock=stocks[5],
                                     number=1)
        ShipmentStock.objects.create(shipment=shipments[3],
                                     stock=stocks[5],
                                     number=2)
        ShipmentStock.objects.create(shipment=shipments[4],
                                     stock=stocks[0],
                                     number=1)
        ShipmentStock.objects.create(shipment=shipments[0],
                                     stock=stocks[4],
                                     number=1)
        ShipmentStock.objects.create(shipment=shipments[6],
                                     stock=stocks[5],
                                     number=5)
        ShipmentStock.objects.create(shipment=shipments[4],
                                     stock=stocks[5],
                                     number=4)
        ShipmentStock.objects.create(shipment=shipments[5],
                                     stock=stocks[4],
                                     number=3)
        ShipmentStock.objects.create(shipment=shipments[7],
                                     stock=stocks[2],
                                     number=7)