Skip to content

Commit

Permalink
Merge pull request #7595 from readthedocs/agj/add-version-create-url
Browse files Browse the repository at this point in the history
Add separate version create view and create view URL
  • Loading branch information
ericholscher authored Apr 6, 2021
2 parents 924699c + 7b18370 commit ba22f16
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"urls": {
"build": "https://readthedocs.org/projects/project/builds/1/",
"project": "https://readthedocs.org/projects/project/",
"version": "https://readthedocs.org/dashboard/project/version/v1.0/"
"version": "https://readthedocs.org/dashboard/project/version/v1.0/edit/"
},
"project": "project",
"state": {
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/api/v3/tests/responses/projects-detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"urls": {
"build": "https://readthedocs.org/projects/project/builds/1/",
"project": "https://readthedocs.org/projects/project/",
"version": "https://readthedocs.org/dashboard/project/version/v1.0/"
"version": "https://readthedocs.org/dashboard/project/version/v1.0/edit/"
},
"project": "project",
"state": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"urls": {
"build": "https://readthedocs.org/projects/project/builds/2/",
"project": "https://readthedocs.org/projects/project/",
"version": "https://readthedocs.org/dashboard/project/version/v1.0/"
"version": "https://readthedocs.org/dashboard/project/version/v1.0/edit/"
},
"project": "project",
"state": {
Expand Down
16 changes: 15 additions & 1 deletion readthedocs/projects/urls/private.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Project URLs for authenticated users."""

from django.conf import settings
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from django.views.generic.base import RedirectView
Expand Down Expand Up @@ -39,6 +40,7 @@
ProjectUsersCreateList,
ProjectUsersDelete,
ProjectVersionDeleteHTML,
ProjectVersionCreate,
ProjectVersionDetail,
RegexAutomationRuleCreate,
RegexAutomationRuleUpdate,
Expand Down Expand Up @@ -81,7 +83,7 @@
name='project_version_delete_html',
),
url(
r'^(?P<project_slug>[-\w]+)/version/(?P<version_slug>[^/]+)/$',
r'^(?P<project_slug>[-\w]+)/version/(?P<version_slug>[^/]+)/edit/$',
ProjectVersionDetail.as_view(),
name='project_version_detail',
),
Expand Down Expand Up @@ -145,6 +147,18 @@
),
]

# TODO move this up to the list above when it's not a conditional URL.
# Currently, this is only used by the new theme, we don't allow for "create" in
# our current templates.
if settings.RTD_EXT_THEME_ENABLED:
urlpatterns.append(
url(
r'^(?P<project_slug>[-\w]+)/version/create/$',
ProjectVersionCreate.as_view(),
name='project_version_create',
),
)

domain_urls = [
url(
r'^(?P<project_slug>[-\w]+)/domains/$',
Expand Down
14 changes: 11 additions & 3 deletions readthedocs/projects/views/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ def get_success_url(self):
)


class ProjectVersionDetail(ProjectVersionMixin, UpdateView):

template_name = 'projects/project_version_detail.html'
class ProjectVersionEditMixin(ProjectVersionMixin):

def get_queryset(self):
return Version.internal.public(
Expand Down Expand Up @@ -221,6 +219,16 @@ def form_valid(self, form):
return HttpResponseRedirect(self.get_success_url())


class ProjectVersionCreate(ProjectVersionEditMixin, CreateView):

template_name = 'projects/project_version_detail.html'


class ProjectVersionDetail(ProjectVersionEditMixin, UpdateView):

template_name = 'projects/project_version_detail.html'


class ProjectVersionDeleteHTML(ProjectVersionMixin, GenericModelView):

http_method_names = ['post']
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/rtd_tests/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_version_delete_html(self):
self.assertRedirectToLogin(response)

def test_version_detail(self):
response = self.client.get('/dashboard/pip/version/0.8.1/')
response = self.client.get('/dashboard/pip/version/0.8.1/edit/')
self.assertRedirectToLogin(response)

def test_project_delete(self):
Expand Down

0 comments on commit ba22f16

Please sign in to comment.