Skip to content

Add initial project overview page #12021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions readthedocs/projects/urls/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from readthedocs.core.views import PageNotFoundView
from readthedocs.projects.backends.views import ImportWizardView
from readthedocs.projects.views import private
from readthedocs.projects.views.private import ProjectOverview # Add this import
from readthedocs.projects.views.private import (
AddonsConfigUpdate,
AutomationRuleDelete,
Expand Down Expand Up @@ -80,6 +81,11 @@
),
name="projects_manage",
),
re_path(
r"^(?P<project_slug>[-\w]+)/overview/$",
ProjectOverview.as_view(),
name="projects_overview",
),
re_path(
r"^(?P<project_slug>[-\w]+)/edit/$",
ProjectUpdate.as_view(),
Expand Down
36 changes: 33 additions & 3 deletions readthedocs/projects/views/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.messages.views import SuccessMessageMixin
from django.db.models import Count, Q
from django.db.models import Count, Q, Sum
from django.http import (
Http404,
HttpResponse,
Expand Down Expand Up @@ -34,6 +34,7 @@
from readthedocs.builds.forms import RegexAutomationRuleForm, VersionForm
from readthedocs.builds.models import (
AutomationRuleMatch,
Build,
RegexAutomationRule,
Version,
VersionAutomationRule,
Expand Down Expand Up @@ -617,8 +618,9 @@ def post(self, request, *args, **kwargs):
username=username,
)
if self._is_last_user():
# NOTE: don't include user input in the message, since it's a security risk.
return HttpResponseBadRequest(_("User is the last owner, can't be removed"))
return HttpResponseBadRequest(
_(f"{username} is the last owner, can't be removed")
)

project = self.get_project()
project.users.remove(user)
Expand Down Expand Up @@ -1360,3 +1362,31 @@ def get_queryset(self):

def get_success_url(self):
return reverse("projects_pull_requests", args=[self.object.slug])


class ProjectOverview(ProjectAdminMixin, PrivateViewMixin, TemplateView):
template_name = "projects/project_overview.html"

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
project = self.get_project()
limit_reached, concurrent, max_concurrent = Build.objects.concurrent(project)

context.update(
{
"project": project,
"concurrent_builds": {
"limit_reached": limit_reached,
"current": concurrent,
"max": max_concurrent,
},
"successful_builds": project.builds.filter(success=True).count(),
"monthly_build_time": project.builds.aggregate(
total_time=Sum("length")
)["total_time"]
or 0,
"active_versions_count": project.versions.filter(active=True).count(),
}
)

return context