1
1
"""Project models."""
2
+
2
3
import fnmatch
3
4
import hashlib
4
5
import hmac
17
18
from django .utils .crypto import get_random_string
18
19
from django .utils .functional import cached_property
19
20
from django .utils .translation import gettext_lazy as _
20
- from django_extensions .db .fields import (CreationDateTimeField ,
21
- ModificationDateTimeField )
21
+ from django_extensions .db .fields import CreationDateTimeField , ModificationDateTimeField
22
22
from django_extensions .db .models import TimeStampedModel
23
23
from taggit .managers import TaggableManager
24
24
25
- from readthedocs .builds .constants import (BRANCH , EXTERNAL , INTERNAL , LATEST ,
26
- LATEST_VERBOSE_NAME , STABLE ,
27
- STABLE_VERBOSE_NAME )
25
+ from readthedocs .builds .constants import (
26
+ BRANCH ,
27
+ EXTERNAL ,
28
+ INTERNAL ,
29
+ LATEST ,
30
+ LATEST_VERBOSE_NAME ,
31
+ STABLE ,
32
+ STABLE_VERBOSE_NAME ,
33
+ )
28
34
from readthedocs .core .history import ExtraHistoricalRecords
29
35
from readthedocs .core .resolver import Resolver
30
36
from readthedocs .core .utils import extract_valid_attributes_for_model , slugify
36
42
from readthedocs .projects import constants
37
43
from readthedocs .projects .exceptions import ProjectConfigurationError
38
44
from readthedocs .projects .managers import HTMLFileManager
39
- from readthedocs .projects .querysets import (ChildRelatedProjectQuerySet ,
40
- FeatureQuerySet , ProjectQuerySet ,
41
- RelatedProjectQuerySet )
45
+ from readthedocs .projects .querysets import (
46
+ ChildRelatedProjectQuerySet ,
47
+ FeatureQuerySet ,
48
+ ProjectQuerySet ,
49
+ RelatedProjectQuerySet ,
50
+ )
42
51
from readthedocs .projects .validators import (
43
- validate_build_config_file , validate_custom_prefix ,
44
- validate_custom_subproject_prefix , validate_domain_name ,
45
- validate_environment_variable_size , validate_no_ip ,
46
- validate_repository_url )
52
+ validate_build_config_file ,
53
+ validate_custom_prefix ,
54
+ validate_custom_subproject_prefix ,
55
+ validate_domain_name ,
56
+ validate_environment_variable_size ,
57
+ validate_no_ip ,
58
+ validate_repository_url ,
59
+ )
47
60
from readthedocs .projects .version_handling import determine_stable_version
48
61
from readthedocs .search .parsers import GenericParser
49
62
from readthedocs .storage import build_media_storage
50
63
from readthedocs .vcs_support .backends import backend_cls
51
64
52
- from .constants import (ADDONS_FLYOUT_POSITION_CHOICES ,
53
- ADDONS_FLYOUT_SORTING_CHOICES ,
54
- ADDONS_FLYOUT_SORTING_SEMVER_READTHEDOCS_COMPATIBLE ,
55
- DOWNLOADABLE_MEDIA_TYPES , MEDIA_TYPES ,
56
- MULTIPLE_VERSIONS_WITH_TRANSLATIONS ,
57
- MULTIPLE_VERSIONS_WITHOUT_TRANSLATIONS , PUBLIC )
65
+ from .constants import (
66
+ ADDONS_FLYOUT_POSITION_CHOICES ,
67
+ ADDONS_FLYOUT_SORTING_CHOICES ,
68
+ ADDONS_FLYOUT_SORTING_SEMVER_READTHEDOCS_COMPATIBLE ,
69
+ DOWNLOADABLE_MEDIA_TYPES ,
70
+ MEDIA_TYPES ,
71
+ MULTIPLE_VERSIONS_WITH_TRANSLATIONS ,
72
+ MULTIPLE_VERSIONS_WITHOUT_TRANSLATIONS ,
73
+ PUBLIC ,
74
+ )
58
75
59
76
log = structlog .get_logger (__name__ )
60
77
@@ -65,7 +82,6 @@ def default_privacy_level():
65
82
66
83
67
84
class ProjectRelationship (models .Model ):
68
-
69
85
"""
70
86
Project to project relationship.
71
87
@@ -120,7 +136,6 @@ def subproject_prefix(self):
120
136
121
137
122
138
class AddonsConfig (TimeStampedModel ):
123
-
124
139
"""
125
140
Addons project configuration.
126
141
@@ -251,7 +266,6 @@ class AddonsConfig(TimeStampedModel):
251
266
252
267
253
268
class AddonSearchFilter (TimeStampedModel ):
254
-
255
269
"""
256
270
Addon search user defined filter.
257
271
@@ -264,7 +278,6 @@ class AddonSearchFilter(TimeStampedModel):
264
278
265
279
266
280
class Project (models .Model ):
267
-
268
281
"""Project model."""
269
282
270
283
# Auto fields
@@ -1367,8 +1380,7 @@ def show_advertising(self):
1367
1380
return False
1368
1381
1369
1382
if "readthedocsext.spamfighting" in settings .INSTALLED_APPS :
1370
- from readthedocsext .spamfighting .utils import \
1371
- is_show_ads_denied # noqa
1383
+ from readthedocsext .spamfighting .utils import is_show_ads_denied # noqa
1372
1384
1373
1385
return not is_show_ads_denied (self )
1374
1386
@@ -1433,7 +1445,6 @@ def organization(self):
1433
1445
1434
1446
1435
1447
class APIProject (Project ):
1436
-
1437
1448
"""
1438
1449
Project proxy model for API data deserialization.
1439
1450
@@ -1507,7 +1518,6 @@ def environment_variables(self, *, public_only=True):
1507
1518
1508
1519
1509
1520
class ImportedFile (models .Model ):
1510
-
1511
1521
"""
1512
1522
Imported files model.
1513
1523
@@ -1559,7 +1569,6 @@ def get_absolute_url(self):
1559
1569
1560
1570
1561
1571
class HTMLFile (ImportedFile ):
1562
-
1563
1572
"""
1564
1573
Imported HTML file Proxy model.
1565
1574
@@ -1581,7 +1590,6 @@ def processed_json(self):
1581
1590
1582
1591
1583
1592
class Notification (TimeStampedModel ):
1584
-
1585
1593
"""WebHook / Email notification attached to a Project."""
1586
1594
1587
1595
# TODO: Overridden from TimeStampedModel just to allow null values,
@@ -1746,7 +1754,6 @@ def sign_payload(self, payload):
1746
1754
1747
1755
1748
1756
class Domain (TimeStampedModel ):
1749
-
1750
1757
"""A custom domain name for a project."""
1751
1758
1752
1759
# TODO: Overridden from TimeStampedModel just to allow null values,
@@ -1870,7 +1877,6 @@ def save(self, *args, **kwargs):
1870
1877
1871
1878
1872
1879
class HTTPHeader (TimeStampedModel , models .Model ):
1873
-
1874
1880
"""
1875
1881
Define a HTTP header for a user Domain.
1876
1882
@@ -1913,7 +1919,6 @@ def __str__(self):
1913
1919
1914
1920
1915
1921
class Feature (models .Model ):
1916
-
1917
1922
"""
1918
1923
Project feature flags.
1919
1924
0 commit comments