Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(DS-536) refactor!: remove distro defaults settings to add from strain/conf file #46

Merged
merged 8 commits into from
Jun 26, 2023
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tutor distro repository-validator
Distro plugin manages a set of settings that you can configure, to know how to do that check:

- [How to custumize distro](./docs/how_to_customize_distro.rst)
- [How to override or add a new package](./docs/how_to_add_new_packages.rst)
- [How to add a new package](./docs/how_to_add_new_packages.rst)

# Required tutor settings

Expand Down Expand Up @@ -64,6 +64,7 @@ These packages will be installed in a default installation.
- eox-audit-model (DISTRO_EOX_AUDIT_MODEL_DPKG)
- eox-tagging (DISTRO_EOX_TAGGING_DPKG)

:warning: **NOTE**: From Olmo version Distro has not defaulted packages. Now it is necessary to add the packages you want in ``config.yml`` file. See [How to add a new package](./docs/how_to_add_new_packages.rst)

## How to add a new package

Expand Down Expand Up @@ -118,6 +119,8 @@ You can use the same steps that in **How to add a new package** just set the var
- DISTRO_EOX_AUDIT_MODEL_DPKG
- DISTRO_EOX_TAGGING_DPKG

:warning: **NOTE**: From Olmo version Distro has not defaulted packages. Now it is necessary to add the packages you want in ``config.yml`` file. See [How to add a new package](./docs/how_to_add_new_packages.rst)
JuanDavidBuitrago marked this conversation as resolved.
Show resolved Hide resolved

## Disable packages

You can disable any default package following this structure in your config.yml:
Expand All @@ -130,11 +133,15 @@ Development environment take this changes with _tutor config save_ and restart,

> **Warning:** Default packages can have dependencies with other default packages or base application and disable it would break some features.

:warning: **NOTE**: From Olmo version Distro has not defaulted packages. Now it is necessary to add the packages you want in ``config.yml`` file. See [How to add a new package](./docs/how_to_add_new_packages.rst)

# Themes

Declare the path of your themes using `tutor config save --set DISTRO_THEMES_ROOT="your_path"`,
by default the themes path goes here **/openedx/themes**

:warning: **NOTE**: From Olmo version Distro has not defaulted themes path. Now it is necessary to add the themes path in ``config.yml`` file or running command above.
JuanDavidBuitrago marked this conversation as resolved.
Show resolved Hide resolved

## Default themes

These themes will be installed in a default installation.
Expand All @@ -143,6 +150,8 @@ These themes will be installed in a default installation.

Defining a DISTRO_DEFAULT_SITE_THEME argument with a color will set a default theme, however, if not specified the default theme will be the first on the DISTRO_THEMES_NAME set of themes.

