修复应用不存在的问题

super_sign_new
youngS 4 years ago
parent 9f178f5c7f
commit 95a96e5dc5
  1. 9
      fir_ser/api/utils/serializer.py
  2. 5
      fir_ser/api/views/apps.py

@ -11,6 +11,11 @@ logger = logging.getLogger(__file__)
token_obj = DownloadToken() token_obj = DownloadToken()
def get_head_img(obj):
storage = Storage(obj)
return storage.get_download_url(obj.head_img)
class UserInfoSerializer(serializers.ModelSerializer): class UserInfoSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = models.UserInfo model = models.UserInfo
@ -21,10 +26,6 @@ class UserInfoSerializer(serializers.ModelSerializer):
head_img = serializers.SerializerMethodField() head_img = serializers.SerializerMethodField()
def get_head_img(self, obj):
storage = Storage(obj)
return storage.get_download_url(obj.head_img)
class AppsSerializer(serializers.ModelSerializer): class AppsSerializer(serializers.ModelSerializer):
class Meta: class Meta:

@ -99,15 +99,16 @@ class AppInfoView(APIView):
if apps_obj: if apps_obj:
app_serializer = AppsSerializer(apps_obj, context={"storage": Storage(request.user)}) app_serializer = AppsSerializer(apps_obj, context={"storage": Storage(request.user)})
res.data = app_serializer.data res.data = app_serializer.data
count = APPToDeveloper.objects.filter(app_id=apps_obj).count()
res.data["count"] = count
else: else:
logger.error("app_id:%s is not found in user:%s " % (app_id, request.user)) logger.error("app_id:%s is not found in user:%s " % (app_id, request.user))
res.msg = "未找到该应用" res.msg = "未找到该应用"
res.code = 1003 res.code = 1003
userserializer = UserInfoSerializer(request.user) userserializer = UserInfoSerializer(request.user)
res.userinfo = {} res.userinfo = {}
res.userinfo = userserializer.data res.userinfo = userserializer.data
count = APPToDeveloper.objects.filter(app_id=apps_obj).count()
res.data["count"] = count
return Response(res.dict) return Response(res.dict)

Loading…
Cancel
Save