feat: 增加commonadmodel
This commit is contained in:
parent
ca5f75177b
commit
46e9607942
|
|
@ -1,6 +1,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from utils.model import BaseModel
|
from utils.model import BaseModel
|
||||||
from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File
|
from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File, CommonADModel, CommonBDModel
|
||||||
from django.contrib.postgres.fields import JSONField
|
from django.contrib.postgres.fields import JSONField
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ class TAction(CommonAModel):
|
||||||
value_old = JSONField('原值', null=True, blank=True, default=dict)
|
value_old = JSONField('原值', null=True, blank=True, default=dict)
|
||||||
value_new = JSONField('新值', null=True, blank=True, default=dict)
|
value_new = JSONField('新值', null=True, blank=True, default=dict)
|
||||||
|
|
||||||
class Pgoal(CommonAModel):
|
class Pgoal(CommonADModel):
|
||||||
"""
|
"""
|
||||||
基础目标
|
基础目标
|
||||||
"""
|
"""
|
||||||
|
|
@ -137,7 +137,7 @@ class Pgoal(CommonAModel):
|
||||||
pgoal_4_file = models.ForeignKey(File, related_name='pgoal_4_file', on_delete=models.SET_NULL, null=True, blank=True)
|
pgoal_4_file = models.ForeignKey(File, related_name='pgoal_4_file', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
pgoal_5_file = models.ForeignKey(File, related_name='pgoal_5_file', on_delete=models.SET_NULL, null=True, blank=True)
|
pgoal_5_file = models.ForeignKey(File, related_name='pgoal_5_file', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
|
|
||||||
class Task2(CommonAModel):
|
class Task2(CommonADModel):
|
||||||
"""
|
"""
|
||||||
报送任务2
|
报送任务2
|
||||||
"""
|
"""
|
||||||
|
|
@ -163,7 +163,7 @@ class Task2(CommonAModel):
|
||||||
depts = models.ManyToManyField(Organization, verbose_name='执行公司', through='supervision.task2do', blank=True)
|
depts = models.ManyToManyField(Organization, verbose_name='执行公司', through='supervision.task2do', blank=True)
|
||||||
|
|
||||||
|
|
||||||
class Task2Do(CommonBModel):
|
class Task2Do(CommonBDModel):
|
||||||
"""任务执行情况
|
"""任务执行情况
|
||||||
"""
|
"""
|
||||||
task2 = models.ForeignKey(Task2, verbose_name='关联任务', on_delete=models.CASCADE, related_name='task2dept_task2')
|
task2 = models.ForeignKey(Task2, verbose_name='关联任务', on_delete=models.CASCADE, related_name='task2dept_task2')
|
||||||
|
|
@ -181,7 +181,7 @@ class Task2Do(CommonBModel):
|
||||||
num_oinspect = models.PositiveSmallIntegerField('外部检查数', null=True, blank=True)
|
num_oinspect = models.PositiveSmallIntegerField('外部检查数', null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class PgoalDept(CommonBModel):
|
class PgoalDept(CommonBDModel):
|
||||||
"""企业年度目标值
|
"""企业年度目标值
|
||||||
"""
|
"""
|
||||||
year = models.PositiveSmallIntegerField('年份')
|
year = models.PositiveSmallIntegerField('年份')
|
||||||
|
|
@ -196,7 +196,7 @@ class PgoalDept(CommonBModel):
|
||||||
task2do = models.ForeignKey('supervision.task2do', verbose_name= '关联任务执行', on_delete=models.SET_NULL, null=True, blank=True)
|
task2do = models.ForeignKey('supervision.task2do', verbose_name= '关联任务执行', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class Rc(CommonBModel):
|
class Rc(CommonBDModel):
|
||||||
"""报告或证书
|
"""报告或证书
|
||||||
"""
|
"""
|
||||||
etype_choices = (
|
etype_choices = (
|
||||||
|
|
@ -214,7 +214,7 @@ class Rc(CommonBModel):
|
||||||
remark = models.TextField('备注', null=True, blank=True)
|
remark = models.TextField('备注', null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class Complaint(CommonBModel):
|
class Complaint(CommonBDModel):
|
||||||
"""客户投诉
|
"""客户投诉
|
||||||
"""
|
"""
|
||||||
complainant = models.CharField('投诉人', max_length=100)
|
complainant = models.CharField('投诉人', max_length=100)
|
||||||
|
|
@ -225,7 +225,7 @@ class Complaint(CommonBModel):
|
||||||
task2do = models.ForeignKey('supervision.task2do', verbose_name= '关联任务执行', on_delete=models.SET_NULL, null=True, blank=True)
|
task2do = models.ForeignKey('supervision.task2do', verbose_name= '关联任务执行', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class Pt(CommonBModel):
|
class Pt(CommonBDModel):
|
||||||
"""能力验证
|
"""能力验证
|
||||||
"""
|
"""
|
||||||
pt_result_choices = (
|
pt_result_choices = (
|
||||||
|
|
@ -248,7 +248,7 @@ class Pt(CommonBModel):
|
||||||
task2do = models.ForeignKey('supervision.task2do', verbose_name= '关联任务执行', on_delete=models.SET_NULL, null=True, blank=True)
|
task2do = models.ForeignKey('supervision.task2do', verbose_name= '关联任务执行', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class Risk(CommonBModel):
|
class Risk(CommonBDModel):
|
||||||
"""风险识别
|
"""风险识别
|
||||||
"""
|
"""
|
||||||
risk_level_choices = (
|
risk_level_choices = (
|
||||||
|
|
@ -268,7 +268,7 @@ class Risk(CommonBModel):
|
||||||
task2do = models.ForeignKey('supervision.task2do', verbose_name= '关联任务执行', on_delete=models.SET_NULL, null=True, blank=True)
|
task2do = models.ForeignKey('supervision.task2do', verbose_name= '关联任务执行', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class Oinspect(CommonBModel):
|
class Oinspect(CommonBDModel):
|
||||||
"""外部检查
|
"""外部检查
|
||||||
"""
|
"""
|
||||||
oinspect_cate_choices = (
|
oinspect_cate_choices = (
|
||||||
|
|
|
||||||
|
|
@ -411,8 +411,6 @@ class PogalViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
||||||
return PgoalCreateUpdateSerializer
|
return PgoalCreateUpdateSerializer
|
||||||
return super().get_serializer_class()
|
return super().get_serializer_class()
|
||||||
|
|
||||||
def perform_destroy(self, instance):
|
|
||||||
instance.delete(soft=False)
|
|
||||||
|
|
||||||
class Task2ViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
class Task2ViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
||||||
perms_map = {'get': '*', 'post': 'task2',
|
perms_map = {'get': '*', 'post': 'task2',
|
||||||
|
|
@ -574,7 +572,7 @@ class Domixin:
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def perform_destroy(self, instance):
|
def perform_destroy(self, instance):
|
||||||
task2do = instance.task2do
|
task2do = instance.task2do
|
||||||
instance.delete(soft=False)
|
instance.delete()
|
||||||
self.countup_task2do(task2do)
|
self.countup_task2do(task2do)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,17 @@ class Dict(SoftModel):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
class CommonADModel(BaseModel):
|
||||||
|
"""
|
||||||
|
业务用基本表A,包含create_by, update_by字段,物理删除
|
||||||
|
"""
|
||||||
|
create_by = models.ForeignKey(
|
||||||
|
User, null=True, blank=True, on_delete=models.SET_NULL, verbose_name='创建人', related_name='%(class)s_create_by')
|
||||||
|
update_by = models.ForeignKey(
|
||||||
|
User, null=True, blank=True, on_delete=models.SET_NULL, verbose_name='最后编辑人', related_name='%(class)s_update_by')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
class CommonAModel(SoftModel):
|
class CommonAModel(SoftModel):
|
||||||
"""
|
"""
|
||||||
|
|
@ -194,6 +205,19 @@ class CommonBModel(SoftModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
class CommonBDModel(BaseModel):
|
||||||
|
"""
|
||||||
|
业务用基本表B,包含create_by, update_by, belong_dept字段,物理删除
|
||||||
|
"""
|
||||||
|
create_by = models.ForeignKey(
|
||||||
|
User, null=True, blank=True, on_delete=models.SET_NULL, verbose_name='创建人', related_name='%(class)s_create_by')
|
||||||
|
update_by = models.ForeignKey(
|
||||||
|
User, null=True, blank=True, on_delete=models.SET_NULL, verbose_name='最后编辑人', related_name='%(class)s_update_by')
|
||||||
|
belong_dept = models.ForeignKey(
|
||||||
|
Organization, null=True, blank=True, on_delete=models.SET_NULL, verbose_name='所属部门', related_name='%(class)s_belong_dept')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
class File(CommonAModel):
|
class File(CommonAModel):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue