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

Non-UTC default timezone for new users #190

Merged
merged 3 commits into from Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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