From 792908eb359048d4ab9ba1178a4f02cd1685e105 Mon Sep 17 00:00:00 2001 From: wangyong <864072399@qq.com> Date: Fri, 16 Sep 2016 17:23:23 +0800 Subject: [PATCH] asset add --- apps/assets/models.py | 13 ++++++++----- apps/assets/views.py | 4 +++- apps/locale/zh/LC_MESSAGES/django.po | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/assets/models.py b/apps/assets/models.py index 36ca9bffd..8ff80d824 100644 --- a/apps/assets/models.py +++ b/apps/assets/models.py @@ -117,11 +117,14 @@ class Asset(models.Model): os = models.CharField(max_length=128, blank=True, verbose_name=_('OS')) cabinet_no = models.CharField(max_length=32, blank=True, verbose_name=_('Cabinet number')) cabinet_pos = models.IntegerField(null=True, blank=True, verbose_name=_('Cabinet position')) - number = models.CharField(max_length=32, blank=True, unique=True, verbose_name=_('Asset number')) - status = models.ForeignKey(AssetExtend, null=True, blank=True, related_name="asset_status_extend", verbose_name=_('Asset status')) - type = models.ForeignKey(AssetExtend, null=True, blank=True, related_name="asset_type_extend", verbose_name=_('Asset type')) - env = models.ForeignKey(AssetExtend, null=True, blank=True, related_name="asset_env_extend", verbose_name=_('Asset environment')) - sn = models.CharField(max_length=128, blank=True, unique=True, verbose_name=_('Serial number')) + number = models.CharField(max_length=32, blank=True, verbose_name=_('Asset number')) + status = models.ForeignKey(AssetExtend, null=True, blank=True, + related_name="asset_status_extend", verbose_name=_('Asset status')) + type = models.ForeignKey(AssetExtend, null=True, blank=True, + related_name="asset_type_extend", verbose_name=_('Asset type')) + env = models.ForeignKey(AssetExtend, null=True, blank=True, + related_name="asset_env_extend", verbose_name=_('Asset environment')) + sn = models.CharField(max_length=128, blank=True, verbose_name=_('Serial number')) created_by = models.CharField(max_length=32, blank=True, verbose_name=_('Created by')) is_active = models.BooleanField(default=True, verbose_name=_('Is active')) date_added = models.DateTimeField(auto_now=True, null=True, verbose_name=_('Date added')) diff --git a/apps/assets/views.py b/apps/assets/views.py index efe698f13..23abf1867 100644 --- a/apps/assets/views.py +++ b/apps/assets/views.py @@ -23,7 +23,9 @@ class AssetCreateView(CreateView): success_url = reverse_lazy('assets:asset-list') def form_invalid(self, form): - print(form.errors) + asset = form.save(commit=False) + asset.is_active = 1 + asset.save() return super(AssetCreateView, self).form_invalid(form) diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index c405456f4..3a1181aca 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -152,7 +152,7 @@ msgstr "远控卡IP" #: assets/models.py:104 msgid "Hostname" -msgstr "用户名" +msgstr "主机名" #: assets/models.py:105 msgid "Port"