:warning: **NOTE**: From Olmo version Distro has not defaulted themes. Now it is necessary to add the themes in ``config.yml`` file. See [How to add a theme](https://github.com/eduNEXT/tutor-contrib-edunext-distro#how-to-add-a-theme).

## How to add a theme

You can override the default themes on the config.yml but
Expand Down Expand Up @@ -190,6 +199,8 @@ tutor distro enable-themes
openedx-assets themes --theme-dirs THEME_DIRS --themes THEME_NAMES
```

:warning: **NOTE**: From Olmo version Distro has not defaulted themes. Now it is necessary to add the themes in ``config.yml`` file.

# Build a new image

**requirements:** you should have enabled the distro plugin, also you had have run the commands `tutor distro enable-themes` and `tutor distro enable-private-packages`.
Expand Down Expand Up @@ -251,6 +262,47 @@ DISTRO_EXTRA_MIDDLEWARES:
- middleware.test.2
```

## How to add extra files requirements

You should set the variable **INSTALL_EXTRA_FILE_REQUIREMENTS** in your config.yml file if you need to install extra files with. The structure should be like:
JuanDavidBuitrago marked this conversation as resolved.
Show resolved Hide resolved

```yaml
INSTALL_EXTRA_FILE_REQUIREMENTS:
path: ./requirements/extra_file/
files: [
/edunext/base.txt,
/test/test.txt
]
```

It's important that ``.txt`` files are added in requirements directory, similar to EXTRA PIP REQUIREMENTS from [Tutor](https://docs.tutor.overhang.io/configuration.html#installing-extra-xblocks-and-requirements).

## How to enable openedx extra settings

You should set the variable **OPENEDX_EXTRA_SETTINGS** in your config.yml file if you need to enable ``cms_env``, ``lms_env`` or ``pre_init_lms_task`` settings to plugins works as expected. For now the principals settings should be like this:

```yaml
OPENEDX_EXTRA_SETTINGS:
cms_env: [
USE_EOX_TENANT: true
]
lms_env: [
USE_EOX_TENANT: true,
JuanDavidBuitrago marked this conversation as resolved.
Show resolved Hide resolved
ENABLE_EOX_THEMING_DERIVE_WORKAROUND: true
]
pre_init_lms_tasks: [
./manage.py lms migrate contenttypes,
./manage.py lms migrate eox_core,
./manage.py lms migrate eox_tenant,
./manage.py lms migrate eox_tagging,
./manage.py lms migrate eox_audit_model
]
```

The list could grow according to the needs that arise at the time of configuring the plugins.

:warning: **Note**: Other Options as ``INSTALL_EXTRA_FILE_REQUIREMENTS`` and ``OPENEDX_EXTRA_SETTINGS`` are included from Olmo version, you can use it from this release.

# License

This software is licensed under the terms of the AGPLv3.
53 changes: 48 additions & 5 deletions docs/how_to_add_new_packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ How to override or add a new package

You can add or override a package directly in config.yml file (``$(tutor config printroot)/config.yaml``).

It's possible to install from a repository or by pip but take in mind, the second option couldn't install it as editable.
It's possible to install from a repository or by pip but take in mind, the second option couldn't install it as editable.

Follow the next structure:

Expand Down Expand Up @@ -48,7 +48,7 @@ To override a default package identify its name and set it like ``DISTRO_<PACKAG
An example of override eox-theming plugin:

.. code-block:: yml

DISTRO_EOX_THEMING_DPKG:
index: git
name: eox-theming
Expand All @@ -72,17 +72,60 @@ An example of override eox-theming plugin:
"from_django_settings"
]

:warning: **NOTE**: From Olmo version Distro has not defaulted packages. Now it is necessary to add the packages you want in ``config.yml`` file.

Private packages
----------------

Once you define your private packages in config file you need to enable them with command:

.. code-block:: bash

tutor distro enable-private-packages


Other Options
-------------

* How to add extra files requirements

You should set the variable **INSTALL_EXTRA_FILE_REQUIREMENTS** in your config.yml file if you need to install extra files with. The structure should be like:

```yaml
INSTALL_EXTRA_FILE_REQUIREMENTS:
path: ./requirements/extra_file/
files: [
/edunext/base.txt,
/test/test.txt
]
```

It's important that ``.txt`` files are added in requirements directory, similar to EXTRA PIP REQUIREMENTS from [Tutor](https://docs.tutor.overhang.io/configuration.html#installing-extra-xblocks-and-requirements).

* How to enable openedx extra settings

You should set the variable **OPENEDX_EXTRA_SETTINGS** in your config.yml file if you need to enable ``cms_env``, ``lms_env`` or ``pre_init_lms_task`` settings to plugins works as expected. For now the principals settings should be like this:

```yaml
OPENEDX_EXTRA_SETTINGS:
cms_env: [
USE_EOX_TENANT: true
]
lms_env: [
USE_EOX_TENANT: true,
ENABLE_EOX_THEMING_DERIVE_WORKAROUND: true
]
pre_init_lms_tasks: [
./manage.py lms migrate contenttypes,
./manage.py lms migrate eox_core,
./manage.py lms migrate eox_tenant,
./manage.py lms migrate eox_tagging,
./manage.py lms migrate eox_audit_model
]
```

