Skip to content

Commit

Permalink
[req-change] Don't overwrite the organization of RadiusAccounting
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy committed May 10, 2024
1 parent c73ee88 commit 057a801
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tests/openwisp2/saml/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
9 changes: 2 additions & 7 deletions openwisp_radius/integrations/monitoring/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def post_save_radiusaccounting(
output_octets,
calling_station_id,
called_station_id,
time=None,
):
try:
registration_method = (
Expand Down Expand Up @@ -221,13 +222,6 @@ def post_save_radiusaccounting(
location_id = str(device.devicelocation.location_id)
else:
location_id = None
# Give preference to the organization_id of the device
# over RadiusAccounting object.
# This would also handle the case when SHARED_ACCOUNTING is enabled,
# and write the metric with the same organization_id as the device.
# If SHARED_ACCOUNTING is disabled, the organization_id of
# Device and RadiusAccounting would be same.
organization_id = str(device.organization_id)

metric, created = Metric._get_or_create(
configuration='radius_acc',
Expand All @@ -249,6 +243,7 @@ def post_save_radiusaccounting(
'output_octets': output_octets,
'username': sha1_hash(username),
},
time=time,
)
if not object_id:
# Adding a chart requires all parameters of extra_tags to be present.
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ force_grid_wrap=0
ignore = W605, W503, W504, E203
exclude = *.egg-info,
.git,
./tests/openwisp2/saml/*
./test-*
./tests/*settings*.py,
docs/*
max-line-length = 88

0 comments on commit 057a801

Please sign in to comment.