diff options
Diffstat (limited to 'app/utils')
-rw-r--r-- | app/utils/util.py | 11 | ||||
-rw-r--r-- | app/utils/widgets.py | 2 |
2 files changed, 12 insertions, 1 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") diff --git a/app/utils/widgets.py b/app/utils/widgets.py index f4a7a4a..9f76608 100644 --- a/app/utils/widgets.py +++ b/app/utils/widgets.py @@ -66,7 +66,7 @@ class TagListFilter(admin.SimpleListFilter): """ tl = [] self.model_to_use = model_admin.model - for t in self.model_to_use.tags.all().order_by('name'): + for t in self.model_to_use.oldtags.all().order_by('name'): tl += (t.name, t.name), return tl |