mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
from django.db import models
|
|
from django.utils.translation import ugettext_lazy as _
|
|
from django.core.validators import MinValueValidator, MaxValueValidator
|
|
from common.mixins import CommonModelMixin
|
|
|
|
|
|
__all__ = ['BaseACL', 'BaseACLQuerySet']
|
|
|
|
|
|
class BaseACLQuerySet(models.QuerySet):
|
|
def active(self):
|
|
return self.filter(is_active=True)
|
|
|
|
def inactive(self):
|
|
return self.filter(is_active=False)
|
|
|
|
def valid(self):
|
|
return self.active()
|
|
|
|
def invalid(self):
|
|
return self.inactive()
|
|
|
|
|
|
class BaseACL(CommonModelMixin):
|
|
name = models.CharField(max_length=128, verbose_name=_('Name'))
|
|
priority = models.IntegerField(
|
|
default=50, verbose_name=_("Priority"),
|
|
help_text=_("1-100, the lower the value will be match first"),
|
|
validators=[MinValueValidator(1), MaxValueValidator(100)]
|
|
)
|
|
is_active = models.BooleanField(default=True, verbose_name=_("Active"))
|
|
comment = models.TextField(default='', blank=True, verbose_name=_('Comment'))
|
|
|
|
class Meta:
|
|
abstract = True
|