-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Domains: put a limit of 2 custom domains per project (#11629)
* Domains: put a limit of 2 custom domains per project Related #1808 * Domains: add tests for limit amount of domains * Add missing import * Test: define 2 domains as limit for all the tests
- Loading branch information
Showing
10 changed files
with
89 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django.conf import settings | ||
from django.core.exceptions import ValidationError | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from readthedocs.subscriptions.constants import TYPE_CNAME | ||
from readthedocs.subscriptions.products import get_feature | ||
|
||
|
||
def check_domains_limit(project, error_class=ValidationError): | ||
"""Check if the project has reached the limit on the number of domains.""" | ||
feature = get_feature(project, TYPE_CNAME) | ||
if feature.unlimited: | ||
return | ||
|
||
if project.domains.count() >= feature.value: | ||
msg = _( | ||
f"This project has reached the limit of {feature.value} domains." | ||
" Consider removing unused domains." | ||
) | ||
if settings.ALLOW_PRIVATE_REPOS: | ||
msg = _( | ||
f"Your organization has reached the limit of {feature.value} domains." | ||
" Consider removing unused domains or upgrading your plan." | ||
) | ||
raise error_class(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters