Skip to content

Commit

Permalink
Merge pull request #5523 from stsewd/fix-extra-origin-urls
Browse files Browse the repository at this point in the history
Fix extra origin in urls
  • Loading branch information
stsewd authored Mar 27, 2019
2 parents 6341bb1 + 1238197 commit 5f78337
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 7 additions & 5 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,14 @@ def __init__(self, *args, **kwargs):
self.helper.add_input(Submit('save', _('Save')))

default_choice = (None, '-' * 9)
all_versions = self.instance.versions.values_list(
'identifier',
'verbose_name',
)
# commit_name is used as the id because it handles
# the special cases of LATEST and STABLE.
all_versions_choices = [
(v.commit_name, v.verbose_name)
for v in self.instance.versions.all()
]
self.fields['default_branch'].widget = forms.Select(
choices=[default_choice] + list(all_versions),
choices=[default_choice] + all_versions_choices,
)

active_versions = self.get_all_active_versions()
Expand Down
8 changes: 7 additions & 1 deletion readthedocs/rtd_tests/tests/test_project_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
)
from readthedocs.projects.exceptions import ProjectSpamError
from readthedocs.projects.forms import (
EmailHookForm,
EnvironmentVariableForm,
ProjectAdvancedForm,
ProjectBasicsForm,
ProjectExtraForm,
TranslationForm,
UpdateProjectForm,
WebHookForm,
EmailHookForm
)
from readthedocs.projects.models import EnvironmentVariable, Project

Expand Down Expand Up @@ -201,6 +201,7 @@ def setUp(self):
active=True,
privacy_level=PUBLIC,
identifier='public-1',
verbose_name='public-1',
)
get(
Version,
Expand All @@ -209,6 +210,7 @@ def setUp(self):
active=True,
privacy_level=PUBLIC,
identifier='public-2',
verbose_name='public-2',
)
get(
Version,
Expand All @@ -217,6 +219,7 @@ def setUp(self):
active=False,
privacy_level=PROTECTED,
identifier='public-3',
verbose_name='public-3',
)
get(
Version,
Expand All @@ -225,6 +228,7 @@ def setUp(self):
active=False,
privacy_level=PUBLIC,
identifier='public/4',
verbose_name='public/4',
)
get(
Version,
Expand All @@ -233,6 +237,7 @@ def setUp(self):
active=True,
privacy_level=PRIVATE,
identifier='private',
verbose_name='private',
)
get(
Version,
Expand All @@ -241,6 +246,7 @@ def setUp(self):
active=True,
privacy_level=PROTECTED,
identifier='protected',
verbose_name='protected',
)

def test_list_only_active_versions_on_default_version(self):
Expand Down

0 comments on commit 5f78337

Please sign in to comment.