修复关联应用,修改操作,未清理缓存导致异常

super_signature
nineven 5 years ago
parent a1167f6303
commit c5ddfd5e33
  1. 5
      fir_ser/api/utils/app/apputils.py
  2. 6
      fir_ser/api/utils/app/supersignutils.py
  3. 3
      fir_ser/api/utils/serializer.py
  4. 17
      fir_ser/api/utils/storage/caches.py
  5. 40
      fir_ser/api/views/apps.py
  6. 5
      fir_ser/api/views/download.py
  7. 24
      fir_ser/api/views/login.py
  8. 6
      fir_ser/api/views/logout.py
  9. 1
      fir_ser/api/views/receiveudids.py
  10. 13
      fir_ser/api/views/storage.py
  11. 24
      fir_ser/api/views/supersign.py
  12. 12
      fir_ser/api/views/uploads.py

@ -59,7 +59,8 @@ def make_resigned(bin_url, img_url, bundle_id, app_version, name):
</array> </array>
</dict> </dict>
</plist>""" % (bin_url, img_url, img_url, bundle_id, app_version, name) </plist>""" % (bin_url, img_url, img_url, bundle_id, app_version, name)
logger.info("make_resigned bin_url %s ,img_url %s, img_url %s, bundle_id %s, app_version %s, name %s" % (
bin_url, img_url, img_url, bundle_id, app_version, name))
return ios_plist_tem return ios_plist_tem
@ -135,7 +136,7 @@ def SaveAppInfos(app_file_name, user_obj, appinfo, bundle_id, app_img, short, si
else: else:
try: try:
newapp = False newapp = False
del_cache_response_by_short(appmobj.short, appmobj.app_id) del_cache_response_by_short(appmobj.app_id)
appmobj.short = short appmobj.short = short
appmobj.name = appinfo["labelname"] appmobj.name = appinfo["labelname"]
appmobj.bundle_id = bundle_id appmobj.bundle_id = bundle_id

@ -172,7 +172,9 @@ class IosUtils(object):
if apptodev_obj: if apptodev_obj:
release_obj = AppReleaseInfo.objects.filter(app_id=self.app_obj, is_master=True).first() release_obj = AppReleaseInfo.objects.filter(app_id=self.app_obj, is_master=True).first()
if release_obj.release_id == apptodev_obj.release_file: if release_obj.release_id == apptodev_obj.release_file:
logger.info("udid %s exists app_id %s" % (self.udid_info.get('udid'), self.app_obj))
return return
logger.info("udid %s not exists app_id %s ,need sign" % (self.udid_info.get('udid'), self.app_obj))
self.download_profile() self.download_profile()
file_format_path_name = file_format_path(self.user_obj, self.auth) file_format_path_name = file_format_path(self.user_obj, self.auth)
@ -200,6 +202,8 @@ class IosUtils(object):
if appsupersign_obj.count() == 0: if appsupersign_obj.count() == 0:
developer_obj = self.developer_obj developer_obj = self.developer_obj
developer_obj.use_number = developer_obj.use_number + 1 developer_obj.use_number = developer_obj.use_number + 1
logger.info("developer %s use_number+1 now %s udid %s app_id %s" % (
developer_obj, developer_obj.use_number, self.udid_info.get('udid'), self.app_obj))
developer_obj.save() developer_obj.save()
if not appsupersign_obj.filter(app_id=self.app_obj, user_id=self.user_obj).first(): if not appsupersign_obj.filter(app_id=self.app_obj, user_id=self.user_obj).first():
@ -208,7 +212,7 @@ class IosUtils(object):
udid=AppUDID.objects.filter(app_id=self.app_obj, udid=AppUDID.objects.filter(app_id=self.app_obj,
udid=self.udid_info.get('udid')).first()) udid=self.udid_info.get('udid')).first())
del_cache_response_by_short(self.app_obj.short, self.app_obj.app_id, udid=self.udid_info.get('udid')) del_cache_response_by_short(self.app_obj.app_id, udid=self.udid_info.get('udid'))
app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=self.developer_obj, udid=self.udid_info.get('udid')) app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=self.developer_obj, udid=self.udid_info.get('udid'))
if not app_udid_obj: if not app_udid_obj:

