label_location bug

This commit is contained in:
曹前明 2022-06-30 10:32:11 +08:00
parent 69d687c8d0
commit d919578b79
3 changed files with 35 additions and 5 deletions

View File

@ -0,0 +1,30 @@
# Generated by Django 3.2.12 on 2022-06-30 02:25
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('hrm', '0002_auto_20220617_1124'),
('third', '0003_tlog'),
]
operations = [
migrations.AddField(
model_name='tdevice',
name='employee',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='hrm.employee', verbose_name='绑定人员'),
),
migrations.AddField(
model_name='tdevice',
name='obj_cate',
field=models.CharField(blank=True, help_text='people/...', max_length=20, null=True, verbose_name='绑定对象'),
),
migrations.AlterField(
model_name='tdevice',
name='code',
field=models.CharField(db_index=True, max_length=20, verbose_name='设备唯一标识'),
),
]

View File

@ -39,7 +39,7 @@ class TDevice(BaseModel):
verbose_name='所在区', null=True, blank=True)
areas = models.ManyToManyField(Area, verbose_name='覆盖区',
related_name='tareas')
obj_cate = models.CharField('绑定对象', max_length=20, help_text='people/...')
obj_cate = models.CharField('绑定对象', max_length=20, help_text='people/...', null=True, blank=True)
employee = models.ForeignKey(Employee, verbose_name='绑定人员', on_delete=models.CASCADE, null=True, blank=True)
is_clock = models.BooleanField('是否打卡设备', default=False)
third_info = models.JSONField('三方信息', default=dict,

View File

@ -67,21 +67,21 @@ class TDeviceViewSet(CustomGenericViewSet):
td.type = vdata['type']
td.area = vdata['area']
td.update_by = request.user
td.save()
td.areas.clear()
for i in vdata['areas']:
td.areas.add(i)
td.save()
td.areas.add(i)
else:
td = TDevice()
td.type = vdata['type']
td.code = vdata['code']
td.location = vdata['location']
td.area = vdata['area']
td.create_by = request.user
td.save()
td.areas.clear()
for i in vdata['areas']:
td.areas.add(i)
td.create_by = request.user
td.save()
return Response()
@action(methods=['post'], detail=False, perms_map={'post': 'tdevice:bind_area'},