The list could grow according to the needs that arise at the time of configuring the plugins.

:warning: **Note**: Other Options as ``INSTALL_EXTRA_FILE_REQUIREMENTS`` and ``OPENEDX_EXTRA_SETTINGS`` are included from Olmo version, you can use it from this release.

Use your new packages
----------------------
Expand All @@ -97,4 +140,4 @@ To use in local mode:
To use in dev mode:

1. Run ``tutor dev do init``
2. Run ``tutor dev start``
2. Run ``tutor dev start``
33 changes: 30 additions & 3 deletions docs/how_to_customize_distro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,35 @@ General Settings
| | |
| Add any middleware to openedx setting MIDDLEWARE | - middleware.test.1 |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+
| **INSTALL_EXTRA_FILE_REQUIREMENTS** |.. code-block:: yml |
| | |
| Add any extra files to aditional requirements | path: ./requirements/extra_file/ |
| | files: [ |
| | /edunext/base.txt, |
| | /test/test.txt |
| | ] |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+
| **OPENEDX_EXTRA_SETTINGS** |.. code-block:: yml |
| | |
| Enable openedx extra settings to configure cms_env, lms_env or pre_init_lms_tasks variables | cms_env: [ |
| | USE_EOX_TENANT: true |
| | ] |
| | lms_env: [ |
| | USE_EOX_TENANT: true, |
| | ENABLE_EOX_THEMING_DERIVE_WORKAROUND: true |
| | ]
| | pre_init_lms_tasks: [ |
| | ./manage.py lms migrate contenttypes, |
| | ./manage.py lms migrate eox_core, |
| | ./manage.py lms migrate eox_tenant |
| | ] |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+


To override these settings define it on config.yml file (``$(tutor config printroot)/config.yaml``) or use the command ``tutor config save --set GENERAL_SETTING=Value``.

:warning: **Note**: Other Options as ``INSTALL_EXTRA_FILE_REQUIREMENTS`` and ``OPENEDX_EXTRA_SETTINGS`` are included from Olmo version, you can use it from this release.


Plugins or packages
-------------------
Expand Down Expand Up @@ -86,8 +111,10 @@ You can disable anyone by the ``tutor config save --set DISTRO_<PLUGIN_NAME>_DPK


.. code-block:: yml

DISTRO_<PLUGIN_NAME>_DPKG: None


If you want to override default packages or add a new one go to the corresponding section: `How to override or add a new package. <./how_to_add_new_packages.rst>`_

:warning: **NOTE**: From Olmo version Distro has not defaulted packages. Now it is necessary to add the packages you want in ``config.yml`` file.

If you want to override default packages or add a new one go to the corresponding section: `How to add a new package. <./how_to_add_new_packages.rst>`_
5 changes: 3 additions & 2 deletions tutordistro/commands/enable_themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ def enable_themes() -> None:
repository = ThemeGitRepository()
enabler = ThemeEnabler(repository=repository)

