Skip to content

Commit

Permalink
add type hints to RedirectObjectType
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubMastalerz committed May 9, 2024
1 parent bc1a92b commit e2f0a41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Unreleased

### Changed
- Handling of `new_url` on `RedirectObjectType` to always return absolute URLs ([#380](https://github.com/torchbox/wagtail-grapple/pull/391)) @JakubMastalerz
- Handling of `new_url` on `RedirectObjectType` to always return absolute URLs ([#391](https://github.com/torchbox/wagtail-grapple/pull/391)) @JakubMastalerz

## [0.25.1] - 2024-04-21

Expand Down
6 changes: 3 additions & 3 deletions grapple/types/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class RedirectObjectType(graphene.ObjectType):
class Meta:
name = "Redirect"

def resolve_old_url(self, info, **kwargs) -> str:
def resolve_old_url(self: Redirect, info, **kwargs) -> str:
"""
Resolve the value of `old_url` using the `root_url` of the associated
site and `old_path`.
"""

return self.site.root_url + self.old_path

def resolve_new_url(self, info, **kwargs) -> Optional[str]:
def resolve_new_url(self: Redirect, info, **kwargs) -> Optional[str]:
"""
Resolve the value of `new_url`. If `redirect_page` is specified then
`link` is used. Otherwise, ensure that the redirect link is absolute.
Expand All @@ -58,7 +58,7 @@ def resolve_new_url(self, info, **kwargs) -> Optional[str]:
return None

# Return the page that's being redirected to, if at all.
def resolve_page(self, info, **kwargs) -> Optional[Page]:
def resolve_page(self: Redirect, info, **kwargs) -> Optional[Page]:
if self.redirect_page is not None:
return self.redirect_page.specific

Expand Down

0 comments on commit e2f0a41

Please sign in to comment.