Skip to content

Commit

Permalink
chore: address code reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee committed Sep 17, 2024
1 parent 3031228 commit 075ef04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
5 changes: 2 additions & 3 deletions downloads/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,8 @@ class ReleaseFeedTests(BaseDownloadTests):
Content is ensured via setUp in BaseDownloadTests.
"""

def setUp(self) -> None:
super().setUp()
self.url = reverse("downloads:feed")
url = reverse("downloads:feed")


def test_endpoint_reachable(self) -> None:
response = self.client.get(self.url)
Expand Down
16 changes: 0 additions & 16 deletions downloads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,6 @@ def items(self) -> list[dict[str, Any]]:
"""Return the latest Python releases."""
return Release.objects.filter(is_published=True).order_by("-release_date")[:10]

@staticmethod
def _fetch_releases(url: str) -> list[dict[str, Any]]:
"""Grabs the latest Python releases from API."""
response = requests.get(url, timeout=10)
response.raise_for_status()
data = response.json()

sorted_releases = sorted(data, key=lambda x: x["release_date"], reverse=True)
return sorted_releases[:10]

def item_title(self, item: Release) -> str:
"""Return the release name as the item title."""
return item.name
Expand All @@ -218,9 +208,3 @@ def item_pubdate(self, item: Release) -> datetime | None:
def item_guid(self, item: Release) -> str:
"""Return a unique ID for the item based on DB record."""
return str(item.pk)

def create_url(self, path: str) -> str:
"""Create a full URL using the current site domain."""
current_site = get_current_site(self.request)
scheme = "https" if self.request.is_secure() else "http"
return f"{scheme}://{current_site.domain}{path}"

0 comments on commit 075ef04

Please sign in to comment.