Skip to content

Commit

Permalink
Non-UTC default timezone for new users (#190)
Browse files Browse the repository at this point in the history
Use the FLEXMEASURES_TIMEZONE config setting as a more sensible default for new users.


* Create draft PR for #189

* Apply default user timezone from FLEXMEASURES_TIMEZONE config setting

* Changelog entry

Co-authored-by: Flix6x <Flix6x@users.noreply.github.com>
Co-authored-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
3 people committed Sep 23, 2021
1 parent 49edd62 commit 356d56a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -20,6 +20,7 @@ Bugfixes
Infrastructure / Support
----------------------
* FlexMeasures plugins can be Python packages now. We provide `a cookie-cutter template <https://github.com/SeitaBV/flexmeasures-plugin-template>`_ for this approach. [see `PR #182 <http://www.github.com/SeitaBV/flexmeasures/pull/182>`_]
* Set default timezone for new users using the FLEXMEASURES_TIMEZONE config setting [see `PR #190 <http://www.github.com/SeitaBV/flexmeasures/pull/190>`_]


v0.6.1 | September XX, 2021
Expand Down
14 changes: 11 additions & 3 deletions flexmeasures/data/scripts/cli_tasks/data_add.py
Expand Up @@ -99,18 +99,26 @@ def new_account(name: str, roles: List[str]):
@click.option("--roles", help="e.g. anonymous,Prosumer,CPO")
@click.option(
"--timezone",
default="UTC",
help="timezone as string, e.g. 'UTC' or 'Europe/Amsterdam'",
help="timezone as string, e.g. 'UTC' or 'Europe/Amsterdam' (defaults to FLEXMEASURES_TIMEZONE config setting)",
)
def new_user(
username: str, email: str, account_id: int, roles: List[str], timezone: str
username: str,
email: str,
account_id: int,
roles: List[str],
timezone: Optional[str],
):
"""
Create a FlexMeasures user.
The `users create` task from Flask Security Too is too simple for us.
Use this to add email, timezone and roles.
"""
if timezone is None:
timezone = app.config.get("FLEXMEASURES_TIMEZONE")
print(
f"Setting user timezone to {timezone} (taken from FLEXMEASURES_TIMEZONE config setting)..."
)
try:
pytz.timezone(timezone)
except pytz.UnknownTimeZoneError:
Expand Down

0 comments on commit 356d56a

Please sign in to comment.