-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
setting stable version manually #3723
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,6 +328,22 @@ def save(self): | |
self.project.default_version = default_version | ||
self.project.save() | ||
|
||
stable_version_identifier = self.cleaned_data.get('stable-version', None) | ||
if stable_version_identifier: | ||
old_stable_version = self.project.get_stable_version() | ||
if old_stable_version: | ||
if old_stable_version.identifier != stable_version_identifier: | ||
old_stable_version.identifier = stable_version_identifier | ||
old_stable_version.save() | ||
trigger_build(project=self.project, version=old_stable_version) | ||
else: | ||
new_stable = self.project.versions.filter(identifier=stable_version_identifier) | ||
stable_version = self.project.versions.create_stable( | ||
type=new_stable.type, | ||
identifier=new_stable.identifier) | ||
trigger_build(project=self.project, version=stable_version) | ||
|
||
|
||
def save_version(self, version): | ||
"""Save version if there has been a change, trigger a rebuild.""" | ||
new_value = self.cleaned_data.get( | ||
|
@@ -347,7 +363,6 @@ def save_version(self, version): | |
if version.active and not version.built and not version.uploaded: | ||
trigger_build(project=self.project, version=version) | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undo this ! |
||
def build_versions_form(project): | ||
"""Versions form with a list of versions and version privacy levels.""" | ||
attrs = { | ||
|
@@ -356,6 +371,11 @@ def build_versions_form(project): | |
versions_qs = project.versions.all() # Admin page, so show all versions | ||
active = versions_qs.filter(active=True) | ||
if active.exists(): | ||
attrs['stable-version'] = forms.ChoiceField( | ||
label=_('Stable Version'), | ||
choices=project.get_stable_version_choice(), | ||
initial=project.get_default_version(), | ||
) | ||
choices = [(version.slug, version.verbose_name) for version in active] | ||
attrs['default-version'] = forms.ChoiceField( | ||
label=_('Default Version'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
RelatedProjectQuerySet) | ||
from readthedocs.projects.templatetags.projects_tags import sort_version_aware | ||
from readthedocs.projects.version_handling import ( | ||
determine_stable_version, version_windows) | ||
determine_stable_version, version_windows, sort_versions) | ||
from readthedocs.restapi.client import api | ||
from readthedocs.vcs_support.backends import backend_cls | ||
from readthedocs.vcs_support.utils import Lock, NonBlockingLock | ||
|
@@ -724,11 +724,20 @@ def supported_versions(self): | |
def get_stable_version(self): | ||
return self.versions.filter(slug=STABLE).first() | ||
|
||
def get_stable_version_choice(self): | ||
version_list = self.versions.all() | ||
stable_version_choice = sort_versions(version_list) | ||
stable_version_choice = [(version_obj.identifier, version_obj.verbose_name) | ||
for version_obj, comparable in stable_version_choice | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent this by only 4 spaces ! |
||
if (not comparable.is_prerelease and version_obj.active)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto ! |
||
return stable_version_choice | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this blank line ! |
||
def update_stable_version(self): | ||
""" | ||
Returns the version that was promoted to be the new stable version. | ||
|
||
Return ``None`` if no update was mode or if there is no version on the | ||
Return ``None`` if no update was made or if there is no version on the | ||
project that can be considered stable. | ||
""" | ||
versions = self.versions.all() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this blank line !