|
@@ -71,7 +71,9 @@ class User(Model):
|
|
def base_url(self) -> str:
|
|
def base_url(self) -> str:
|
|
return f"/u/{self.name}"
|
|
return f"/u/{self.name}"
|
|
|
|
|
|
- def get_links(self, as_user: r.User, page: int) -> Tuple[List[v.Link], v.Pagination]:
|
|
|
|
|
|
+ def get_links(
|
|
|
|
+ self, as_user: r.User, page: int
|
|
|
|
+ ) -> Tuple[List[v.Link], v.Pagination]:
|
|
links = (
|
|
links = (
|
|
Link.select()
|
|
Link.select()
|
|
.where((Link.user == self) & ((self == as_user) | (Link.private == False)))
|
|
.where((Link.user == self) & ((self == as_user) | (Link.private == False)))
|
|
@@ -128,7 +130,6 @@ class Link(Model):
|
|
def by_id(id: int) -> Optional["Link"]:
|
|
def by_id(id: int) -> Optional["Link"]:
|
|
return Link.get_or_none(id=id)
|
|
return Link.get_or_none(id=id)
|
|
|
|
|
|
-
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def from_request(user: User, link: r.Link) -> "Link":
|
|
def from_request(user: User, link: r.Link) -> "Link":
|
|
l = Link.create(
|
|
l = Link.create(
|
|
@@ -146,7 +147,6 @@ class Link(Model):
|
|
)
|
|
)
|
|
return l
|
|
return l
|
|
|
|
|
|
-
|
|
|
|
def update_from_request(self, user: User, link: r.Link):
|
|
def update_from_request(self, user: User, link: r.Link):
|
|
|
|
|
|
req_tags = set(link.tags)
|
|
req_tags = set(link.tags)
|
|
@@ -168,7 +168,6 @@ class Link(Model):
|
|
self.private = link.private
|
|
self.private = link.private
|
|
self.save()
|
|
self.save()
|
|
|
|
|
|
-
|
|
|
|
def to_view(self, as_user: User) -> v.Link:
|
|
def to_view(self, as_user: User) -> v.Link:
|
|
return v.Link(
|
|
return v.Link(
|
|
id=self.id,
|
|
id=self.id,
|
|
@@ -176,7 +175,7 @@ class Link(Model):
|
|
name=self.name,
|
|
name=self.name,
|
|
description=self.description,
|
|
description=self.description,
|
|
private=self.private,
|
|
private=self.private,
|
|
- tags=[t.tag.to_view() for t in self.tags], # type: ignore
|
|
|
|
|
|
+ tags=[t.tag.to_view() for t in self.tags], # type: ignore
|
|
created=self.created,
|
|
created=self.created,
|
|
is_mine=self.user.id == as_user.id,
|
|
is_mine=self.user.id == as_user.id,
|
|
link_url=self.link_url(),
|
|
link_url=self.link_url(),
|