File tree Expand file tree Collapse file tree 5 files changed +14
-17
lines changed
openwisp_controller/config Expand file tree Collapse file tree 5 files changed +14
-17
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ def __setmodels__(self):
65
65
self .org_limits = load_model ("config" , "OrganizationLimits" )
66
66
self .cert_model = load_model ("django_x509" , "Cert" )
67
67
self .org_model = load_model ("openwisp_users" , "Organization" )
68
- self .org_config_model = load_model ("config" , "OrganizationConfigSettings" )
69
68
70
69
def connect_signals (self ):
71
70
"""
Original file line number Diff line number Diff line change 14
14
DeviceGroup = load_model ("config" , "DeviceGroup" )
15
15
Organization = load_model ("openwisp_users" , "Organization" )
16
16
Cert = load_model ("django_x509" , "Cert" )
17
- WhoIsInfo = load_model ("config" , "WhoIsInfo" )
18
17
19
18
20
19
@receiver (
Original file line number Diff line number Diff line change @@ -72,11 +72,8 @@ def get_setting(option, default):
72
72
GEOIP_LICENSE_KEY = get_setting ("GEOIP_LICENSE_KEY" , None )
73
73
WHO_IS_ENABLED = get_setting ("WHO_IS_ENABLED" , False )
74
74
WHO_IS_CONFIGURED = GEOIP_ACCOUNT_ID and GEOIP_LICENSE_KEY
75
- if WHO_IS_ENABLED :
76
- try :
77
- assert WHO_IS_CONFIGURED
78
- except AssertionError :
79
- raise ImproperlyConfigured (
80
- "GEOIP_ACCOUNT_ID and GEOIP_LICENSE_KEY must be set "
81
- + "when WHO_IS_ENABLED is True."
82
- )
75
+ if WHO_IS_ENABLED and not WHO_IS_CONFIGURED :
76
+ raise ImproperlyConfigured (
77
+ "GEOIP_ACCOUNT_ID and GEOIP_LICENSE_KEY must be set "
78
+ + "when WHO_IS_ENABLED is True."
79
+ )
Original file line number Diff line number Diff line change 19
19
Vpn = load_model ("config" , "Vpn" )
20
20
Device = load_model ("config" , "Device" )
21
21
Notification = load_model ("openwisp_notifications" , "Notification" )
22
- OrganizationConfigSettings = load_model ("config" , "OrganizationConfigSettings" )
23
22
24
23
notification_qs = Notification .objects .all ()
25
24
Original file line number Diff line number Diff line change @@ -75,17 +75,20 @@ def update_last_ip(device, request):
75
75
if device .last_ip != ip :
76
76
device .last_ip = ip
77
77
update_fields .append ("last_ip" )
78
- # for cases of devices who do not have who_is record
79
- elif (
80
- app_settings .WHO_IS_CONFIGURED
81
- and not device .who_is_service .get_device_who_is_info ()
82
- ):
83
- device .who_is_service .trigger_who_is_lookup ()
84
78
if device .management_ip != management_ip :
85
79
device .management_ip = management_ip
86
80
update_fields .append ("management_ip" )
87
81
if update_fields :
88
82
device .save (update_fields = update_fields )
83
+ # When update fields are present then save() will run the WhoIs
84
+ # lookup. But if there are no update fields, we still want to
85
+ # trigger the WhoIs lookup if there is no record for the device's
86
+ # last_ip.
87
+ elif (
88
+ app_settings .WHO_IS_CONFIGURED
89
+ and not device .who_is_service .get_device_who_is_info ()
90
+ ):
91
+ device .who_is_service .trigger_who_is_lookup ()
89
92
90
93
return bool (update_fields )
91
94
You can’t perform that action at this time.
0 commit comments