File tree Expand file tree Collapse file tree 5 files changed +33
-2
lines changed
openwisp_controller/config
tests/openwisp2/sample_config/migrations Expand file tree Collapse file tree 5 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -563,6 +563,24 @@ their hardware ID instead of their name.
563
563
564
564
If you still want to reference devices by their name, set this to ``False ``.
565
565
566
+ ``OPENWISP_CONTROLLER_DEVICE_VERBOSE_NAME ``
567
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
568
+
569
+ +--------------+----------------------------+
570
+ | **type **: | ``tuple `` |
571
+ +--------------+----------------------------+
572
+ | **default **: | ``('Device', 'Devices') `` |
573
+ +--------------+----------------------------+
574
+
575
+ Defines the ``verbose_name `` attribute of the ``Device `` model, which is displayed in the
576
+ admin site. The first and second element of the tuple represent the singular and plural forms.
577
+
578
+ For example, if we want to change the verbose name to "Hotspot", we could write:
579
+
580
+ .. code-block :: python
581
+
582
+ OPENWISP_CONTROLLER_DEVICE_VERBOSE_NAME = (' Hotspot' , ' Hotspots' )
583
+
566
584
Default Alerts / Notifications
567
585
------------------------------
568
586
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ class Meta:
83
83
('hardware_id' , 'organization' ),
84
84
)
85
85
abstract = True
86
+ verbose_name = app_settings .DEVICE_VERBOSE_NAME [0 ]
87
+ verbose_name_plural = app_settings .DEVICE_VERBOSE_NAME [1 ]
86
88
87
89
def __str__ (self ):
88
90
return (
Original file line number Diff line number Diff line change 12
12
import openwisp_utils .base
13
13
import openwisp_utils .utils
14
14
15
+ from .. import settings as app_settings
16
+
15
17
16
18
class Migration (migrations .Migration ):
17
19
@@ -114,7 +116,11 @@ class Migration(migrations.Migration):
114
116
),
115
117
),
116
118
],
117
- options = {'abstract' : False },
119
+ options = {
120
+ 'abstract' : False ,
121
+ 'verbose_name' : app_settings .DEVICE_VERBOSE_NAME [0 ],
122
+ 'verbose_name_plural' : app_settings .DEVICE_VERBOSE_NAME [1 ],
123
+ },
118
124
),
119
125
migrations .AddField (
120
126
model_name = 'config' ,
Original file line number Diff line number Diff line change @@ -52,3 +52,6 @@ def get_settings_value(option, default):
52
52
}
53
53
HARDWARE_ID_OPTIONS .update (get_settings_value ('HARDWARE_ID_OPTIONS' , {}))
54
54
HARDWARE_ID_AS_NAME = get_settings_value ('HARDWARE_ID_AS_NAME' , True )
55
+ DEVICE_VERBOSE_NAME = get_settings_value (
56
+ 'DEVICE_VERBOSE_NAME' , (_ ('Device' ), _ ('Devices' ))
57
+ )
Original file line number Diff line number Diff line change 1
1
# Generated by Django 3.0.7 on 2020-06-27 11:16
2
-
3
2
import collections
4
3
import re
5
4
import uuid
17
16
import openwisp_users .mixins
18
17
import openwisp_utils .base
19
18
import openwisp_utils .utils
19
+ from openwisp_controller .config import settings as app_settings
20
20
21
21
22
22
class Migration (migrations .Migration ):
@@ -736,6 +736,8 @@ class Migration(migrations.Migration):
736
736
('hardware_id' , 'organization' ),
737
737
('name' , 'organization' ),
738
738
},
739
+ 'verbose_name' : app_settings .DEVICE_VERBOSE_NAME [0 ],
740
+ 'verbose_name_plural' : app_settings .DEVICE_VERBOSE_NAME [1 ],
739
741
},
740
742
bases = (openwisp_users .mixins .ValidateOrgMixin , models .Model ),
741
743
),
You can’t perform that action at this time.
0 commit comments