Skip to content

Commit

Permalink
refactor: cr 调整
Browse files Browse the repository at this point in the history
  • Loading branch information
neronkl committed Nov 13, 2023
1 parent c30cfe9 commit 5c2de7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/bk-user/bkuser/apis/web/tenant_setting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ def delete(self, request, *args, **kwargs):
class TenantUserValidityPeriodConfigRetrieveUpdateApi(
ExcludePatchAPIViewMixin, CurrentUserTenantMixin, generics.RetrieveUpdateAPIView
):
queryset = TenantUserValidityPeriodConfig.objects.all()

def get_object(self):
queryset = self.filter_queryset(self.get_queryset())
queryset = TenantUserValidityPeriodConfig.objects.all()
filter_kwargs = {"tenant_id": self.get_current_tenant_id()}
return get_object_or_404(queryset, **filter_kwargs)

Expand All @@ -133,7 +131,7 @@ def get_object(self):
)
def get(self, request, *args, **kwargs):
instance = self.get_object()
return Response(TenantUserValidityPeriodConfigOutputSLZ(instance).data)
return Response(TenantUserValidityPeriodConfigOutputSLZ(instance=instance).data)

@swagger_auto_schema(
tags=["tenant-setting"],
Expand Down
7 changes: 6 additions & 1 deletion src/bk-user/bkuser/apps/tenant/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ def send(self, users: List[TenantUser]) -> None:
self._send_notifications(u)
# TODO 细化异常处理
except Exception:
logger.exception("send notification failed")
logger.exception(
"send notification failed, tenant: %s, scene:%s, tenant_user_id: %s",
self.tenant_id,
self.scene,
u.id,
)

def _get_templates_with_scene(self, scene: NotificationScene) -> List[NotificationTemplate]:
"""根据场景以及插件配置中设置的通知方式,获取需要发送通知的模板"""
Expand Down

0 comments on commit 5c2de7e

Please sign in to comment.