Skip to content

Conversation

@Eeshu-Yadav
Copy link
Contributor

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Use Django locale for date formatting in device page RADIUS sessions tab JS, matching Django admin and localization settings.

Fixes #662

@Eeshu-Yadav Eeshu-Yadav force-pushed the issues/662-radius_sessions_issue branch from 183d10f to aa60f50 Compare December 26, 2025 10:29
…nwisp#662

Use Django locale for date formatting in device page RADIUS sessions tab JS, matching Django admin and localization settings.

Fixes openwisp#662
@Eeshu-Yadav Eeshu-Yadav force-pushed the issues/662-radius_sessions_issue branch from aa60f50 to 830d07e Compare December 26, 2025 10:31
Copy link
Member

@pandafy pandafy left a comment

Choose a reason for hiding this comment

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

I don't think it is working as expected.

The created/modified timestamp of the Device is in different format from the "Start Time" of the RADIUS session

Check the formatting of "Created" and "Modified" datetime of the Device object:
Image

Check the formatting of "Start time" field in the "RADIUS Sessions" tab:

Image

Check if something like this will solve the problem:

https://github.com/openwisp/openwisp-controller/blob/115cd9ac1b418204bdb704c02af308569e19e3fd/openwisp_controller/connection/static/connection/js/commands.js#L631-L638

@coveralls
Copy link

Coverage Status

coverage: 97.269%. remained the same
when pulling e44b632 on Eeshu-Yadav:issues/662-radius_sessions_issue
into 4053a46 on openwisp:master.

@stktyagi
Copy link
Member

stktyagi commented Dec 30, 2025

@stktyagi i am working on that as suggested by @pandafy ,

Hey @Eeshu-Yadav, sorry for any confusion. I didn’t start working on this. Since the CI failure was fixed, I just updated the branch earlier to keep it in sync and just as a check.

@Eeshu-Yadav
Copy link
Contributor Author

@stktyagi i am working on that as suggested by @pandafy ,

Hey @Eeshu-Yadav, sorry for any confusion. I didn’t start working on this. Since the CI failure was fixed, I just updated the branch earlier to keep it in sync and just as a check.

i though first , yaa ci failed previously , i thought , i will fix in next commit

@nemesifier
Copy link
Member

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

The pull request modifies the date-time formatting logic in the RADIUS sessions tab to align with Django's localization framework. The change replaces a plain locale string formatting with an explicit locale derived from djangoLocale and a detailed Intl.DateTimeFormat options object specifying numeric year, short month, numeric day, and 24-hour time formatting. This ensures consistent date-time display across the application.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: implementing consistent datetime formatting in the RADIUS sessions tab using the monitoring JS module, directly addressing issue #662.
Description check ✅ Passed The PR description covers key checklist items and provides context about using Django locale for date formatting, though it notes that test cases and documentation updates were not completed.
Linked Issues check ✅ Passed The code change implements Django locale-based date formatting with explicit locale conversion and comprehensive formatting options, directly addressing the objective in #662 to align frontend datetime display with Django's localization framework.
Out of Scope Changes check ✅ Passed The change is focused on a single JavaScript file modifying date formatting logic, which is directly scoped to the stated objective of fixing inconsistent datetime formats in the RADIUS sessions tab.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js`:
- Around line 23-31: The options object in device-change.js contains hour12:
false which forces 24-hour time; remove the hour12 property from the options
constant so toLocaleString() can honor the user's locale preferences (locate and
edit the options declaration in device-change.js where the options object with
year/month/day/hour/minute/second is defined and delete the hour12: false
entry).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4053a46 and e44b632.

📒 Files selected for processing (1)
  • openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js
🔇 Additional comments (1)
openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js (1)

22-22: No guard needed; djangoLocale is always defined.

The template explicitly sets const djangoLocale = "{{ LANGUAGE_CODE }}" (line 39 of change_form.html) before this script loads, so djangoLocale is guaranteed to exist. A guard is unnecessary.

The concern about replace("_", "-") replacing only the first underscore is technically valid but low-impact: Django's LANGUAGE_CODE setting uses hyphens by convention (e.g., "en-gb"), and Intl.DateTimeFormat gracefully falls back if an invalid locale string is provided.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +23 to +31
const options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Find the file mentioned in the review
find . -name "device-change.js" -type f

Repository: openwisp/openwisp-radius

Length of output: 154


🏁 Script executed:

#!/bin/bash

# Let's also check the structure of the monitoring module
find . -path "*monitoring/static/radius-monitoring*" -type f | head -20

Repository: openwisp/openwisp-radius

Length of output: 243


🏁 Script executed:

cat -n ./openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js

Repository: openwisp/openwisp-radius

Length of output: 5156


🏁 Script executed:

#!/bin/bash

# Search for djangoLocale definition/usage
rg "djangoLocale" --type js

# Search for where this JS file is included/rendered
rg "device-change.js" 

# Look for locale configuration in Django templates
fd -e "html" -e "py" | xargs rg -l "djangoLocale" 2>/dev/null | head -10

Repository: openwisp/openwisp-radius

Length of output: 412


🏁 Script executed:

cat -n ./openwisp_radius/integrations/monitoring/templates/admin/config/radius-monitoring/device/change_form.html

Repository: openwisp/openwisp-radius

Length of output: 2286


🏁 Script executed:

#!/bin/bash

# Search for other toLocaleString usages
rg "toLocaleString" 

# Search for hour12 settings in the codebase
rg "hour12"

# Check the admin.py for any additional context
head -50 ./openwisp_radius/integrations/monitoring/admin.py

Repository: openwisp/openwisp-radius

Length of output: 1543


Remove hour12: false to respect locale preferences.

hour12: false forces 24-hour format regardless of locale, preventing Django's locale setting from taking full effect. Different locales have different time conventions (e.g., en-US prefers 12-hour, en-GB prefers 24-hour). Removing this option allows toLocaleString() to use the locale's natural preference.

🔧 Proposed fix
       const options = {
         year: "numeric",
         month: "short",
         day: "numeric",
         hour: "2-digit",
         minute: "2-digit",
         second: "2-digit",
-        hour12: false,
       };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
};
const options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
};
🤖 Prompt for AI Agents
In
`@openwisp_radius/integrations/monitoring/static/radius-monitoring/js/device-change.js`
around lines 23 - 31, The options object in device-change.js contains hour12:
false which forces 24-hour time; remove the hour12 property from the options
constant so toLocaleString() can honor the user's locale preferences (locate and
edit the options declaration in device-change.js where the options object with
year/month/day/hour/minute/second is defined and delete the hour12: false
entry).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

[bug] RADIUS sessions tab in device page uses inconsistent date time format

5 participants