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

display loaded plugins in footer #139

Merged
merged 7 commits into from May 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -12,6 +12,7 @@ New features
-----------
* Allow plugins to overwrite UI routes and customise the teaser on the login form [see `PR #106 <http://www.github.com/SeitaBV/flexmeasures/pull/106>`_]
* Allow plugins to customise the copyright notice and credits in the UI footer [see `PR #123 <http://www.github.com/SeitaBV/flexmeasures/pull/123>`_]
* Display loaded plugins in footer [see `PR #139 <http://www.github.com/SeitaBV/flexmeasures/pull/139>`_]

Bugfixes
-----------
Expand Down
5 changes: 4 additions & 1 deletion flexmeasures/ui/templates/base.html
Expand Up @@ -284,7 +284,7 @@ <h3>Icons from <a href="https://www.flaticon.com/" title="Flaticon">Flaticon</a>
{% endif %}
{% if not current_user.has_role('anonymous') %}
{% if flexmeasures_version %}
on version {{ flexmeasures_version }}
on version {{ flexmeasures_version }}.
{% else %}
{% if git_version != "Unknown" %}
on version {{ git_version }}+{{ git_commits_since }}.
Expand All @@ -293,6 +293,9 @@ <h3>Icons from <a href="https://www.flaticon.com/" title="Flaticon">Flaticon</a>
{% endif %}
{% endif %}
{% endif %}
{% if loaded_plugins %}
Loaded plugins: {{ loaded_plugins }}.
{% endif %}
</div>
<div>
<a href="https://seita.nl/"><i class="icon-seita_bird supersize"></i></a>
Expand Down
1 change: 1 addition & 0 deletions flexmeasures/ui/utils/view_utils.py
Expand Up @@ -71,6 +71,7 @@ def render_flexmeasures_template(html_filename: str, **variables):
) = get_git_description()
app_start_time = current_app.config.get("START_TIME")
variables["app_running_since"] = time_utils.naturalized_datetime_str(app_start_time)
variables["loaded_plugins"] = ",".join(current_app.config.get("LOADED_PLUGINS", []))

variables["user_is_logged_in"] = current_user.is_authenticated
variables[
Expand Down
2 changes: 2 additions & 0 deletions flexmeasures/utils/app_utils.py
Expand Up @@ -84,6 +84,7 @@ def register_plugins(app: Flask):
f"The value of FLEXMEASURES_PLUGIN_PATHS is not a list: {plugin_paths}. Cannot install plugins ..."
)
return
app.config["LOADED_PLUGINS"] = []
for plugin_path in plugin_paths:
plugin_name = plugin_path.split("/")[-1]
if not os.path.exists(os.path.join(plugin_path, "__init__.py")):
Expand All @@ -101,3 +102,4 @@ def register_plugins(app: Flask):
sys.modules[plugin_name] = module
spec.loader.exec_module(module)
app.register_blueprint(getattr(module, f"{plugin_name}_bp"))
app.config["LOADED_PLUGINS"].append(plugin_name)