|
@@ -26,8 +26,7 @@ class EmployeeSerializer(serializers.ModelSerializer):
|
|
|
raise CustomError(u'已存在一个平台管理员,禁止操作!')
|
|
|
#标准版 限制检修人人数为2
|
|
|
tenant = self.context['request'].user.employee.tenant
|
|
|
- employees = Employee.objects.filter(tenant=tenant, status=Employee.ENABLE,type=Employee.EMPLOYEE).count()
|
|
|
- if int(self.initial_data['type']) == Employee.EMPLOYEE and employees >= 2 and tenant.edition == Tenant.EDITION_1:
|
|
|
+ if int(self.initial_data['type']) == Employee.EMPLOYEE and Employee.checkEmployee(self.context['request'].user.employee.tenant):
|
|
|
raise CustomError(u'当前版本,仅能添加2个检修人。如有需要,请升级到更高版本!')
|
|
|
# 判断用户是否已经注册登陆过
|
|
|
password = None
|
|
@@ -56,8 +55,7 @@ class EmployeeSerializer(serializers.ModelSerializer):
|
|
|
if int(self.initial_data['type']) == Employee.SUPER and Employee.checkSuper(instance.tenant, instance.id):
|
|
|
raise CustomError(u'已存在一个平台管理员,禁止操作!')
|
|
|
# 标准版 限制检修人人数为2
|
|
|
- employees = Employee.objects.filter(tenant=instance.tenant, status=Employee.ENABLE,type=Employee.EMPLOYEE).count()
|
|
|
- if int(self.initial_data['type']) == Employee.EMPLOYEE and employees >= 2 and instance.tenant.edition == Tenant.EDITION_1:
|
|
|
+ if int(self.initial_data['type']) == Employee.EMPLOYEE and Employee.checkEmployee(instance.tenant, instance.id):
|
|
|
raise CustomError(u'当前版本,仅能添加2个检修人。如有需要,请升级到更高版本!')
|
|
|
|
|
|
username = self.initial_data['tel']
|