Ejemplo n.º 1
0
class Feature(models.Model):
    """Project feature flags

    Features should generally be added here as choices, however features may
    also be added dynamically from a signal in other packages. Features can be
    added by external packages with the use of signals::

        @receiver(pre_init, sender=Feature)
        def add_features(sender, **kwargs):
            sender.FEATURES += (('blah', 'BLAH'),)

    The FeatureForm will grab the updated list on instantiation.
    """

    # Feature constants - this is not a exhaustive list of features, features
    # may be added by other packages
    USE_SPHINX_LATEST = 'use_sphinx_latest'
    USE_SETUPTOOLS_LATEST = 'use_setuptools_latest'
    ALLOW_DEPRECATED_WEBHOOKS = 'allow_deprecated_webhooks'
    PIP_ALWAYS_UPGRADE = 'pip_always_upgrade'

    FEATURES = (
        (USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
        (USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')),
        (ALLOW_DEPRECATED_WEBHOOKS, _('Allow deprecated webhook views')),
        (PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')),
    )

    projects = models.ManyToManyField(
        Project,
        blank=True,
    )
    # Feature is not implemented as a ChoiceField, as we don't want validation
    # at the database level on this field. Arbitrary values are allowed here.
    feature_id = models.CharField(
        _('Feature identifier'),
        max_length=32,
        unique=True,
    )
    add_date = models.DateTimeField(
        _('Date feature was added'),
        auto_now_add=True,
    )
    default_true = models.BooleanField(
        _('Historical default is True'),
        default=False,
    )

    objects = FeatureQuerySet.as_manager()

    def __str__(self):
        return "{0} feature".format(self.get_feature_display(), )

    def get_feature_display(self):
        """Implement display name field for fake ChoiceField

        Because the field is not a ChoiceField here, we need to manually
        implement this behavior.
        """
        return dict(self.FEATURES).get(self.feature_id, self.feature_id)
Ejemplo n.º 2
0
class Feature(models.Model):
    """
    Project feature flags.

    Features should generally be added here as choices, however features may
    also be added dynamically from a signal in other packages. Features can be
    added by external packages with the use of signals::

        @receiver(pre_init, sender=Feature)
        def add_features(sender, **kwargs):
            sender.FEATURES += (('blah', 'BLAH'),)

    The FeatureForm will grab the updated list on instantiation.
    """

    # Feature constants - this is not a exhaustive list of features, features
    # may be added by other packages
    USE_SPHINX_LATEST = 'use_sphinx_latest'
    USE_SETUPTOOLS_LATEST = 'use_setuptools_latest'
    ALLOW_DEPRECATED_WEBHOOKS = 'allow_deprecated_webhooks'
    PIP_ALWAYS_UPGRADE = 'pip_always_upgrade'
    SKIP_SUBMODULES = 'skip_submodules'
    DONT_OVERWRITE_SPHINX_CONTEXT = 'dont_overwrite_sphinx_context'
    ALLOW_V2_CONFIG_FILE = 'allow_v2_config_file'
    MKDOCS_THEME_RTD = 'mkdocs_theme_rtd'

    FEATURES = (
        (USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
        (USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')),
        (ALLOW_DEPRECATED_WEBHOOKS, _('Allow deprecated webhook views')),
        (PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')),
        (SKIP_SUBMODULES, _('Skip git submodule checkout')),
        (DONT_OVERWRITE_SPHINX_CONTEXT,
         _(
             'Do not overwrite context vars in conf.py with Read the Docs context',
         )),
        (ALLOW_V2_CONFIG_FILE,
         _('Allow to use the v2 of the configuration file')),
        (MKDOCS_THEME_RTD,
         _('Use Read the Docs theme for MkDocs as default theme')),
    )

    projects = models.ManyToManyField(
        Project,
        blank=True,
    )
    # Feature is not implemented as a ChoiceField, as we don't want validation
    # at the database level on this field. Arbitrary values are allowed here.
    feature_id = models.CharField(
        _('Feature identifier'),
        max_length=32,
        unique=True,
    )
    add_date = models.DateTimeField(
        _('Date feature was added'),
        auto_now_add=True,
    )
    default_true = models.BooleanField(
        _('Historical default is True'),
        default=False,
    )

    objects = FeatureQuerySet.as_manager()

    def __str__(self):
        return '{0} feature'.format(self.get_feature_display(), )

    def get_feature_display(self):
        """
        Implement display name field for fake ChoiceField.

        Because the field is not a ChoiceField here, we need to manually
        implement this behavior.
        """
        return dict(self.FEATURES).get(self.feature_id, self.feature_id)
Ejemplo n.º 3
0
class Feature(models.Model):

    """
    Project feature flags.

    Features should generally be added here as choices, however features may
    also be added dynamically from a signal in other packages. Features can be
    added by external packages with the use of signals::

        @receiver(pre_init, sender=Feature)
        def add_features(sender, **kwargs):
            sender.FEATURES += (('blah', 'BLAH'),)

    The FeatureForm will grab the updated list on instantiation.
    """

    # Feature constants - this is not a exhaustive list of features, features
    # may be added by other packages
    USE_SPHINX_LATEST = 'use_sphinx_latest'
    USE_SETUPTOOLS_LATEST = 'use_setuptools_latest'
    ALLOW_DEPRECATED_WEBHOOKS = 'allow_deprecated_webhooks'
    PIP_ALWAYS_UPGRADE = 'pip_always_upgrade'
    SKIP_SUBMODULES = 'skip_submodules'
    DONT_OVERWRITE_SPHINX_CONTEXT = 'dont_overwrite_sphinx_context'
    MKDOCS_THEME_RTD = 'mkdocs_theme_rtd'
    API_LARGE_DATA = 'api_large_data'
    DONT_SHALLOW_CLONE = 'dont_shallow_clone'
    USE_TESTING_BUILD_IMAGE = 'use_testing_build_image'
    SHARE_SPHINX_DOCTREE = 'share_sphinx_doctree'
    USE_PDF_LATEXMK = 'use_pdf_latexmk'
    DEFAULT_TO_MKDOCS_0_17_3 = 'default_to_mkdocs_0_17_3'

    FEATURES = (
        (USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
        (USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')),
        (USE_PDF_LATEXMK, _('Use latexmk to build the PDF')),
        (ALLOW_DEPRECATED_WEBHOOKS, _('Allow deprecated webhook views')),
        (PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')),
        (SKIP_SUBMODULES, _('Skip git submodule checkout')),
        (
            DONT_OVERWRITE_SPHINX_CONTEXT,
            _(
                'Do not overwrite context vars in conf.py with Read the Docs context',
            ),
        ),
        (
            MKDOCS_THEME_RTD,
            _('Use Read the Docs theme for MkDocs as default theme'),
        ),
        (
            DONT_SHALLOW_CLONE,
            _('Do not shallow clone when cloning git repos'),
        ),
        (
            USE_TESTING_BUILD_IMAGE,
            _('Use Docker image labelled as `testing` to build the docs'),
        ),
        (
            API_LARGE_DATA,
            _('Try alternative method of posting large data'),
        ),
        (
            SHARE_SPHINX_DOCTREE,
            _('Use shared directory for doctrees'),
        ),
        (
            DEFAULT_TO_MKDOCS_0_17_3,
            _('Install mkdocs 0.17.3 by default')
        ),
    )

    projects = models.ManyToManyField(
        Project,
        blank=True,
    )
    # Feature is not implemented as a ChoiceField, as we don't want validation
    # at the database level on this field. Arbitrary values are allowed here.
    feature_id = models.CharField(
        _('Feature identifier'),
        max_length=32,
        unique=True,
    )
    add_date = models.DateTimeField(
        _('Date feature was added'),
        auto_now_add=True,
    )
    default_true = models.BooleanField(
        _('Historical default is True'),
        default=False,
    )

    objects = FeatureQuerySet.as_manager()

    def __str__(self):
        return '{} feature'.format(self.get_feature_display(),)

    def get_feature_display(self):
        """
        Implement display name field for fake ChoiceField.

        Because the field is not a ChoiceField here, we need to manually
        implement this behavior.
        """
        return dict(self.FEATURES).get(self.feature_id, self.feature_id)
Ejemplo n.º 4
0
class Feature(models.Model):
    """
    Project feature flags.

    Features should generally be added here as choices, however features may
    also be added dynamically from a signal in other packages. Features can be
    added by external packages with the use of signals::

        @receiver(pre_init, sender=Feature)
        def add_features(sender, **kwargs):
            sender.FEATURES += (('blah', 'BLAH'),)

    The FeatureForm will grab the updated list on instantiation.
    """

    # Feature constants - this is not a exhaustive list of features, features
    # may be added by other packages
    USE_SPHINX_LATEST = 'use_sphinx_latest'
    ALLOW_DEPRECATED_WEBHOOKS = 'allow_deprecated_webhooks'
    PIP_ALWAYS_UPGRADE = 'pip_always_upgrade'
    DONT_OVERWRITE_SPHINX_CONTEXT = 'dont_overwrite_sphinx_context'
    MKDOCS_THEME_RTD = 'mkdocs_theme_rtd'
    API_LARGE_DATA = 'api_large_data'
    DONT_SHALLOW_CLONE = 'dont_shallow_clone'
    USE_TESTING_BUILD_IMAGE = 'use_testing_build_image'
    SHARE_SPHINX_DOCTREE = 'share_sphinx_doctree'
    DEFAULT_TO_MKDOCS_0_17_3 = 'default_to_mkdocs_0_17_3'
    CLEAN_AFTER_BUILD = 'clean_after_build'
    EXTERNAL_VERSION_BUILD = 'external_version_build'
    UPDATE_CONDA_STARTUP = 'update_conda_startup'
    CONDA_APPEND_CORE_REQUIREMENTS = 'conda_append_core_requirements'
    SEARCH_ANALYTICS = 'search_analytics'

    FEATURES = ((USE_SPHINX_LATEST, _('Use latest version of Sphinx')), (
        ALLOW_DEPRECATED_WEBHOOKS, _('Allow deprecated webhook views')
    ), (PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')), (
        DONT_OVERWRITE_SPHINX_CONTEXT,
        _(
            'Do not overwrite context vars in conf.py with Read the Docs context',
        ),
    ), (
        MKDOCS_THEME_RTD,
        _('Use Read the Docs theme for MkDocs as default theme'),
    ), (
        DONT_SHALLOW_CLONE,
        _('Do not shallow clone when cloning git repos'),
    ), (
        USE_TESTING_BUILD_IMAGE,
        _('Use Docker image labelled as `testing` to build the docs'),
    ), (
        API_LARGE_DATA,
        _('Try alternative method of posting large data'),
    ), (
        SHARE_SPHINX_DOCTREE,
        _('Use shared directory for doctrees'),
    ), (
        DEFAULT_TO_MKDOCS_0_17_3,
        _('Install mkdocs 0.17.3 by default'),
    ), (
        CLEAN_AFTER_BUILD,
        _('Clean all files used in the build process'),
    ), (
        EXTERNAL_VERSION_BUILD,
        _('Enable project to build on pull/merge requests'),
    ), (
        UPDATE_CONDA_STARTUP,
        _('Upgrade conda before creating the environment'),
    ), (
        CONDA_APPEND_CORE_REQUIREMENTS,
        _('Append Read the Docs core requirements to environment.yml file'),
    ), (
        SEARCH_ANALYTICS,
        _('Enable search analytics'),
    ))

    projects = models.ManyToManyField(
        Project,
        blank=True,
    )
    # Feature is not implemented as a ChoiceField, as we don't want validation
    # at the database level on this field. Arbitrary values are allowed here.
    feature_id = models.CharField(
        _('Feature identifier'),
        max_length=32,
        unique=True,
    )
    add_date = models.DateTimeField(
        _('Date feature was added'),
        auto_now_add=True,
    )
    default_true = models.BooleanField(
        _('Historical default is True'),
        default=False,
    )

    objects = FeatureQuerySet.as_manager()

    def __str__(self):
        return '{} feature'.format(self.get_feature_display(), )

    def get_feature_display(self):
        """
        Implement display name field for fake ChoiceField.

        Because the field is not a ChoiceField here, we need to manually
        implement this behavior.
        """
        return dict(self.FEATURES).get(self.feature_id, self.feature_id)