Skip to content

Commit 09a09a2

Browse files
committed
External version name added everywhere
1 parent 3d62248 commit 09a09a2

10 files changed

+45
-46
lines changed

readthedocs/builds/constants.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@
3131
('dash', _('Dash')),
3232
)
3333

34+
# Manager name for Internal Versions or Builds.
35+
# ie: Versions and Builds Excluding pull request/merge request Versions and Builds.
36+
INTERNAL = 'internal'
37+
# Manager name for External Versions or Builds.
38+
# ie: Only pull request/merge request Versions and Builds.
39+
EXTERNAL = 'external'
40+
3441
BRANCH = 'branch'
3542
TAG = 'tag'
36-
PULL_REQUEST = 'pull_request'
3743
UNKNOWN = 'unknown'
3844

3945
VERSION_TYPES = (
4046
(BRANCH, _('Branch')),
4147
(TAG, _('Tag')),
42-
(PULL_REQUEST, _('Pull Request')),
48+
(EXTERNAL, _('External')),
4349
(UNKNOWN, _('Unknown')),
4450
)
4551

@@ -55,10 +61,3 @@
5561
LATEST,
5662
STABLE,
5763
)
58-
59-
# Manager name for Internal Versions or Builds.
60-
# ie: Versions and Builds Excluding PULL_REQUEST Type.
61-
INTERNAL = 'internal'
62-
# Manager name for External Versions or Builds.
63-
# ie: Only PULL_REQUEST Type Versions and Builds.
64-
EXTERNAL = 'external'

readthedocs/builds/managers.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
STABLE,
2020
STABLE_VERBOSE_NAME,
2121
TAG,
22-
PULL_REQUEST,
22+
EXTERNAL,
2323
)
2424
from .querysets import VersionQuerySet
2525

@@ -91,24 +91,24 @@ class InternalVersionManagerBase(VersionManagerBase):
9191
"""
9292
Version manager that only includes internal version.
9393
94-
It will exclude PULL_REQUEST type from the queries
94+
It will exclude pull request/merge request versions from the queries
9595
and only include BRANCH, TAG, UNKONWN type Versions.
9696
"""
9797

9898
def get_queryset(self):
99-
return super().get_queryset().exclude(type=PULL_REQUEST)
99+
return super().get_queryset().exclude(type=EXTERNAL)
100100

101101

102102
class ExternalVersionManagerBase(VersionManagerBase):
103103

104104
"""
105105
Version manager that only includes external version.
106106
107-
It will only include PULL_REQUEST type Versions in the queries.
107+
It will only include pull request/merge request Versions in the queries.
108108
"""
109109

110110
def get_queryset(self):
111-
return super().get_queryset().filter(type=PULL_REQUEST)
111+
return super().get_queryset().filter(type=EXTERNAL)
112112

113113

114114
class VersionManager(SettingsOverrideObject):

readthedocs/builds/migrations/0008_added_pull_request_version_type.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Generated by Django 1.11.20 on 2019-06-06 16:51
2+
# Generated by Django 1.11.21 on 2019-06-17 19:26
33
from __future__ import unicode_literals
44

55
from django.db import migrations, models
@@ -15,11 +15,11 @@ class Migration(migrations.Migration):
1515
migrations.AlterField(
1616
model_name='version',
1717
name='type',
18-
field=models.CharField(choices=[('branch', 'Branch'), ('tag', 'Tag'), ('pull_request', 'Pull Request'), ('unknown', 'Unknown')], default='unknown', max_length=20, verbose_name='Type'),
18+
field=models.CharField(choices=[('branch', 'Branch'), ('tag', 'Tag'), ('external', 'External'), ('unknown', 'Unknown')], default='unknown', max_length=20, verbose_name='Type'),
1919
),
2020
migrations.AlterField(
2121
model_name='versionautomationrule',
2222
name='version_type',
23-
field=models.CharField(choices=[('branch', 'Branch'), ('tag', 'Tag'), ('pull_request', 'Pull Request'), ('unknown', 'Unknown')], max_length=32, verbose_name='Version type'),
23+
field=models.CharField(choices=[('branch', 'Branch'), ('tag', 'Tag'), ('external', 'External'), ('unknown', 'Unknown')], max_length=32, verbose_name='Version type'),
2424
),
2525
]

readthedocs/builds/models.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
INTERNAL,
4242
LATEST,
4343
NON_REPOSITORY_VERSIONS,
44-
PULL_REQUEST,
44+
EXTERNAL,
4545
STABLE,
4646
TAG,
4747
VERSION_TYPES,
@@ -119,7 +119,7 @@ class Version(models.Model):
119119
objects = VersionManager.from_queryset(VersionQuerySet)()
120120
# Only include BRANCH, TAG, UNKONWN type Versions.
121121
internal = InternalVersionManager.from_queryset(VersionQuerySet)()
122-
# Only include PULL_REQUEST type Versions.
122+
# Only include EXTERNAL type Versions.
123123
external = ExternalVersionManager.from_queryset(VersionQuerySet)()
124124

