asset add

pull/530/head
wangyong 2016-09-16 17:23:23 +08:00
parent bc232c4f77
commit 792908eb35
3 changed files with 12 additions and 7 deletions

View File

@ -117,11 +117,14 @@ class Asset(models.Model):
os = models.CharField(max_length=128, blank=True, verbose_name=_('OS')) 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_no = models.CharField(max_length=32, blank=True, verbose_name=_('Cabinet number'))
cabinet_pos = models.IntegerField(null=True, blank=True, verbose_name=_('Cabinet position')) 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')) 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')) status = models.ForeignKey(AssetExtend, null=True, blank=True,
type = models.ForeignKey(AssetExtend, null=True, blank=True, related_name="asset_type_extend", verbose_name=_('Asset type')) related_name="asset_status_extend", verbose_name=_('Asset status'))
env = models.ForeignKey(AssetExtend, null=True, blank=True, related_name="asset_env_extend", verbose_name=_('Asset environment')) type = models.ForeignKey(AssetExtend, null=True, blank=True,
sn = models.CharField(max_length=128, blank=True, unique=True, verbose_name=_('Serial number')) 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')) created_by = models.CharField(max_length=32, blank=True, verbose_name=_('Created by'))
is_active = models.BooleanField(default=True, verbose_name=_('Is active')) is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
date_added = models.DateTimeField(auto_now=True, null=True, verbose_name=_('Date added')) date_added = models.DateTimeField(auto_now=True, null=True, verbose_name=_('Date added'))

View File

@ -23,7 +23,9 @@ class AssetCreateView(CreateView):
success_url = reverse_lazy('assets:asset-list') success_url = reverse_lazy('assets:asset-list')
def form_invalid(self, form): 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) return super(AssetCreateView, self).form_invalid(form)

View File

@ -152,7 +152,7 @@ msgstr "远控卡IP"
#: assets/models.py:104 #: assets/models.py:104
msgid "Hostname" msgid "Hostname"
msgstr "用户名" msgstr "主机名"
#: assets/models.py:105 #: assets/models.py:105
msgid "Port" msgid "Port"