Przeglądaj źródła

Thread hierarchical tag state appropriately

Getty Ritter 4 lat temu
rodzic
commit
6e0e1a407b
3 zmienionych plików z 15 dodań i 4 usunięć
  1. 6 4
      lc/app.py
  2. 1 0
      lc/model.py
  3. 8 0
      lc/view.py

+ 6 - 4
lc/app.py

@@ -19,7 +19,7 @@ class Index(Endpoint):
 
         pg = int(flask.request.args.get("page", 1))
         links, pages = m.Link.get_all(as_user=self.user, page=pg)
-        linklist = v.LinkList(links=links, pages=pages, tags=[])
+        linklist = v.LinkList(links=links, pages=pages, user="", tags=[])
 
         return render(
             "main",
@@ -89,7 +89,7 @@ class GetUser(Endpoint):
         pg = int(flask.request.args.get("page", 1))
         tags = u.get_tags()
         links, pages = u.get_links(as_user=self.user, page=pg)
-        linklist = v.LinkList(links=links, pages=pages, tags=tags)
+        linklist = v.LinkList(links=links, user=slug, pages=pages, tags=tags)
         return render(
             "main",
             v.Page(
@@ -190,7 +190,9 @@ class GetLink(Endpoint):
             "main",
             v.Page(
                 title=f"link {l.name}",
-                content=render("linklist", v.LinkList([l.to_view(self.user)], [])),
+                content=render(
+                    "linklist", v.LinkList([l.to_view(self.user)], [], user=user)
+                ),
                 user=self.user,
             ),
         )
@@ -219,7 +221,7 @@ class GetTaggedLinks(Endpoint):
         t = u.get_tag(tag)
         links, pages = t.get_links(as_user=self.user, page=pg)
         tags = u.get_related_tags(t)
-        linklist = v.LinkList(links=links, pages=pages, tags=tags)
+        linklist = v.LinkList(links=links, pages=pages, tags=tags, user=user)
         return render(
             "main",
             v.Page(

+ 1 - 0
lc/model.py

@@ -263,6 +263,7 @@ class Link(Model):
             created=self.created,
             is_mine=self.user.id == as_user.id if as_user else False,
             link_url=self.link_url(),
+            user=self.user.name,
         )
 
     def get_tags_view(self) -> List[v.Tag]:

+ 8 - 0
lc/view.py

@@ -132,14 +132,22 @@ class Link(View):
     created: datetime
     is_mine: bool
     link_url: str
+    user: str
+
+    def hier_tags(self) -> str:
+        return HierTagList(user=self.user, tags=self.tags).render()
 
 
 @dataclass
 class LinkList(View):
     links: List[Any]
     tags: List[Tag]
+    user: str
     pages: Optional[Pagination] = None
 
+    def hier_tags(self) -> str:
+        return HierTagList(user=self.user, tags=self.tags).render()
+
 
 @dataclass
 class SingleLink(View):