for theme in config["DISTRO_THEMES"]:
enabler(settings=theme, tutor_root=directory, tutor_config=config)
if config.get("DISTRO_THEMES"):
for theme in config["DISTRO_THEMES"]:
enabler(settings=theme, tutor_root=directory, tutor_config=config)
11 changes: 10 additions & 1 deletion tutordistro/patches/cms-env
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
USE_EOX_TENANT: True
{% if OPENEDX_EXTRA_SETTINGS is defined and OPENEDX_EXTRA_SETTINGS["cms_env"] is defined %}
############### extra cms-env settings #############
{%- for setting in OPENEDX_EXTRA_SETTINGS["cms_env"] %}
{%- for key, value in setting.items() %}
{{ key }}: {{ value }}
{%- endfor %}
{%- endfor %}
{%- endif %}
{%- if DISTRO_DEFAULT_SITE_THEME is defined or DISTRO_THEMES_NAME is defined %}
DEFAULT_SITE_THEME: "{{ DISTRO_DEFAULT_SITE_THEME | default(DISTRO_THEMES_NAME[0]) }}"
{% endif %}
12 changes: 10 additions & 2 deletions tutordistro/patches/lms-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
USE_EOX_TENANT: True
{% if OPENEDX_EXTRA_SETTINGS is defined and OPENEDX_EXTRA_SETTINGS["lms_env"] is defined %}
############### extra cms-env settings #############
{%- for setting in OPENEDX_EXTRA_SETTINGS["lms_env"] %}
{%- for key, value in setting.items() %}
{{ key }}: {{ value }}
{%- endfor %}
{%- endfor %}
{%- endif %}
{%- if DISTRO_DEFAULT_SITE_THEME is defined or DISTRO_THEMES_NAME is defined %}
DEFAULT_SITE_THEME: "{{ DISTRO_DEFAULT_SITE_THEME | default(DISTRO_THEMES_NAME[0]) }}"
ENABLE_EOX_THEMING_DERIVE_WORKAROUND: True
{% endif %}
SESSION_COOKIE_DOMAIN: ".{{ LMS_HOST|common_domain(CMS_HOST) }}"
10 changes: 8 additions & 2 deletions tutordistro/patches/openedx-cms-production-settings
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% for pkg in iter_values_named(suffix="_DPKG") %}
{%- if pkg != 'None' -%}
{%- if pkg != 'None' and pkg["variables"] is defined %}
JuanDavidBuitrago marked this conversation as resolved.
Show resolved Hide resolved
# Start {{ pkg["name"] }} settings
{%- if "variables" in pkg and "production" in pkg["variables"] -%}
{%- for key, value in pkg["variables"]["production"].items() %}
Expand All @@ -10,12 +10,18 @@
{%- endif -%}
{% endfor %}

{% if DISTRO_THEME_DIRS is defined -%}
COMPREHENSIVE_THEME_DIRS.remove('/openedx/themes')
COMPREHENSIVE_THEME_DIRS.extend({{ DISTRO_THEME_DIRS }})
{%- endif %}

{%- for pkg in iter_values_named(suffix="_DPKG") %}
{%- if pkg["name"] == 'eox-theming' %}
################## EOX_THEMING ##################
from lms.envs.common import _make_mako_template_dirs # pylint: disable=import-error
ENABLE_COMPREHENSIVE_THEMING = True
TEMPLATES[1]["DIRS"] = _make_mako_template_dirs
derive_settings("cms.envs.production")
# EOL
# EOL
{%- endif %}
{%- endfor %}
6 changes: 4 additions & 2 deletions tutordistro/patches/openedx-common-assets-settings
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{% for pkg in iter_values_named(suffix="_DPKG") %}
{%- if pkg != 'None' -%}
{%- if pkg != 'None' and pkg["variables"] is defined %}
# Start {{ pkg["name"] }} settings
{%- if "variables" in pkg and "development" in pkg["variables"] -%}
{%- for key, value in pkg["variables"]["development"].items() %}
{{ key }} = {% if value is string %}"{{ value }}"{% else %}{{ value }}{% endif %}
{{ key }} = {% if value is string %}"{{ value }}"{% else %}{{ value }}{% endif %}
{%- endfor %}
# End {{ pkg["name"] }} settings
{%- endif -%}
{%- endif -%}
{% endfor %}

{%- if DISTRO_THEME_DIRS is defined %}
COMPREHENSIVE_THEME_DIRS.remove('/openedx/themes')
COMPREHENSIVE_THEME_DIRS.extend({{ DISTRO_THEME_DIRS }})
{%- endif %}
Loading