Skip to content

Commit 19170b9

Browse files
committed
Fix Device.organization.RelatedObjectDoesNotExist error
1 parent 3354ad7 commit 19170b9

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ jobs:
9494
GECKO_LOG: 1
9595

9696
- name: Show gecko web driver log on failures
97-
if: ${{ failure() }}
98-
run: cat geckodriver.log
97+
if: ${{ failure() && steps.deps.conclusion == 'success' }}
98+
run: |
99+
if [ -f geckodriver.log ]; then
100+
cat geckodriver.log
101+
else
102+
echo "geckodriver.log not found"
103+
fi
99104
100105
- name: Upload Coverage
101106
if: ${{ success() }}

openwisp_controller/config/base/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,9 @@ def clean_templates_org(cls, action, instance, pk_set, raw_data=None, **kwargs):
415415
pk_list = [template.pk for template in templates]
416416
templates = template_model.objects.filter(pk__in=pk_list)
417417
# looking for invalid templates
418-
organization = raw_data.get("organization", instance.device.organization)
418+
organization = raw_data.get("organization") or getattr(
419+
instance.device, "organization", None
420+
)
419421
invalids = (
420422
templates.exclude(organization=organization)
421423
.exclude(organization=None)

openwisp_controller/config/tests/test_admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,7 @@ def test_empty_device_form_with_config_inline(self):
22922292
# This reproduces the scenario where user clicks "Add another Configuration"
22932293
# and submits without filling device details
22942294
params = {
2295+
"organization": str(org.pk),
22952296
"config-0-backend": "netjsonconfig.OpenWrt",
22962297
"config-0-templates": str(template.pk),
22972298
"config-0-config": json.dumps({}),

0 commit comments

Comments
 (0)