Skip to content

Commit

Permalink
#872 Rm images copying logic
Browse files Browse the repository at this point in the history
  • Loading branch information
duker33 committed Jun 10, 2019
1 parent 029838c commit bad1da3
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 11 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed media/modelpage/21/deer.jpg
Binary file not shown.
Binary file removed media/modelpage/21/gold.jpg
Binary file not shown.
Binary file removed media/modelpage/22/deer.jpg
Binary file not shown.
Binary file removed media/modelpage/22/gold.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion shopelectro/fixtures/dump.json

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions shopelectro/management/commands/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
- now you have json file, that'll be used by our TDD tests
"""
import os
import shutil

from django.conf import settings
from django.core.files.images import ImageFile
from django.core.management import call_command
from django.core.management.base import BaseCommand

from images.models import Image, model_directory_path
from images.models import Image
from pages.models import Page, FlatPage, PageTemplate
from pages.utils import save_custom_pages, init_redirects_app
from shopelectro import models as se_models, tests as se_tests
Expand Down Expand Up @@ -130,17 +129,11 @@ def create_image(file_path, slug):
# save files to media folder
with open(file_path, mode='rb') as file_src:
# product "/catalog/products/2/" contains image
image = Image.objects.create(
Image.objects.create(
model=page,
slug=slug,
image=ImageFile(file_src)
)
file_name = os.path.basename(file_src.name)
file_dst_path = os.path.join(
settings.MEDIA_ROOT,
model_directory_path(image, file_name)
)
shutil.copyfile(file_src.name, file_dst_path)

create_image(file_path=self.FIRST_IMAGE, slug='deer')
create_image(file_path=self.SECOND_IMAGE, slug='gold')
Expand All @@ -164,7 +157,6 @@ def create_product(parent: se_models.Category, tags_, price_factor):

if product.id in self.PRODUCTS_WITH_IMAGE:
create_images(product.page)
create_images(product.page)

def fill_with_products(to_fill, tags_, count):
for category in to_fill:
Expand Down

0 comments on commit bad1da3

Please sign in to comment.