|
@@ -1,5 +1,5 @@
|
|
# coding=utf-8
|
|
# coding=utf-8
|
|
-
|
|
|
|
|
|
+from django.conf import settings
|
|
from utils.custom_modelviewset import CustomModelViewSet
|
|
from utils.custom_modelviewset import CustomModelViewSet
|
|
from utils.permission import IsAdministratorUser
|
|
from utils.permission import IsAdministratorUser
|
|
from apps.tenant.models import Tenant
|
|
from apps.tenant.models import Tenant
|
|
@@ -11,7 +11,7 @@ from django.db import transaction
|
|
from utils import response_ok
|
|
from utils import response_ok
|
|
from utils.exceptions import CustomError
|
|
from utils.exceptions import CustomError
|
|
from rest_framework.decorators import action
|
|
from rest_framework.decorators import action
|
|
-from apps.WechatTp.models import WechatTp
|
|
|
|
|
|
+from utils import response_ok, response_error
|
|
|
|
|
|
class TenantViewSet(CustomModelViewSet):
|
|
class TenantViewSet(CustomModelViewSet):
|
|
permission_classes = [IsAdministratorUser, ]
|
|
permission_classes = [IsAdministratorUser, ]
|
|
@@ -41,9 +41,23 @@ class TenantViewSet(CustomModelViewSet):
|
|
return response_ok()
|
|
return response_ok()
|
|
|
|
|
|
@action(methods=['post'], detail=True)
|
|
@action(methods=['post'], detail=True)
|
|
- def bind_wechat_tp(self, request, pk):
|
|
|
|
- tp = WechatTp.getDefault()
|
|
|
|
- if not tp:
|
|
|
|
- raise CustomError(u'未找到微信第三方平台!')
|
|
|
|
- url = tp.getAuthUrl(pk)
|
|
|
|
- return response_ok(url)
|
|
|
|
|
|
+ def check(self, request, pk):
|
|
|
|
+ # 审核
|
|
|
|
+ status = request.POST.get('status')
|
|
|
|
+ reject_reason = request.POST.get('reason')
|
|
|
|
+ try:
|
|
|
|
+ with transaction.atomic():
|
|
|
|
+ instance = Tenant.getById(pk)
|
|
|
|
+ # 审核
|
|
|
|
+ if instance.status > settings.DEFAULT:
|
|
|
|
+ raise CustomError('当前租户已审核!')
|
|
|
|
+
|
|
|
|
+ instance.status = status
|
|
|
|
+ instance.reject_reason = reject_reason
|
|
|
|
+ instance.save()
|
|
|
|
+ BizLog.objects.addnew(None, request.user, BizLog.INSERT, u'审核租户[%s]状态为[%s],id=%d' % (instance.company_name, status, instance.id))
|
|
|
|
+ except CustomError as e:
|
|
|
|
+ return response_error(e.get_error_msg())
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return response_error(str(e))
|
|
|
|
+ return response_ok('审核完成!')
|