mirror of
https://github.com/boostorg/website-v2.git
synced 2026-02-27 17:42:08 +00:00
🔧 I can't stop refactoring
This commit is contained in:
@@ -60,6 +60,14 @@ class LibraryDetail(CategoryMixin, DetailView):
|
||||
model = Library
|
||||
template_name = "libraries/detail.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Set the form action to the main libraries page"""
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["closed_prs_count"] = self.get_closed_prs_count(self.object)
|
||||
context["open_issues_count"] = self.get_open_issues_count(self.object)
|
||||
context["version"] = Version.objects.most_recent()
|
||||
return context
|
||||
|
||||
def get_object(self):
|
||||
slug = self.kwargs.get("slug")
|
||||
version = Version.objects.most_recent()
|
||||
@@ -75,14 +83,6 @@ class LibraryDetail(CategoryMixin, DetailView):
|
||||
raise Http404("No library found matching the query")
|
||||
return obj
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
context = self.get_context_data(object=self.object)
|
||||
context["closed_prs_count"] = self.get_closed_prs_count(self.object)
|
||||
context["open_issues_count"] = self.get_open_issues_count(self.object)
|
||||
context["version"] = Version.objects.most_recent()
|
||||
return self.render_to_response(context)
|
||||
|
||||
def get_closed_prs_count(self, obj):
|
||||
return PullRequest.objects.filter(library=obj, is_open=True).count()
|
||||
|
||||
@@ -178,6 +178,16 @@ class LibraryDetailByVersion(CategoryMixin, DetailView):
|
||||
model = Library
|
||||
template_name = "libraries/detail.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
object = self.get_object()
|
||||
context["closed_prs_count"] = self.get_closed_prs_count(object)
|
||||
context["open_issues_count"] = self.get_open_issues_count(object)
|
||||
context["version_slug"] = self.kwargs.get("version_slug")
|
||||
context["version"] = self.get_version(self.kwargs.get("version_slug"))
|
||||
context["version_name"] = context["version"].name
|
||||
return context
|
||||
|
||||
def get_object(self):
|
||||
version_slug = self.kwargs.get("version_slug")
|
||||
slug = self.kwargs.get("slug")
|
||||
@@ -192,16 +202,6 @@ class LibraryDetailByVersion(CategoryMixin, DetailView):
|
||||
raise Http404("No library found matching the query")
|
||||
return obj
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
context = self.get_context_data(object=self.object)
|
||||
context["closed_prs_count"] = self.get_closed_prs_count(self.object)
|
||||
context["open_issues_count"] = self.get_open_issues_count(self.object)
|
||||
context["version_slug"] = self.kwargs.get("version_slug")
|
||||
context["version"] = self.get_version(self.kwargs.get("version_slug"))
|
||||
context["version_name"] = context["version"].name
|
||||
return self.render_to_response(context)
|
||||
|
||||
def get_closed_prs_count(self, obj):
|
||||
return PullRequest.objects.filter(library=obj, is_open=True).count()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user