-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
on post detail page as menu for search
- Loading branch information
Showing
8 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django.urls import reverse | ||
|
||
|
||
class CategoryCrumbMixin: | ||
def get_post_categs_path(self) -> list: | ||
""" | ||
list of dict's based on a given p.category: | ||
{key:p.category slug, value: p.category name} | ||
incl ancestors for UI: categs links | ||
""" | ||
post = self.get_object() | ||
cats_names = post.categ.get_name_slug_chain() | ||
slugs_keys = cats_names["path_slug"].split("/") | ||
names_vals = cats_names["path_name"].split("/") | ||
if len(slugs_keys) == len(names_vals): | ||
res = dict(zip(slugs_keys, names_vals, strict=True)) | ||
else: | ||
return [] | ||
chain_crumbs = [] | ||
for slug, name in res.items(): | ||
chain_crumbs.append( | ||
{ | ||
"path": reverse("posts:cat_search", kwargs={"slug": slug}), | ||
"name": name, | ||
} | ||
) | ||
return chain_crumbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% load static %} | ||
<nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E");"aria-label="breadcrumb"> | ||
<ol class="breadcrumb" id="post_categ"> | ||
{% for item in categ_dict %} | ||
<li class="breadcrumb-item"> | ||
<a href="{{item.path}}" class="post_categ__link"> | ||
{{item.name}} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ol> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters