Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolai <nrozanov@iponweb.net>
  • Loading branch information
Nikolai committed Jun 11, 2024
2 parents 12656e0 + f59c108 commit afa80da
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 27 deletions.
1 change: 1 addition & 0 deletions documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Infrastructure / Support
* ``PandasReporter`` accepts the parameter ``use_latest_version_only`` to filter input data [see `PR #1045 <https://github.com/FlexMeasures/flexmeasures/pull/1045/>`_]
* ``flexmeasures show beliefs`` uses the entity path (`<Account>/../<Sensor>`) in case of duplicated sensors [see `PR #1026 <https://github.com/FlexMeasures/flexmeasures/pull/1026/>`_]
* Add ``--resolution`` option to ``flexmeasures show chart`` to produce charts in different time resolutions [see `PR #1007 <https://github.com/FlexMeasures/flexmeasures/pull/1007/>`_]
* Add ``FLEXMEASURES_JSON_COMPACT`` config setting and deprecate ``JSONIFY_PRETTYPRINT_REGULAR`` setting [see `PR #1090 <https://github.com/FlexMeasures/flexmeasures/pull/1090/>`_]


v0.21.0 | May 16, 2024
Expand Down
13 changes: 13 additions & 0 deletions flexmeasures/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ def get_reporters():

register_auth_at(app)

# This needs to happen here because for unknown reasons, Security(app)
# and FlaskJSON() will set this to False on their own
if app.config.get("FLEXMEASURES_JSON_COMPACT", False) in (
True,
"True",
"true",
"1",
"yes",
):
app.json.compact = True
else:
app.json.compact = False

# Register the CLI

from flexmeasures.cli import register_at as register_cli_at
Expand Down
34 changes: 17 additions & 17 deletions flexmeasures/ui/templates/admin/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ <h1>Meter data</h1>
</thead>
<tbody id ="clients-table"> </tbody>
</table>
<a class="btn btn-default" href="#" role="button" data-toggle="modal" data-target="#editClientModal" id="button-add-client">
<a class="btn btn-default" href="#" role="button" data-bs-toggle="modal" data-bs-target="#editClientModal" id="button-add-client">
<span class="fa fa-plus" aria-hidden="true"></span> Add
</a>
<div class="modal fade" id="editClientModal" tabindex="-1" role="dialog" aria-labelledby="editClientModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="editClientModalLabel">
Expand Down Expand Up @@ -112,8 +112,8 @@ <h4 class="modal-title" id="editClientModalLabel">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit-client-form-save" data-dismiss="modal">Save</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit-client-form-save" data-bs-dismiss="modal">Save</button>
</div>
</div>
</div>
Expand All @@ -128,8 +128,8 @@ <h4 class="modal-title text-center" id="removeClientModalLabel">Are you sure you
<form id="remove-client-form">
<input type="hidden" name="id" id="remove-client-id"/>
</form>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" id="button-remove-client" data-dismiss="modal">Remove</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" id="button-remove-client" data-bs-dismiss="modal">Remove</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -187,8 +187,8 @@ <h4 class="modal-title" id="editClientDataSetModalLabel">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit-client-data-set-form-save" data-dismiss="modal">Save</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit-client-data-set-form-save" data-bs-dismiss="modal">Save</button>
</div>
</div>
</div>
Expand All @@ -209,14 +209,14 @@ <h1>Price data</h1>
</thead>
<tbody id ="markets-table"> </tbody>
</table>
<a class="btn btn-default" href="#" role="button" data-toggle="modal" data-target="#editMarketModal" id="button-add-market">
<a class="btn btn-default" href="#" role="button" data-bs-toggle="modal" data-bs-target="#editMarketModal" id="button-add-market">
<span class="fa fa-plus" aria-hidden="true"></span> Add
</a>
<div class="modal fade" id="editMarketModal" tabindex="-1" role="dialog" aria-labelledby="editMarketModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="editMarketModalLabel">
Expand All @@ -242,8 +242,8 @@ <h4 class="modal-title" id="editMarketModalLabel">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit-market-form-save" data-dismiss="modal">Save</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit-market-form-save" data-bs-dismiss="modal">Save</button>
</div>
</div>
</div>
Expand All @@ -258,8 +258,8 @@ <h4 class="modal-title text-center" id="removeMarketModalLabel">Are you sure you
<form id="remove-market-form">
<input type="hidden" name="id" id="remove-market-id"/>
</form>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" id="button-remove-market" data-dismiss="modal">Remove</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" id="button-remove-market" data-bs-dismiss="modal">Remove</button>
</div>
</div>
</div>
Expand All @@ -268,7 +268,7 @@ <h4 class="modal-title text-center" id="removeMarketModalLabel">Are you sure you
<div class="modal-dialog modal-lg" id="edit-market-data-set-modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="editMarketDataSetModalLabel">
Expand Down Expand Up @@ -316,8 +316,8 @@ <h4 class="modal-title" id="editMarketDataSetModalLabel">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit-market-data-set-form-save" data-dismiss="modal">Save</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit-market-data-set-form-save" data-bs-dismiss="modal">Save</button>
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions flexmeasures/ui/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -700,14 +700,14 @@
{% endblock copyright_notice %}

