diff options
Diffstat (limited to 'app/utils/util.py')
-rw-r--r-- | app/utils/util.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/utils/util.py b/app/utils/util.py index b765e78..93ae5b1 100644 --- a/app/utils/util.py +++ b/app/utils/util.py @@ -50,6 +50,14 @@ def extract_main_image(markdown): return None +def parse_products(s): + soup = BeautifulSoup(s.group(), "lxml") + for div in soup.find_all('div'): + p = apps.get_model('products', 'Product').objects.get(pk=int(div['id'].split("product-")[1])) + print(p.get_full_name()) + return render_to_string("products/snippet.html", {'object': p}) + + def parse_image(s): soup = BeautifulSoup(s.group(), "lxml") for img in soup.find_all('img'): @@ -115,6 +123,9 @@ def render_images(s): s = re.sub('<img(.*)/>', parse_image, s) return s +def render_products(s): + s = re.sub('<div(.*)</div>', parse_products, s) + return s def parse_video(s): soup = BeautifulSoup(s, "lxml") |