125125
class Meta:
@@ -155,7 +155,7 @@ def vcs_url(self):
155155
Generate VCS (github, gitlab, bitbucket) URL for this version.
156156
157157
Branch/Tag Example: https://github.com/rtfd/readthedocs.org/tree/3.4.2/.
158-
Pull Request Example: https://github.com/rtfd/readthedocs.org/pull/9999/.
158+
Pull/merge Request Example: https://github.com/rtfd/readthedocs.org/pull/9999/.
159159
"""
160160
url = ''
161161
if self.slug == STABLE:
@@ -165,7 +165,7 @@ def vcs_url(self):
165165
else:
166166
slug_url = self.slug
167167

168-
if self.type == PULL_REQUEST:
168+
if self.type == EXTERNAL:
169169
if 'github' in self.project.repo:
170170
url = f'/pull/{slug_url}/'
171171

@@ -245,14 +245,14 @@ def commit_name(self):
245245
# the actual tag name.
246246
return self.verbose_name
247247

248-
if self.type == PULL_REQUEST:
249-
# If this version is a Pull Request, the identifier will
248+
if self.type == EXTERNAL:
249+
# If this version is a EXTERNAL version, the identifier will
250250
# contain the actual commit hash. which we can use to
251251
# generate url for a given file name
252252
return self.identifier
253253

254254
# If we came that far it's not a special version
255-
# nor a branch, tag or Pull Request.
255+
# nor a branch, tag or EXTERNAL version.
256256
# Therefore just return the identifier to make a safe guess.
257257
log.debug(
258258
'TODO: Raise an exception here. Testing what cases it happens',

readthedocs/rtd_tests/tests/test_doc_serving.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from django.urls import reverse
1111
from mock import mock_open, patch
1212

13-
from readthedocs.builds.constants import PULL_REQUEST, INTERNAL
13+
from readthedocs.builds.constants import LATEST, EXTERNAL, INTERNAL
1414
from readthedocs.builds.models import Version
1515
from readthedocs.core.middleware import SubdomainMiddleware
1616
from readthedocs.core.views import server_error_404_subdomain
@@ -249,15 +249,15 @@ def test_sitemap_xml(self):
249249
project=self.public,
250250
active=True
251251
)
252-
# This is a Pull Request Version
252+
# This is a EXTERNAL Version
253253
pr_version = fixture.get(
254254
Version,
255255
identifier='pr-version',
256256
verbose_name='pr-version',
257257
slug='pr-9999',
258258
project=self.public,
259259
active=True,
260-
type=PULL_REQUEST
260+
type=EXTERNAL
261261
)
262262
# This also creates a Version `latest` Automatically for this project
263263
translation = fixture.get(

readthedocs/rtd_tests/tests/test_managers.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.test import TestCase
33
from django_dynamic_fixture import get
44

5-
from readthedocs.builds.constants import PULL_REQUEST, BRANCH, TAG
5+
from readthedocs.builds.constants import EXTERNAL, BRANCH, TAG
66
from readthedocs.builds.models import Version
77
from readthedocs.projects.constants import PUBLIC, PRIVATE, PROTECTED
88
from readthedocs.projects.models import Project
@@ -19,37 +19,37 @@ def setUp(self):
1919
self.user = User.objects.create(username='test_user', password='test')
2020
self.client.login(username='test_user', password='test')
2121
self.pip = Project.objects.get(slug='pip')
22-
# Create a External Version. ie: PULL_REQUEST type Version.
22+
# Create a External Version. ie: pull/merge request Version.
2323
self.public_pr_version = get(
2424
Version,
2525
project=self.pip,
2626
active=True,
27-
type=PULL_REQUEST,
27+
type=EXTERNAL,
2828
privacy_level=PUBLIC
2929
)
3030
self.private_pr_version = get(
3131
Version,
3232
project=self.pip,
3333
active=True,
34-
type=PULL_REQUEST,
34+
type=EXTERNAL,
3535
privacy_level=PRIVATE
3636
)
3737
self.protected_pr_version = get(
3838
Version,
3939
project=self.pip,
4040
active=True,
41-
type=PULL_REQUEST,
41+
type=EXTERNAL,
4242
privacy_level=PROTECTED
4343
)
44-
self.internal_versions = Version.objects.exclude(type=PULL_REQUEST)
44+
self.internal_versions = Version.objects.exclude(type=EXTERNAL)
4545

4646

4747
class TestInternalVersionManager(TestVersionManagerBase):
4848

4949
"""
5050
Queries using Internal Manager should only include Internal Versions.
5151
52-
It will exclude PULL_REQUEST type Versions from the queries
52+
It will exclude EXTERNAL type Versions from the queries
5353
and only include BRANCH, TAG, UNKONWN type Versions.
5454
"""
5555

@@ -83,7 +83,7 @@ class TestExternalVersionManager(TestVersionManagerBase):
8383
"""
8484
Queries using External Manager should only include External Versions.
8585
86-
It will only include PULL_REQUEST type Versions in the queries.
86+
It will only include pull/merge request Version in the queries.
8787
"""
8888

8989
def test_external_version_manager_with_all(self):

readthedocs/rtd_tests/tests/test_project.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
BUILD_STATE_FINISHED,
1515
BUILD_STATE_TRIGGERED,
1616
LATEST,
17-
PULL_REQUEST,
17+
EXTERNAL,
1818
)
1919
from readthedocs.builds.models import Build, Version
2020
from readthedocs.projects.exceptions import ProjectConfigurationError
@@ -30,15 +30,15 @@ class ProjectMixin:
3030
def setUp(self):
3131
self.client.login(username='eric', password='test')
3232
self.pip = Project.objects.get(slug='pip')
33-
# Create a External Version. ie: PULL_REQUEST type Version.
33+
# Create a External Version. ie: pull/merge request Version.
3434
self.pr_version = get(
3535
Version,
3636
identifier='pr-version',
3737
verbose_name='pr-version',
3838
slug='pr-9999',
3939
project=self.pip,
4040
active=True,
41-
type=PULL_REQUEST
41+
type=EXTERNAL
4242
)
4343

4444

@@ -156,7 +156,7 @@ def test_all_active_versions_excludes_pr_versions(self):
156156

157157
def test_update_stable_version_excludes_pr_versions(self):
158158
# Delete all versions excluding PR Versions.
159-
self.pip.versions.exclude(type=PULL_REQUEST).delete()
159+
self.pip.versions.exclude(type=EXTERNAL).delete()
160160
# Test that PR Version is not considered for stable.
161161
self.assertEqual(self.pip.update_stable_version(), None)
162162

readthedocs/rtd_tests/tests/test_project_forms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django_dynamic_fixture import get
66
from textclassifier.validators import ClassifierValidator
77

8-
from readthedocs.builds.constants import LATEST, STABLE, PULL_REQUEST
8+
from readthedocs.builds.constants import LATEST, STABLE, EXTERNAL
99
from readthedocs.builds.models import Version
1010
from readthedocs.projects.constants import (
1111
PRIVATE,
@@ -391,7 +391,7 @@ def test_pr_version_not_in_default_branch_choices(self):
391391
slug='pr-9999',
392392
project=self.project,
393393
active=True,
394-
type=PULL_REQUEST,
394+
type=EXTERNAL,
395395
privacy_level=PUBLIC,
396396
)
397397
form = ProjectAdvancedForm(instance=self.project)

readthedocs/rtd_tests/tests/test_project_views.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from django_dynamic_fixture import get, new
1313
from mock import patch
1414

15-
from readthedocs.builds.constants import LATEST, PULL_REQUEST
15+
from readthedocs.builds.constants import LATEST, EXTERNAL
1616
from readthedocs.builds.models import Build, Version
1717
from readthedocs.oauth.models import RemoteRepository
1818
from readthedocs.projects import tasks
@@ -377,7 +377,7 @@ def setUp(self):
377377
slug='pr-9999',
378378
project=self.pip,
379379
active=True,
380-
type=PULL_REQUEST
380+
type=EXTERNAL
381381
)
382382

383383
def test_project_download_media(self):

readthedocs/rtd_tests/tests/test_version.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.test import TestCase
22
from django_dynamic_fixture import get
33

4-
from readthedocs.builds.constants import PULL_REQUEST, BRANCH, TAG
4+
from readthedocs.builds.constants import EXTERNAL, BRANCH, TAG
55
from readthedocs.builds.models import Version
66
from readthedocs.projects.models import Project
77

@@ -13,15 +13,15 @@ class VersionMixin:
1313
def setUp(self):
1414
self.client.login(username='eric', password='test')
1515
self.pip = Project.objects.get(slug='pip')
16-
# Create a External Version. ie: PULL_REQUEST type Version.
16+
# Create a External Version. ie: pull/merge request Version.
1717
self.pr_version = get(
1818
Version,
1919
identifier='9F86D081884C7D659A2FEAA0C55AD015A',
2020
verbose_name='pr-version',
2121
slug='9999',
2222
project=self.pip,
2323
active=True,
24-
type=PULL_REQUEST
24+
type=EXTERNAL
2525
)
2626
self.branch_version = get(
2727
Version,

0 commit comments

Comments
 (0)