factory/apps/am/models.py

47 lines
1.6 KiB
Python
Executable File

from django.db import models
from apps.system.models import Post, User
from apps.utils.models import CommonADModel, CommonBModel
# Create your models here.
class Area(CommonBModel):
"""
地图区域
"""
AREA_LEVEL_1 = 10
AREA_LEVEL_2 = 20
AREA_LEVEL_3 = 30
AREA_LEVEL_4 = 40
AREA_LEVEL_HOICES = (
(AREA_LEVEL_1, '办公'),
(AREA_LEVEL_2, '生产一般'),
(AREA_LEVEL_3, '生产重点'),
(AREA_LEVEL_4, '四级')
)
name = models.CharField('名称', max_length=20)
level = models.PositiveSmallIntegerField('区域等级')
sort_str = models.CharField('排序字符', max_length=12, default='1')
visitor_yes = models.BooleanField('准许访客人员', default=False)
remployee_yes = models.BooleanField('准许相关方人员', default=False)
employee_yes = models.BooleanField('准许全部员工', default=True)
posts_access = models.ManyToManyField(Post, through='am.access')
third_info = models.JSONField('三方信息', default=dict,
null=False, blank=True)
class Access(CommonADModel):
"""
岗位准入权限
"""
ACCESS_IN_YES = 10
ACCESS_IN_NO = 20
ACCESS_CHOICE = (
(ACCESS_IN_YES, '准入'),
(ACCESS_IN_NO, '禁入')
)
type = models.PositiveSmallIntegerField('准入类型', choices=ACCESS_CHOICE)
area = models.ForeignKey(Area, verbose_name='关联区域',
on_delete=models.CASCADE)
post = models.ForeignKey(Post, verbose_name='关联岗位',
on_delete=models.CASCADE)