Skip to content

Commit 57a3f66

Browse files
committed
Domains: put a limit of 2 custom domains per project
Related #1808
1 parent 794b58b commit 57a3f66

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

readthedocs/projects/models.py

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from readthedocs.core.utils import extract_valid_attributes_for_model, slugify
3737
from readthedocs.core.utils.url import unsafe_join_url_path
3838
from readthedocs.domains.querysets import DomainQueryset
39+
from readthedocs.domains.validators import check_domains_limit
3940
from readthedocs.notifications.models import Notification as NewNotification
4041
from readthedocs.projects import constants
4142
from readthedocs.projects.exceptions import ProjectConfigurationError
@@ -1817,6 +1818,9 @@ def restart_validation_process(self):
18171818
self.validation_process_start = timezone.now()
18181819
self.save()
18191820

1821+
def clean(self):
1822+
check_domains_limit(self.project)
1823+
18201824
def save(self, *args, **kwargs):
18211825
parsed = urlparse(self.domain)
18221826
if parsed.scheme or parsed.netloc:

readthedocs/settings/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ def RTD_DEFAULT_FEATURES(self):
170170

171171
return dict(
172172
(
173-
RTDProductFeature(type=constants.TYPE_CNAME).to_item(),
173+
# Max number of domains allowed per project.
174+
RTDProductFeature(type=constants.TYPE_CNAME, value=2).to_item(),
174175
RTDProductFeature(type=constants.TYPE_EMBED_API).to_item(),
175176
# Retention days for search analytics.
176177
RTDProductFeature(

0 commit comments

Comments
 (0)