jumpserver/apps/assets/models/group.py

33 lines
947 B
Python
Raw Normal View History

2016-12-20 16:43:52 +00:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from __future__ import unicode_literals
2017-11-23 06:08:01 +00:00
import uuid
2016-12-20 16:43:52 +00:00
from django.db import models
from django.utils.translation import ugettext_lazy as _
__all__ = ['AssetGroup']
class AssetGroup(models.Model):
2017-11-23 06:08:01 +00:00
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
2016-12-20 16:43:52 +00:00
name = models.CharField(max_length=64, unique=True, verbose_name=_('Name'))
2018-01-25 04:16:26 +00:00
created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by'))
2017-04-07 08:59:09 +00:00
date_created = models.DateTimeField(auto_now_add=True, null=True, verbose_name=_('Date created'))
2016-12-20 16:43:52 +00:00
comment = models.TextField(blank=True, verbose_name=_('Comment'))
def __str__(self):
2016-12-20 16:43:52 +00:00
return self.name
class Meta:
ordering = ['name']
2018-01-05 09:57:02 +00:00
verbose_name = _("Asset group")
2016-12-20 16:43:52 +00:00
@classmethod
def initial(cls):
asset_group = cls(name=_('Default'), comment=_('Default asset group'))
asset_group.save()