Skip to content

Commit 3c4bb63

Browse files
committed
Add separate version create view and create view URL
This is not currently used outside the new theme, but enables the solution for #6238 -- latest `master` of the new theme already expects this code. For now, the create URL does throw and exception, because we are rendering template code inside the version form. I'm not going to address this as the create view is not linked and unused, and we probably shouldn't be rendering templates inside form instantiation anyways. The edit version URL does change with this, to append the `/edit/` postfix. This was done to match similar URL patterns, and to give a path for the create view URL that does not match the edit URL pattern.
1 parent a81d82e commit 3c4bb63

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

readthedocs/projects/urls/private.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
ProjectUsersCreateList,
4242
ProjectUsersDelete,
4343
ProjectVersionDeleteHTML,
44+
ProjectVersionCreate,
4445
ProjectVersionDetail,
4546
RegexAutomationRuleCreate,
4647
RegexAutomationRuleUpdate,
@@ -82,7 +83,12 @@
8283
name='project_version_delete_html',
8384
),
8485
url(
85-
r'^(?P<project_slug>[-\w]+)/version/(?P<version_slug>[^/]+)/$',
86+
r'^(?P<project_slug>[-\w]+)/version/create/$',
87+
ProjectVersionCreate.as_view(),
88+
name='project_version_create',
89+
),
90+
url(
91+
r'^(?P<project_slug>[-\w]+)/version/(?P<version_slug>[^/]+)/edit/$',
8692
ProjectVersionDetail.as_view(),
8793
name='project_version_detail',
8894
),

readthedocs/projects/views/private.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ def get_success_url(self):
192192
)
193193

194194

195-
class ProjectVersionDetail(ProjectVersionMixin, UpdateView):
196-
197-
template_name = 'projects/project_version_detail.html'
195+
class ProjectVersionEditMixin(ProjectVersionMixin):
198196

199197
def get_queryset(self):
200198
return Version.internal.public(
@@ -222,6 +220,16 @@ def form_valid(self, form):
222220
return HttpResponseRedirect(self.get_success_url())
223221

224222

223+
class ProjectVersionCreate(ProjectVersionEditMixin, CreateView):
224+
225+
template_name = 'projects/project_version_detail.html'
226+
227+
228+
class ProjectVersionDetail(ProjectVersionEditMixin, UpdateView):
229+
230+
template_name = 'projects/project_version_detail.html'
231+
232+
225233
class ProjectVersionDeleteHTML(ProjectVersionMixin, GenericModelView):
226234

227235
http_method_names = ['post']

0 commit comments

Comments
 (0)