From cd98ee79edfbfdda24f60171799ba3bb0c78e5a2 Mon Sep 17 00:00:00 2001 From: Dmitry Novikov Date: Sat, 15 Sep 2018 11:45:11 +0300 Subject: [PATCH] FIX: if extra_data not None and type is 'str' than raised error. Fixed it. --- devapp/dev_types.py | 4 ++-- devapp/locale/ru/LC_MESSAGES/django.po | 3 +++ devapp/models.py | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/devapp/dev_types.py b/devapp/dev_types.py index 73a8772..c57dfde 100644 --- a/devapp/dev_types.py +++ b/devapp/dev_types.py @@ -478,8 +478,8 @@ class ZteOnuDevice(OnuDevice): return '\n'.join(i for i in r if i) def register_device(self, extra_data: Dict): - if extra_data is None: - raise DeviceConfigurationError('You have not info in extra_data field, please fill it in JSON') + if not extra_data: + raise DeviceConfigurationError(_('You have not info in extra_data field, please fill it in JSON')) device = self.db_instance ip = None if device.ip_address: diff --git a/devapp/locale/ru/LC_MESSAGES/django.po b/devapp/locale/ru/LC_MESSAGES/django.po index 58c79a6..6ab7c45 100644 --- a/devapp/locale/ru/LC_MESSAGES/django.po +++ b/devapp/locale/ru/LC_MESSAGES/django.po @@ -636,6 +636,9 @@ msgstr "Не правильный логин или пароль для дост msgid "Process locked by another process" msgstr "Процесс занят другой задачей, подождите чуть и попробуйте ещё" +msgid "You have not info in extra_data field, please fill it in JSON" +msgstr "Не заполнено поле 'Техническая информация', обратитесь к администратору" + #~ msgid "Device %(device_name)s is up" #~ msgstr "%(device_name)s в сети" diff --git a/devapp/models.py b/devapp/models.py index 405b2c1..4180b03 100644 --- a/devapp/models.py +++ b/devapp/models.py @@ -96,8 +96,8 @@ class Device(models.Model): def register_device(self): mng = self.get_manager_object() - if self.extra_data is None: - if self.parent_dev and self.parent_dev.extra_data is not None: + if not self.extra_data: + if self.parent_dev and self.parent_dev.extra_data: return mng.register_device(self.parent_dev.extra_data) return mng.register_device(self.extra_data)