{% block about %}
<a href="#" data-toggle="modal" data-target="#About">About FlexMeasures</a>.
<a href="#" data-bs-toggle="modal" data-bs-target="#About">About FlexMeasures</a>.
<!-- The modal -->
<div class="modal fade" id="About" tabindex="-1" role="dialog" aria-labelledby="modalLabelLarge" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">

<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="modalLabelLarge">About FlexMeasures</h4>
Expand Down Expand Up @@ -769,15 +769,15 @@ <h4 class="modal-title" id="modalLabelLarge">About FlexMeasures</h4>
{% endblock about %}

{% block credits %}
<a href="#" data-toggle="modal" data-target="#Credits">Credits</a>.
<a href="#" data-bs-toggle="modal" data-bs-target="#Credits">Credits</a>.

<!-- The modal -->
<div class="modal fade" id="Credits" tabindex="-1" role="dialog" aria-labelledby="modalLabelLarge" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">

<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="modalLabelLarge">Credits</h4>
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/ui/templates/rq_dashboard/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<div class="modal-content">
<div class="modal-header">
<h3>Do you really want to <span id="confirmation-modal-action"></span>?</h3>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<button type="button" class="close" data-bs-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-footer">
<button type="button" id="confirmation-modal-no" class="btn">No</button>
Expand Down
5 changes: 2 additions & 3 deletions flexmeasures/utils/config_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ class Config(object):

MAPBOX_ACCESS_TOKEN: str | None = None

JSONIFY_PRETTYPRINT_REGULAR: bool = False

RQ_DASHBOARD_POLL_INTERVAL: int = (
3000 # Web interface poll period for updates in ms
)
Expand Down Expand Up @@ -130,6 +128,7 @@ class Config(object):
currencysymbolmap="5.1.0",
# todo: expand with other js versions used in FlexMeasures
)
FLEXMEASURES_JSON_COMPACT = False

FLEXMEASURES_FALLBACK_REDIRECT: bool = False

Expand Down Expand Up @@ -182,9 +181,9 @@ class DevelopmentConfig(Config):
SQLALCHEMY_ECHO: bool = False
PROPAGATE_EXCEPTIONS: bool = True
# PRESERVE_CONTEXT_ON_EXCEPTION: bool = False # might need this to make our transaction handling work in debug mode
JSONIFY_PRETTYPRINT_REGULAR: bool = True
FLEXMEASURES_MODE: str = "development"
FLEXMEASURES_PROFILE_REQUESTS: bool = True
FLEXMEASURES_JSON_COMPACT = False


class TestingConfig(Config):
Expand Down
9 changes: 8 additions & 1 deletion flexmeasures/utils/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,18 @@ def read_env_vars(app: Flask):
- Logging settings
- access tokens
- plugins (handled in plugin utils)
- json compactness
"""
for var in (
required
+ list(warnable.keys())
+ ["LOGGING_LEVEL", "MAPBOX_ACCESS_TOKEN", "SENTRY_SDN", "FLEXMEASURES_PLUGINS"]
+ [
"LOGGING_LEVEL",
"MAPBOX_ACCESS_TOKEN",
"SENTRY_SDN",
"FLEXMEASURES_PLUGINS",
"FLEXMEASURES_JSON_COMPACT",
]
):
app.config[var] = os.getenv(var, app.config.get(var, None))
# DEBUG in env can come in as a string ("True") so make sure we don't trip here
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/utils/flexmeasures_inflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def human_sorted(alist: list, attr: Any | None = None, reverse: bool = False):
# List of objects, to be sorted by attribute
sorted_list = sorted(
alist,
key=lambda k: natural_keys(str(getattr(k, attr))),
key=lambda k: natural_keys(str(getattr(k, str(attr)))),
reverse=reverse,
)
return sorted_list

0 comments on commit afa80da

Please sign in to comment.