feat(setting): Enable super admin to set ALL device models as global
sets is_global=true and creates device models in global organization !12 closes #29
This commit is contained in:
@ -8,7 +8,7 @@ from access.models import TenancyObject
|
||||
from core.mixin.history_save import SaveHistory
|
||||
from core.models.manufacturer import Manufacturer
|
||||
|
||||
|
||||
from settings.models.app_settings import AppSettings
|
||||
|
||||
class DeviceModel(DeviceCommonFieldsName, SaveHistory):
|
||||
|
||||
@ -28,6 +28,17 @@ class DeviceModel(DeviceCommonFieldsName, SaveHistory):
|
||||
blank= True
|
||||
)
|
||||
|
||||
|
||||
def clean(self):
|
||||
|
||||
app_settings = AppSettings.objects.get(owner_organization=None)
|
||||
|
||||
if app_settings.device_model_is_global:
|
||||
|
||||
self.organization = app_settings.global_organization
|
||||
self.is_global = app_settings.device_model_is_global
|
||||
|
||||
|
||||
def __str__(self):
|
||||
|
||||
return self.manufacturer.name + ' ' + self.name
|
||||
|
Reference in New Issue
Block a user