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

Add dropdown for user to choose datetime format #140

Merged
merged 7 commits into from
Sep 23, 2024

Conversation

hmpf
Copy link
Collaborator

@hmpf hmpf commented Sep 20, 2024

Closes #100

This is based very closely on the theme-switching UX.

Set up: add "argus_htmx.context_processors.datetime_format_via_session" to the context_processors" in the TEMPLATES-setting in your localsettings-file, or change the argus_htmx-entry in EXTRA_APPS to:

  {
    "app_name": "argus_htmx",
    "urls": {
      "path": "",
      "urlpatterns_module": "argus_htmx.urls"
    },
    "context_processors": [
      "argus_htmx.context_processors.theme_via_session",
      "argus_htmx.context_processors.datetime_format_via_session"
    ],
    "middleware": {
      "argus_htmx.middleware.LoginRequiredMiddleware": "end"
    }
  },

One difference from the themes: in order to actually switch to the new format, the page is always refreshed. There might be redundant htmx-code for that reason.

There's a new optional setting ARGUS_FRONTEND_DATETIME_FORMAT that sets the default format. If not set i fall backs to using locale.

@hmpf hmpf added the polish Nice to have label Sep 20, 2024
@hmpf hmpf requested review from podliashanyk and a team September 20, 2024 12:09
@hmpf hmpf self-assigned this Sep 20, 2024
Copy link
Contributor

@elfjes elfjes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great :D

src/argus_htmx/dateformat/views.py Outdated Show resolved Hide resolved
src/argus_htmx/dateformat/views.py Outdated Show resolved Hide resolved
src/argus_htmx/dateformat/views.py Outdated Show resolved Hide resolved
@hmpf hmpf merged commit ac19253 into Uninett:main Sep 23, 2024
@hmpf hmpf deleted the userpref-dates branch September 23, 2024 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
polish Nice to have
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow user to override datetime format, to obey the Church of ISO
2 participants