@ -102,7 +102,8 @@ class AppsShortSerializer(serializers.ModelSerializer):
def get_has_combo(self, obj): def get_has_combo(self, obj):
if obj.has_combo: if obj.has_combo:
obj.has_combo.has_combo = None obj.has_combo.has_combo = None
return AppsSerializer(obj.has_combo, context=self.context).data if obj.has_combo.isshow:
return AppsSerializer(obj.has_combo, context=self.context).data
master_release = serializers.SerializerMethodField() master_release = serializers.SerializerMethodField()

@ -94,7 +94,18 @@ def set_app_download_by_cache(app_id, limit=900):
return download_times + 1 return download_times + 1
def del_cache_response_by_short(short, app_id, udid=''): def del_cache_response_by_short(app_id, udid=''):
apps_dict = Apps.objects.filter(app_id=app_id).values("id", "short", "app_id", "has_combo").first()
if apps_dict:
del_cache_response_by_short_util(apps_dict.get("short"), apps_dict.get("app_id"), udid)
if apps_dict.get("has_combo"):
combo_dict = Apps.objects.filter(pk=apps_dict.get("has_combo")).values("id", "short", "app_id").first()
if combo_dict:
del_cache_response_by_short_util(combo_dict.get("short"), combo_dict.get("app_id"), udid)
def del_cache_response_by_short_util(short, app_id, udid):
logger.info("del_cache_response_by_short short:%s app_id:%s udid:%s" % (short, app_id, udid))
cache.delete("_".join([CACHE_KEY_TEMPLATE.get("download_short_key"), short])) cache.delete("_".join([CACHE_KEY_TEMPLATE.get("download_short_key"), short]))
key = "_".join([CACHE_KEY_TEMPLATE.get("download_short_key"), short, '*']) key = "_".join([CACHE_KEY_TEMPLATE.get("download_short_key"), short, '*'])
for app_download_key in cache.iter_keys(key): for app_download_key in cache.iter_keys(key):
@ -126,8 +137,9 @@ def del_cache_by_app_id(app_id, user_obj):
def del_cache_storage(user_obj): def del_cache_storage(user_obj):
logger.info("del_cache_storage user:%s" % (user_obj))
for app_obj in Apps.objects.filter(user_id=user_obj): for app_obj in Apps.objects.filter(user_id=user_obj):
del_cache_response_by_short(app_obj.short, app_obj.app_id) del_cache_response_by_short(app_obj.app_id)
del_cache_by_app_id(app_obj.app_id, user_obj) del_cache_by_app_id(app_obj.app_id, user_obj)
storage_keys = "_".join([CACHE_KEY_TEMPLATE.get('user_storage_key'), user_obj.uid, '*']) storage_keys = "_".join([CACHE_KEY_TEMPLATE.get('user_storage_key'), user_obj.uid, '*'])
@ -185,6 +197,7 @@ def upload_file_tmp_name(act, filename, user_obj_id):
def login_auth_failed(act, email): def login_auth_failed(act, email):
logger.error("login email:%s act:%s" % (email, act))
auth_code_key = "_".join([CACHE_KEY_TEMPLATE.get("login_failed_try_times_key"), email]) auth_code_key = "_".join([CACHE_KEY_TEMPLATE.get("login_failed_try_times_key"), email])
if act == "set": if act == "set":
data = { data = {

@ -9,10 +9,7 @@ from api.utils.response import BaseResponse
from api.utils.auth import ExpiringTokenAuthentication from api.utils.auth import ExpiringTokenAuthentication
from rest_framework.response import Response from rest_framework.response import Response
from django.db.models import Sum, F from django.db.models import Sum, F
import os
from fir_ser import settings
from api.utils.app.supersignutils import IosUtils from api.utils.app.supersignutils import IosUtils
from api.utils.app.randomstrings import make_from_user_uuid
from api.utils.storage.storage import Storage from api.utils.storage.storage import Storage
from api.utils.storage.caches import del_cache_response_by_short, get_app_today_download_times from api.utils.storage.caches import del_cache_response_by_short, get_app_today_download_times
from api.models import Apps, AppReleaseInfo, APPToDeveloper, AppIOSDeveloperInfo, UserInfo from api.models import Apps, AppReleaseInfo, APPToDeveloper, AppIOSDeveloperInfo, UserInfo
@ -37,7 +34,6 @@ class AppsView(APIView):
app_type = request.query_params.get("type", None) app_type = request.query_params.get("type", None)
act_type = request.query_params.get("act", None) act_type = request.query_params.get("act", None)
logger.info("app_type:%s act_type:%s" % (app_type, act_type))
res = BaseResponse() res = BaseResponse()
res.hdata = {"all_hits_count": 0} res.hdata = {"all_hits_count": 0}
res.hdata["upload_domain"] = request.user.domain_name res.hdata["upload_domain"] = request.user.domain_name
@ -122,20 +118,20 @@ class AppInfoView(APIView):
apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first() apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
if apps_obj: if apps_obj:
if apps_obj.issupersign: if apps_obj.issupersign:
logger.info("app_id:%s is supersign ,so delete this app need clean IOS developer") logger.info("app_id:%s is supersign ,delete this app need clean IOS developer" % (app_id))
IosUtils.clean_app_by_user_obj(apps_obj, request.user) IosUtils.clean_app_by_user_obj(apps_obj, request.user)
storage = Storage(request.user) storage = Storage(request.user)
has_combo = apps_obj.has_combo has_combo = apps_obj.has_combo
if has_combo: if has_combo:
logger.info( logger.info(
"app_id:%s has_combo ,so delete this app need uncombo and clean del_cache_response_by_short") "app_id:%s has_combo ,delete this app need uncombo and clean del_cache_response_by_short" % (
del_cache_response_by_short(apps_obj.has_combo.short, apps_obj.has_combo.app_id) app_id))
apps_obj.has_combo.has_combo = None apps_obj.has_combo.has_combo = None
del_cache_response_by_short(apps_obj.short, apps_obj.app_id) del_cache_response_by_short(apps_obj.app_id)
for appreleaseobj in AppReleaseInfo.objects.filter(app_id=apps_obj).all(): for appreleaseobj in AppReleaseInfo.objects.filter(app_id=apps_obj).all():
logger.info("app_id:%s has_combo ,so delete this app need clean all release,release_id:%s" % ( logger.info("delete app_id:%s need clean all release,release_id:%s" % (
appreleaseobj.release_id)) app_id, appreleaseobj.release_id))
storage.delete_file(appreleaseobj.release_id, appreleaseobj.release_type) storage.delete_file(appreleaseobj.release_id, appreleaseobj.release_type)
storage.delete_file(appreleaseobj.icon_url) storage.delete_file(appreleaseobj.icon_url)
appreleaseobj.delete() appreleaseobj.delete()
@ -175,8 +171,7 @@ class AppInfoView(APIView):
has_combo.update(**{"has_combo": apps_obj.first()}) has_combo.update(**{"has_combo": apps_obj.first()})
else: else:
pass pass
del_cache_response_by_short(apps_obj.first().short, apps_obj.first().app_id) del_cache_response_by_short(apps_obj.first().app_id)
del_cache_response_by_short(has_combo.first().short, has_combo.first().app_id)
except Exception as e: except Exception as e:
logger.error("app_id:%s actions:%s hcombo_id:%s Exception:%s" % (app_id, actions, hcombo_id, e)) logger.error("app_id:%s actions:%s hcombo_id:%s Exception:%s" % (app_id, actions, hcombo_id, e))
@ -185,8 +180,9 @@ class AppInfoView(APIView):
else: else:
try: try:
apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first() apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
logger.info("app_id:%s update old data:%s" % (app_id, apps_obj.__dict__))
apps_obj.description = data.get("description", apps_obj.description) apps_obj.description = data.get("description", apps_obj.description)
del_cache_response_by_short(apps_obj.short, apps_obj.app_id) del_cache_response_by_short(apps_obj.app_id)
apps_obj.short = data.get("short", apps_obj.short) apps_obj.short = data.get("short", apps_obj.short)
apps_obj.name = data.get("name", apps_obj.name) apps_obj.name = data.get("name", apps_obj.name)
apps_obj.password = data.get("password", apps_obj.password) apps_obj.password = data.get("password", apps_obj.password)
@ -206,6 +202,7 @@ class AppInfoView(APIView):
res.msg = "超级签开发者不存在,无法开启" res.msg = "超级签开发者不存在,无法开启"
return Response(res.dict) return Response(res.dict)
apps_obj.issupersign = data.get("issupersign", apps_obj.issupersign) apps_obj.issupersign = data.get("issupersign", apps_obj.issupersign)
logger.info("app_id:%s update new data:%s" % (app_id, apps_obj.__dict__))
apps_obj.save() apps_obj.save()
except Exception as e: except Exception as e:
logger.error("app_id:%s update Exception:%s" % (app_id, e)) logger.error("app_id:%s update Exception:%s" % (app_id, e))
@ -300,11 +297,13 @@ class AppReleaseinfoView(APIView):
apprelease_count = AppReleaseInfo.objects.filter(app_id=apps_obj).values("release_id").count() apprelease_count = AppReleaseInfo.objects.filter(app_id=apps_obj).values("release_id").count()
appreleaseobj = AppReleaseInfo.objects.filter(app_id=apps_obj, release_id=act).first() appreleaseobj = AppReleaseInfo.objects.filter(app_id=apps_obj, release_id=act).first()
if not appreleaseobj.is_master: if not appreleaseobj.is_master:
logger.info("delete app release %s" % (appreleaseobj))
storage.delete_file(appreleaseobj.release_id, appreleaseobj.release_type) storage.delete_file(appreleaseobj.release_id, appreleaseobj.release_type)
storage.delete_file(appreleaseobj.icon_url) storage.delete_file(appreleaseobj.icon_url)
appreleaseobj.delete() appreleaseobj.delete()
elif appreleaseobj.is_master and apprelease_count < 2: elif appreleaseobj.is_master and apprelease_count < 2:
logger.info("delete app master release %s and clean app %s " % (appreleaseobj, apps_obj))
storage.delete_file(appreleaseobj.release_id, appreleaseobj.release_type) storage.delete_file(appreleaseobj.release_id, appreleaseobj.release_type)
storage.delete_file(appreleaseobj.icon_url) storage.delete_file(appreleaseobj.icon_url)
@ -316,7 +315,7 @@ class AppReleaseinfoView(APIView):
apps_obj.delete() apps_obj.delete()
else: else:
pass pass
del_cache_response_by_short(apps_obj.short, apps_obj.app_id) del_cache_response_by_short(apps_obj.app_id)
return Response(res.dict) return Response(res.dict)
@ -327,16 +326,16 @@ class AppReleaseinfoView(APIView):
apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first() apps_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
if apps_obj: if apps_obj:
appreleaseobj = AppReleaseInfo.objects.filter(app_id=apps_obj, release_id=act) appreleaseobj = AppReleaseInfo.objects.filter(app_id=apps_obj, release_id=act)
data = request.data
make_master = request.data.get("make_master", None) make_master = data.get("make_master", None)
try: try:
if make_master and make_master == act: if make_master and make_master == act:
AppReleaseInfo.objects.filter(app_id=apps_obj).update(**{"is_master": False}) AppReleaseInfo.objects.filter(app_id=apps_obj).update(**{"is_master": False})
appreleaseobj.update(**{"is_master": True}) appreleaseobj.update(**{"is_master": True})
else: else:
appreleaseobj.update( appreleaseobj.update(
**{"changelog": request.data.get("changelog", appreleaseobj.first().changelog)}) **{"changelog": data.get("changelog", appreleaseobj.first().changelog)})
binary_url = request.data.get("binary_url", None) binary_url = data.get("binary_url", None)
if binary_url != '': if binary_url != '':
if binary_url: if binary_url:
if not binary_url.startswith('http'): if not binary_url.startswith('http'):
@ -345,13 +344,14 @@ class AppReleaseinfoView(APIView):
binary_url = appreleaseobj.first().binary_url binary_url = appreleaseobj.first().binary_url
appreleaseobj.update(**{"binary_url": binary_url}) appreleaseobj.update(**{"binary_url": binary_url})
logger.info("update app:%s release:%s data:%s" % (apps_obj, appreleaseobj, data))
except Exception as e: except Exception as e:
logger.error("update app:%s release:%s failed Exception:%s" % (apps_obj, appreleaseobj, e))
res.code = 1006 res.code = 1006
res.msg = "更新失败" res.msg = "更新失败"
return Response(res.dict) return Response(res.dict)
del_cache_response_by_short(apps_obj.short, apps_obj.app_id) del_cache_response_by_short(apps_obj.app_id)
app_serializer = AppsSerializer(apps_obj) app_serializer = AppsSerializer(apps_obj)
res.data["currentapp"] = app_serializer.data res.data["currentapp"] = app_serializer.data

@ -29,9 +29,6 @@ class DownloadView(APIView):
文件下载接口,适用于本地存储和所有plist文件下载 文件下载接口,适用于本地存储和所有plist文件下载
''' '''
# authentication_classes = [ExpiringTokenAuthentication, ]
# parser_classes = (MultiPartParser,)
def get(self, request, filename): def get(self, request, filename):
res = BaseResponse() res = BaseResponse()
downtoken = request.query_params.get(settings.DATA_DOWNLOAD_KEY, None) downtoken = request.query_params.get(settings.DATA_DOWNLOAD_KEY, None)
@ -113,7 +110,7 @@ class ShortDownloadView(APIView):
res.msg = "该应用不存在" res.msg = "该应用不存在"
return Response(res.dict) return Response(res.dict)
if udid: if udid:
del_cache_response_by_short(short, app_obj.app_id, udid=udid) del_cache_response_by_short(app_obj.app_id, udid=udid)
if not app_obj.isshow: if not app_obj.isshow:
res.code = 1004 res.code = 1004
res.msg = "您没有权限访问该应用" res.msg = "您没有权限访问该应用"

@ -94,7 +94,7 @@ class UserInfoView(APIView):
if act and act == "sms": if act and act == "sms":
sms_token_obj = DownloadToken() sms_token_obj = DownloadToken()
sms_code = generateNumericTokenOfLength(6) sms_code = generateNumericTokenOfLength(6)
sms_token = sms_token_obj.make_token([sms_code]) sms_token = sms_token_obj.make_token(sms_code)
res.data["sms_token"] = sms_token res.data["sms_token"] = sms_token
res.data["sms_code"] = sms_code res.data["sms_code"] = sms_code
@ -102,18 +102,22 @@ class UserInfoView(APIView):
def put(self, request): def put(self, request):
res = BaseResponse() res = BaseResponse()
request.user.qq = request.data.get("qq", request.user.qq) data = request.data
request.user.job = request.data.get("job", request.user.job) logger.info("user:%s update old data:%s" % (request.user, request.user.__dict__))
request.user.first_name = request.data.get("first_name", request.user.first_name) logger.info("user:%s update new data:%s" % (request.user, data))
request.user.qq = data.get("qq", request.user.qq)
oldpassword = request.data.get("oldpassword", None) request.user.job = data.get("job", request.user.job)
surepassword = request.data.get("surepassword", None) request.user.first_name = data.get("first_name", request.user.first_name)
oldpassword = data.get("oldpassword", None)
surepassword = data.get("surepassword", None)
if oldpassword and surepassword: if oldpassword and surepassword:
user = auth.authenticate(username=request.user.username, password=oldpassword) user = auth.authenticate(username=request.user.username, password=oldpassword)
if user is not None: if user is not None:
user.set_password(surepassword) user.set_password(surepassword)
user.save() user.save()
res.msg = "密码修改成功" res.msg = "密码修改成功"
logger.info("user:%s change password success,old %s new %s" % (request.user, oldpassword, surepassword))
auth_token = request.auth auth_token = request.auth
for token_obj in Token.objects.filter(user=user): for token_obj in Token.objects.filter(user=user):
@ -127,11 +131,11 @@ class UserInfoView(APIView):
res.msg = "老密码校验失败" res.msg = "老密码校验失败"
else: else:
sms_token = request.data.get("sms_token", None) sms_token = data.get("sms_token", None)
if sms_token: if sms_token:
sms_token_obj = DownloadToken() sms_token_obj = DownloadToken()
if sms_token_obj.verify_token(sms_token, request.data.get("sms_code", None)): if sms_token_obj.verify_token(sms_token, data.get("sms_code", None)):
request.user.mobile = request.data.get("mobile", request.user.mobile) request.user.mobile = data.get("mobile", request.user.mobile)
request.user.save() request.user.save()
serializer = UserInfoSerializer(request.user) serializer = UserInfoSerializer(request.user)
res.data = serializer.data res.data = serializer.data

@ -3,14 +3,20 @@ from api.utils.auth import ExpiringTokenAuthentication
from api.models import Token from api.models import Token
from django.core.cache import cache from django.core.cache import cache
from rest_framework.response import Response from rest_framework.response import Response
from django.contrib import auth
import logging
logger = logging.getLogger(__file__)
class LogoutView(APIView): class LogoutView(APIView):
authentication_classes = [ExpiringTokenAuthentication] authentication_classes = [ExpiringTokenAuthentication]
def delete(self, request): def delete(self, request):
logger.info("user:%s logout" % (request.user))
user = request.user.pk user = request.user.pk
auth_token = request.auth auth_token = request.auth
cache.delete(auth_token) cache.delete(auth_token)
Token.objects.filter(user=user, access_token=auth_token).delete() Token.objects.filter(user=user, access_token=auth_token).delete()
auth.logout(request)
return Response({"code": 1000}) return Response({"code": 1000})

@ -18,6 +18,7 @@ class IosUDIDView(View):
def post(self, request, short): def post(self, request, short):
stream_f = str(request.body) stream_f = str(request.body)
format_udid_info = udid_bytes_to_dict(stream_f) format_udid_info = udid_bytes_to_dict(stream_f)
logger.info("short %s get new udid %s" % (short, format_udid_info))
server_domain = get_redirect_server_domain(request) server_domain = get_redirect_server_domain(request)
try: try:
app_info = Apps.objects.filter(short=short).first() app_info = Apps.objects.filter(short=short).first()

@ -56,18 +56,20 @@ class StorageView(APIView):
def post(self, request): def post(self, request):
res = BaseResponse() res = BaseResponse()
data = request.data data = request.data
logger.info("user %s add new storage data:%s" % (request.user, data))
try: try:
data['additionalparameters'] = json.dumps(data.get('additionalparameter', '')) data['additionalparameters'] = json.dumps(data.get('additionalparameter', ''))
except Exception as e: except Exception as e:
logger.error("user:%s additionalparameters %s dumps failed Exception:%s" % ( logger.error("user:%s additionalparameters %s dumps failed Exception:%s" % (
request.user, data.get('additionalparameter', ''), e)) request.user, data.get('additionalparameter', ''), e))
serializer = StorageSerializer(data=data, context={'user_obj': request.user}) serializer = StorageSerializer(data=data, context={'user_obj': request.user})
if serializer.is_valid(): if serializer.is_valid():
serializer.save() serializer.save()
res.msg = serializer.validated_data res.msg = serializer.validated_data
logger.info("user %s add new storage success" % (request.user))
else: else:
logger.info("user %s add new storage failed" % (request.user))
res.msg = serializer.errors res.msg = serializer.errors
res.code = 1005 res.code = 1005
return Response(res.dict) return Response(res.dict)
@ -75,6 +77,7 @@ class StorageView(APIView):
def put(self, request): def put(self, request):
res = BaseResponse() res = BaseResponse()
data = request.data data = request.data
logger.info("user %s update storage data:%s" % (request.user, data))
use_storage_id = data.get("use_storage_id", None) use_storage_id = data.get("use_storage_id", None)
if use_storage_id: if use_storage_id:
@ -116,7 +119,11 @@ class StorageView(APIView):
res = BaseResponse() res = BaseResponse()
storage_id = request.query_params.get("id", None) storage_id = request.query_params.get("id", None)
if storage_id: if storage_id:
AppStorage.objects.filter(user_id=request.user, id=storage_id).delete() try:
AppStorage.objects.filter(user_id=request.user, id=storage_id).delete()
logger.error("user %s delete storage id:%s success" % (request.user, storage_id))
except Exception as e:
logger.error("user %s delete storage id:%s failed Exception:%s" % (request.user, storage_id, e))
else: else:
res.code = 1004 res.code = 1004
res.msg = '该存储不存在' res.msg = '该存储不存在'

@ -58,6 +58,7 @@ class DeveloperView(APIView):
act = data.get("act", None) act = data.get("act", None)
if act: if act:
res = BaseResponse() res = BaseResponse()
logger.info("user %s iosdeveloper %s act %s" % (request.user, developer_obj, act))
if act == "preactive": if act == "preactive":
developer_auth_code("del", request.user, developer_obj.email) developer_auth_code("del", request.user, developer_obj.email)
status, result = IosUtils.active_developer(developer_obj, request.user) status, result = IosUtils.active_developer(developer_obj, request.user)
@ -107,19 +108,28 @@ class DeveloperView(APIView):
res.msg = result.get("return_info") res.msg = result.get("return_info")
return Response(res.dict) return Response(res.dict)
else: else:
logger.info("user %s iosdeveloper %s update input data %s" % (request.user, developer_obj, data))
logger.info("user %s iosdeveloper %s update old data %s" % (
request.user, developer_obj, developer_obj.__dict__))
try: try:
usable_number = int(data.get("usable_number", developer_obj.usable_number)) usable_number = int(data.get("usable_number", developer_obj.usable_number))
if usable_number >= 0 and usable_number <= 100: if usable_number >= 0 and usable_number <= 100:
developer_obj.usable_number = usable_number developer_obj.usable_number = usable_number
except Exception as e: except Exception as e:
logger.error("developer %s usable_number %s get failed Exception:%s" % ( logger.error("developer %s usable_number %s get failed Exception:%s" % (
developer_obj, data.get("usable_number", developer_obj.usable_number), e)) developer_obj, data.get("usable_number", developer_obj.usable_number), e))
developer_obj.description = data.get("description", developer_obj.description) developer_obj.description = data.get("description", developer_obj.description)
password = data.get("password", developer_obj.password) password = data.get("password", developer_obj.password)
if password != "" and password != developer_obj.password: if password != "" and password != developer_obj.password:
developer_obj.password = password developer_obj.password = password
developer_obj.is_actived = False developer_obj.is_actived = False
developer_obj.save() try:
developer_obj.save()
logger.info("user %s iosdeveloper %s update now data %s" % (
request.user, developer_obj, developer_obj.__dict__))
except Exception as e:
logger.error("user %s iosdeveloper %s update error data %s Exception %s" % (
request.user, developer_obj, data, e))
return self.get(request) return self.get(request)
@ -132,6 +142,8 @@ class DeveloperView(APIView):
"email": data.get("email", ""), "email": data.get("email", ""),
} }
try: try:
logger.error("user %s add new developer %s data %s" % (
request.user, data.get("email", ""), datainfo))
AppIOSDeveloperInfo.objects.create(user_id=request.user, **datainfo) AppIOSDeveloperInfo.objects.create(user_id=request.user, **datainfo)
except Exception as e: except Exception as e:
logger.error("user %s create developer %s failed Exception:%s" % ( logger.error("user %s create developer %s failed Exception:%s" % (
@ -148,6 +160,8 @@ class DeveloperView(APIView):
if email: if email:
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user, email=email).first() developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user, email=email).first()
if developer_obj: if developer_obj:
logger.error("user %s delete developer %s " % (
request.user, developer_obj))
IosUtils.clean_developer(developer_obj, request.user) IosUtils.clean_developer(developer_obj, request.user)
developer_obj.delete() developer_obj.delete()
@ -211,6 +225,8 @@ class AppUDIDUsedView(APIView):
id = request.query_params.get("id", None) id = request.query_params.get("id", None)
app_id = request.query_params.get("aid", None) app_id = request.query_params.get("aid", None)
app_udid_obj = AppUDID.objects.filter(app_id__user_id_id=request.user, pk=id) app_udid_obj = AppUDID.objects.filter(app_id__user_id_id=request.user, pk=id)
IosUtils.disable_udid(app_udid_obj.first(), app_id) if app_udid_obj:
app_udid_obj.delete() logger.error("user %s delete devices %s" % (request.user, app_udid_obj))
IosUtils.disable_udid(app_udid_obj.first(), app_id)
app_udid_obj.delete()
return Response(res.dict) return Response(res.dict)

@ -100,7 +100,7 @@ class AppAnalyseView(APIView):
png_tmp_filename = data.get("png_key") png_tmp_filename = data.get("png_key")
png_new_filename = data.get("png_key").strip(settings.FILE_UPLOAD_TMP_KEY) png_new_filename = data.get("png_key").strip(settings.FILE_UPLOAD_TMP_KEY)
logger.info("user %s create or update app %s data:%s" % (request.user, data.get("bundleid"), data))
if SaveAppInfos(app_new_filename, request.user, appinfo, if SaveAppInfos(app_new_filename, request.user, appinfo,
data.get("bundleid"), png_new_filename, data.get("short"), data.get('filesize')): data.get("bundleid"), png_new_filename, data.get("short"), data.get('filesize')):
pass pass
@ -115,7 +115,7 @@ class AppAnalyseView(APIView):
upload_file_tmp_name("del", png_tmp_filename, request.user.id) upload_file_tmp_name("del", png_tmp_filename, request.user.id)
except Exception as e: except Exception as e:
logger.error("%s %s save app info failed Exception:%s" % (request.user, data.get("bundleid"), e)) logger.error("user %s %s save app info failed Exception:%s" % (request.user, data.get("bundleid"), e))
res.code = 10003 res.code = 10003
return Response(res.dict) return Response(res.dict)
@ -229,6 +229,7 @@ class UploadView(APIView):
random_file_name = make_from_user_uuid(request.user) random_file_name = make_from_user_uuid(request.user)
local_file = os.path.join(settings.MEDIA_ROOT, certinfo.get("upload_key", random_file_name)) local_file = os.path.join(settings.MEDIA_ROOT, certinfo.get("upload_key", random_file_name))
# 读取传入的文件 # 读取传入的文件
logger.info("user:%s save file:%s" % (request.user, local_file))
try: try:
destination = open(local_file, 'wb+') destination = open(local_file, 'wb+')
for chunk in file_obj.chunks(): for chunk in file_obj.chunks():
@ -260,10 +261,11 @@ class UploadView(APIView):
certinfo = request.data.get('certinfo', None) certinfo = request.data.get('certinfo', None)
if certinfo: if certinfo:
app_id = certinfo.get("app_id", None) app_id = certinfo.get("app_id", None)
logger.info("user %s update img %s info" % (request.user, app_id))
ftype = certinfo.get('ftype', None) ftype = certinfo.get('ftype', None)
storage = Storage(request.user) storage = Storage(request.user)
if ftype and ftype == 'app': if ftype and app_id and ftype == 'app':
app_obj = Apps.objects.filter(app_id=app_id, user_id=request.user).first() app_obj = Apps.objects.filter(app_id=app_id, user_id=request.user).first()
if app_obj: if app_obj:
release_obj = AppReleaseInfo.objects.filter(app_id=app_obj, is_master=True).first() release_obj = AppReleaseInfo.objects.filter(app_id=app_obj, is_master=True).first()
@ -271,10 +273,10 @@ class UploadView(APIView):
old_file_key = release_obj.icon_url old_file_key = release_obj.icon_url
release_obj.icon_url = certinfo.get("upload_key") release_obj.icon_url = certinfo.get("upload_key")
release_obj.save() release_obj.save()
del_cache_response_by_short(app_obj.short, app_id) del_cache_response_by_short(app_id)
storage.delete_file(old_file_key) storage.delete_file(old_file_key)
return Response(res.dict) return Response(res.dict)
elif ftype and ftype == 'head': elif ftype and app_id and ftype == 'head':
if request.user.uid != app_id: if request.user.uid != app_id:
res.code = 1007 res.code = 1007
res.msg = '该用户不存在' res.msg = '该用户不存在'

Loading…
Cancel
Save