23
23
from readthedocs .core .resolver import Resolver
24
24
from readthedocs .core .unresolver import UnresolverError , unresolver
25
25
from readthedocs .core .utils .extend import SettingsOverrideObject
26
- from readthedocs .projects .models import Feature , Project
26
+ from readthedocs .projects .models import Project
27
27
28
28
log = structlog .get_logger (__name__ ) # noqa
29
29
@@ -320,24 +320,21 @@ def _v0(self, project, version, build, filename, url, user):
320
320
# serializer than the keys ``project``, ``version`` and ``build`` from the top level.
321
321
"addons" : {
322
322
"analytics" : {
323
- "enabled" : Feature .ADDONS_ANALYTICS_DISABLED
324
- not in project_features ,
323
+ "enabled" : project .addons .analytics_enabled ,
325
324
# TODO: consider adding this field into the ProjectSerializer itself.
326
325
# NOTE: it seems we are removing this feature,
327
326
# so we may not need the ``code`` attribute here
328
327
# https://github.com/readthedocs/readthedocs.org/issues/9530
329
328
"code" : project .analytics_code ,
330
329
},
331
330
"external_version_warning" : {
332
- "enabled" : Feature .ADDONS_EXTERNAL_VERSION_WARNING_DISABLED
333
- not in project_features ,
331
+ "enabled" : project .addons .external_version_warning_enabled ,
334
332
# NOTE: I think we are moving away from these selectors
335
333
# since we are doing floating noticications now.
336
334
# "query_selector": "[role=main]",
337
335
},
338
336
"non_latest_version_warning" : {
339
- "enabled" : Feature .ADDONS_NON_LATEST_VERSION_WARNING_DISABLED
340
- not in project_features ,
337
+ "enabled" : project .addons .stable_latest_version_warning_enabled ,
341
338
# NOTE: I think we are moving away from these selectors
342
339
# since we are doing floating noticications now.
343
340
# "query_selector": "[role=main]",
@@ -346,7 +343,7 @@ def _v0(self, project, version, build, filename, url, user):
346
343
),
347
344
},
348
345
"flyout" : {
349
- "enabled" : Feature . ADDONS_FLYOUT_DISABLED not in project_features ,
346
+ "enabled" : project . addons . flyout_enabled ,
350
347
"translations" : [
351
348
{
352
349
# TODO: name this field "display_name"
@@ -398,7 +395,7 @@ def _v0(self, project, version, build, filename, url, user):
398
395
# },
399
396
},
400
397
"search" : {
401
- "enabled" : Feature . ADDONS_SEARCH_DISABLED not in project_features ,
398
+ "enabled" : project . addons . search_enabled ,
402
399
"project" : project .slug ,
403
400
"version" : version .slug if version else None ,
404
401
"api_endpoint" : "/_/api/v3/search/" ,
@@ -416,7 +413,7 @@ def _v0(self, project, version, build, filename, url, user):
416
413
else None ,
417
414
},
418
415
"hotkeys" : {
419
- "enabled" : Feature . ADDONS_HOTKEYS_DISABLED not in project_features ,
416
+ "enabled" : project . addons . hotkeys_enabled ,
420
417
"doc_diff" : {
421
418
"enabled" : True ,
422
419
"trigger" : "KeyD" , # Could be something like "Ctrl + D"
@@ -437,8 +434,7 @@ def _v0(self, project, version, build, filename, url, user):
437
434
data ["addons" ].update (
438
435
{
439
436
"doc_diff" : {
440
- "enabled" : Feature .ADDONS_DOC_DIFF_DISABLED
441
- not in project_features ,
437
+ "enabled" : project .addons .doc_diff_enabled ,
442
438
# "http://test-builds-local.devthedocs.org/en/latest/index.html"
443
439
"base_url" : resolver .resolve (
444
440
project = project ,
@@ -478,8 +474,7 @@ def _v0(self, project, version, build, filename, url, user):
478
474
data ["addons" ].update (
479
475
{
480
476
"ethicalads" : {
481
- "enabled" : Feature .ADDONS_ETHICALADS_DISABLED
482
- not in project_features ,
477
+ "enabled" : project .addons .ethicalads_enabled ,
483
478
# NOTE: this endpoint is not authenticated, the user checks are done over an annonymous user for now
484
479
#
485
480
# NOTE: it requires ``settings.USE_PROMOS=True`` to return ``ad_free=false`` here
0 commit comments