mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-05-02 02:14:43 +00:00
Extract utils for use in other modules
This commit is contained in:
parent
11d511f9cc
commit
3177eb8e19
2 changed files with 15 additions and 14 deletions
|
|
@ -1,19 +1,7 @@
|
|||
from bs4 import BeautifulSoup
|
||||
from django.template import Context, Template, TemplateSyntaxError
|
||||
from django.template import TemplateSyntaxError
|
||||
from nose.tools import eq_, assert_not_in, raises, assert_not_equal
|
||||
from . import imagespecs # noqa
|
||||
from .utils import get_image_file
|
||||
|
||||
|
||||
def render_tag(ttag):
|
||||
img = get_image_file()
|
||||
template = Template('{%% load imagekit %%}%s' % ttag)
|
||||
context = Context({'img': img})
|
||||
return template.render(context)
|
||||
|
||||
|
||||
def get_html_attrs(ttag):
|
||||
return BeautifulSoup(render_tag(ttag)).img.attrs
|
||||
from .utils import render_tag, get_html_attrs
|
||||
|
||||
|
||||
def test_img_tag():
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from bs4 import BeautifulSoup
|
||||
import os
|
||||
from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
from django.template import Context, Template
|
||||
from imagekit.lib import Image, StringIO
|
||||
import pickle
|
||||
from .models import Photo
|
||||
|
|
@ -42,3 +44,14 @@ def pickleback(obj):
|
|||
pickle.dump(obj, pickled)
|
||||
pickled.seek(0)
|
||||
return pickle.load(pickled)
|
||||
|
||||
|
||||
def render_tag(ttag):
|
||||
img = get_image_file()
|
||||
template = Template('{%% load imagekit %%}%s' % ttag)
|
||||
context = Context({'img': img})
|
||||
return template.render(context)
|
||||
|
||||
|
||||
def get_html_attrs(ttag):
|
||||
return BeautifulSoup(render_tag(ttag)).img.attrs
|
||||
|
|
|
|||
Loading…
Reference in a new issue