diff options
author | luxagraf <sng@luxagraf.net> | 2019-11-05 11:14:09 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-11-05 11:14:09 -0500 |
commit | 725e3d2f798d228a386466823490b6f25647a4db (patch) | |
tree | 4a4bdfbe7c494a596631bcb7312708dbf2115263 /app/utils | |
parent | f65cea71db9d0ae489f6228d5d2c68dab0bd91ce (diff) |
added updates to posts model
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 |