Esempio n. 1
0
 def post(self, request, team_name, share_id, *args, **kwargs):
     try:
         share_record = share_service.get_service_share_record_by_ID(
             ID=share_id, team_name=team_name)
         if not share_record:
             result = general_message(404, "share record not found",
                                      "分享流程不存在,请退出重试")
             return Response(result, status=404)
         if share_record.is_success or share_record.step >= 3:
             result = general_message(400, "share record is complete",
                                      "分享流程已经完成,请重新进行分享")
             return Response(result, status=400)
         # 验证是否所有同步事件已完成
         count = ServiceShareRecordEvent.objects.filter(
             Q(record_id=share_id) & ~Q(event_status="success")).count()
         plugin_count = PluginShareRecordEvent.objects.filter(
             Q(record_id=share_id) & ~Q(event_status="success")).count()
         if count > 0 or plugin_count > 0:
             result = general_message(415, "share complete can not do",
                                      "应用或插件同步未全部完成")
             return Response(result, status=415)
         app_market_url = share_service.complete(self.tenant, self.user,
                                                 share_record)
         result = general_message(200,
                                  "share complete",
                                  "应用分享完成",
                                  bean=share_record.to_dict(),
                                  app_market_url=app_market_url)
     except ServiceHandleException as e:
         raise e
     except Exception as e:
         logger.exception(e)
         result = error_message(e.message)
     return Response(result, status=result["code"])
Esempio n. 2
0
 def post(self, request, team_name, share_id, *args, **kwargs):
     share_record = share_service.get_service_share_record_by_ID(
         ID=share_id, team_name=team_name)
     if not share_record:
         result = general_message(404, "share record not found",
                                  "分享流程不存在,请退出重试")
         return Response(result, status=404)
     if share_record.is_success or share_record.step >= 3:
         result = general_message(400, "share record is complete",
                                  "分享流程已经完成,请重新进行分享")
         return Response(result, status=400)
     # 验证是否所有同步事件已完成
     count = ServiceShareRecordEvent.objects.filter(
         Q(record_id=share_id) & ~Q(event_status="success")).count()
     if count > 0:
         result = general_message(415, "share complete can not do",
                                  "应用同步未全部完成")
         return Response(result, status=415)
     share_service.complete(share_record)
     result = general_message(200,
                              "share complete",
                              "应用分享完成",
                              bean=share_record.to_dict())
     return Response(result, status=200)