Skip to content

Commit

Permalink
Merge d72aa9f into 5e9354d
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Jan 13, 2019
2 parents 5e9354d + d72aa9f commit dcc9080
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions misago/themes/admin/importer.py
Expand Up @@ -3,7 +3,7 @@
from tempfile import TemporaryDirectory
from zipfile import BadZipFile, ZipFile

from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.files.uploadedfile import UploadedFile
from django.utils.translation import gettext as _, gettext_lazy

from ..models import Theme
Expand Down Expand Up @@ -196,16 +196,22 @@ def create_css_from_manifest(tmp_dir, theme, manifest):
theme.css.create(**item, order=theme.css.count())
else:
with open(item["path"], "rb") as fp:
file_obj = SimpleUploadedFile(
item["name"], fp.read(), content_type="text/css"
file_obj = UploadedFile(
fp,
name=item["name"],
content_type="text/css",
size=os.path.getsize(item["path"]),
)
create_css(theme, file_obj)


def create_media_from_manifest(tmp_dir, theme, manifest):
for item in manifest:
with open(item["path"], "rb") as fp:
file_obj = SimpleUploadedFile(
item["name"], fp.read(), content_type=item["type"]
file_obj = UploadedFile(
fp,
name=item["name"],
content_type=item["type"],
size=os.path.getsize(item["path"]),
)
create_media(theme, file_obj)

0 comments on commit dcc9080

Please sign in to comment.