优化代码

dependabot/npm_and_yarn/fir_admin/async-2.6.4
nineven 3 years ago
parent 1d75c8ed23
commit 156bf67c1c
  1. 23
      fir_client/src/components/apps/FirApps.vue
  2. 24
      fir_client/src/components/user/FirSuperSignBase.vue
  3. 2
      fir_ser/api/utils/serializer.py
  4. 15
      fir_ser/api/views/apps.py
  5. 1
      fir_ser/xsign/migrations/0001_initial.py
  6. 1
      fir_ser/xsign/models.py
  7. 11
      fir_ser/xsign/tasks.py
  8. 34
      fir_ser/xsign/utils/supersignutils.py
  9. 15
      fir_ser/xsign/views/supersign.py

@ -491,12 +491,13 @@
<div class=" app-animator">
<div class="card app card-ios">
<i v-if="r.type === 1" class=" type-icon iconfont icon-ios"/>
<i class="down-icon el-icon-cloudy"> {{ r.count_hits }}</i>
<i v-if="r.type === 1" class="type-icon iconfont icon-ios"/>
<i v-if="r.type === 0" class="type-icon iconfont icon-android2"/>
<div v-if="r.type === 1" class="type-mark"></div>
<div v-if="r.type === 0" class="type-mark" style="border-top: 48px solid #A4C639"></div>
<div v-if="r.type === 1 && r.issupersign" class="type-mark" style="border-top: 48px solid #a2b0f5"></div>
<div v-if="r.type === 1 && !r.issupersign" class="type-mark"></div>
<div v-if="r.type === 0" class="type-mark" style="border-top: 48px solid #a4c639"></div>
<a class="appicon" @click="appInfos(r)">
<img :src="r.master_release.icon_url|make_icon_url" alt="" class="icon ng-isolate-scope"
height="100" width="100"></a>
@ -1035,7 +1036,7 @@ export default {
if (this.searchfromtype) {
this.getappsFun({"type": this.searchfromtype, 'page': 1, size: 999});
} else {
this.getappsFun({'page': 1, size: 999});
this.getappsFun({'page': 1, size: 999, 'search': keysearch});
}
}
},
@ -1062,7 +1063,7 @@ export default {
let keysearch = this.keysearch.replace(/^\s+|\s+$/g, "");
let newapplists = [];
for (let i = 0; i < this.orgapplists.length; i++) {
if (this.orgapplists[i].name.search(keysearch) >= 0) {
if (this.orgapplists[i].name.search(keysearch) >= 0 || this.orgapplists[i].short.search(keysearch) >= 0) {
newapplists.push(this.orgapplists[i]);
}
}
@ -1365,6 +1366,16 @@ export default {
}
.page-apps .card.app .down-icon {
position: absolute;
top: 9px;
left: 7px;
z-index: 2;
/*color: #1f72ee;*/
color: #B6BDC1;
}
.page-apps .card.app .type-mark {
position: absolute;
top: 0;

@ -135,6 +135,16 @@
</el-switch>
<el-tag style="margin-left: 10px" type="warning"> 开启之后每天凌晨自动检测该开发者和设备使用状态默认关闭</el-tag>
</el-form-item>
<el-form-item label="异常状态注册" label-width="110px" style="text-align: left">
<el-switch
v-model="editdeveloperinfo.abnormal_register"
:active-value="true"
:inactive-value="false"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
<el-tag style="margin-left: 10px" type="warning"> 开启之后当开发者出现设备异常状态时新设备还是可以继续注册默认开启</el-tag>
</el-form-item>
<el-form-item label="证书id" label-width="110px">
<el-input v-model="editdeveloperinfo.certid" :disabled='isedit'/>
</el-form-item>
@ -732,7 +742,17 @@
<el-tag v-else size="medium" type="info"></el-tag>
</template>
</el-table-column>
<el-table-column
align="center"
label="异常注册"
prop="abnormal_register"
sortable
width="60">
<template slot-scope="scope">
<el-tag v-if="scope.row.abnormal_register" size="medium"></el-tag>
<el-tag v-else size="medium" type="info"></el-tag>
</template>
</el-table-column>
<el-table-column
align="center"
label="备注"
@ -752,7 +772,7 @@
align="center"
fixed="right"
label="操作"
width="150">
width="145">
<template slot-scope="scope">
<el-button

@ -205,7 +205,7 @@ class AppsListSerializer(AppsSerializer):
class Meta:
model = models.Apps
fields = ["app_id", "bundle_id", "issupersign", "name", "preview_url", "short", "type", "master_release",
"has_combo"]
"has_combo", "count_hits"]
def get_master_release(self, obj):
master_release_obj = get_app_master_obj_from_context(self, obj)

@ -45,17 +45,18 @@ def get_release_apps(request, res, app_serializer, apps_obj, storage):
def apps_filter(request):
app_type = request.query_params.get("type", None)
act_type = request.query_params.get("act", None)
search = request.query_params.get("search", None)
filter_data = {"user_id": request.user}
if app_type == "android":
filter_data = {"user_id": request.user, "type": 0}
filter_data["type"] = 0
elif app_type == "ios":
filter_data = {"user_id": request.user, "type": 1}
else:
filter_data = {"user_id": request.user}
filter_data["type"] = 1
if act_type == "combo":
filter_data["has_combo"] = None
return Apps.objects.filter(**filter_data).all()
app_query_set = Apps.objects.filter(**filter_data)
if search:
app_query_set = app_query_set.filter(Q(short=search) | Q(name__contains=search))
return app_query_set.all()
class AppsPageNumber(PageNumberPagination):

@ -36,6 +36,7 @@ class Migration(migrations.Migration):
default=0, verbose_name='账户状态')),
('clean_status', models.BooleanField(default=False, verbose_name='清理是否同时禁用设备ID')),
('auto_check', models.BooleanField(default=False, verbose_name='是否自动检测开发者状态')),
('abnormal_register', models.BooleanField(default=True, verbose_name='设备异常状态是否注册')),
('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL,
verbose_name='用户ID')),
],

@ -37,6 +37,7 @@ class AppIOSDeveloperInfo(models.Model):
clean_status = models.BooleanField(verbose_name="清理是否同时禁用设备ID", default=False)
auto_check = models.BooleanField(verbose_name="是否自动检测开发者状态", default=False)
abnormal_register = models.BooleanField(verbose_name="设备异常状态是否注册", default=True)
class Meta:
verbose_name = '苹果开发者账户'

@ -24,6 +24,7 @@ logger = logging.getLogger(__name__)
def run_sign_task(format_udid_info, short, client_ip):
app_obj = Apps.objects.filter(short=short).first()
user_obj = app_obj.user_id
udid = format_udid_info.get('udid')
if MigrateStorageState(user_obj.uid).get_state():
msg = "数据迁移中,无法处理该操作"
code = 1000
@ -33,9 +34,11 @@ def run_sign_task(format_udid_info, short, client_ip):
status, result = ios_sign_obj.sign_ipa(client_ip)
if ios_sign_obj.developer_obj:
if status:
add_sign_message(user_obj, ios_sign_obj.developer_obj, app_obj, '签名成功', result, True)
message = f"sign_info:[client_ip:{client_ip} udid:{udid}] raw_info:[{result}]"
add_sign_message(user_obj, ios_sign_obj.developer_obj, app_obj, '签名成功', message, True)
except Exception as e:
logger.error(f"run_sign_task failed. udid_info:{format_udid_info} app_obj:{app_obj} Exception:{e}")
logger.error(
f"run_sign_task failed. client_ip:{client_ip} udid_info:{format_udid_info} app_obj:{app_obj} Exception:{e}")
msg = '系统内部错误,请稍后再试或联系管理员'
code = 5000
return {'code': code, 'msg': msg}
@ -54,11 +57,11 @@ def run_sign_task(format_udid_info, short, client_ip):
else:
code = 5000
msg = '系统内部错误,请稍后再试或联系管理员'
message = f"return_info:[code:{code},msg:{msg}] raw_info:[{result}]"
message = f"return_info:[client_ip:{client_ip},code:{code},msg:{msg},udid:{udid}] raw_info:[{result}]"
if ios_sign_obj.developer_obj:
add_sign_message(user_obj, ios_sign_obj.developer_obj, app_obj, '签名失败了', message, False)
else:
logger.error(f"{user_obj} {app_obj} 签名失败了:{message}")
logger.error(f"[client_ip:{client_ip}] {user_obj} {app_obj} 签名失败了:{message}")
else:
msg = ""
code = 1000

@ -338,11 +338,13 @@ def get_developer_user_by_app_exist_udid(user_objs, udid, app_obj, abnormal_use_
return developer_udid_queryset, False
def get_developer_user_by_app_new_udid(user_objs, udid, app_obj, status_choice, private_first):
def get_developer_user_by_app_new_udid(user_objs, udid, app_obj, status_choice, private_first, abnormal_register=False):
# 新设备查找策略
# 根据app查找开发者账户
exist_app_developer_pk_list = []
status_filter = {'developerid__certid__isnull': False, 'developerid__status__in': status_choice}
if abnormal_register:
status_filter['developerid__abnormal_register'] = abnormal_register
developer_pk_list = UDIDsyncDeveloper.objects.filter(developerid__user_id__in=user_objs,
developerid__apptodeveloper__app_id=app_obj,
**status_filter).values('developerid').all().distinct()
@ -361,6 +363,8 @@ def get_developer_user_by_app_new_udid(user_objs, udid, app_obj, status_choice,
return AppIOSDeveloperInfo.objects.filter(pk=exist_app_developer_pk_list[0]).first(), False
status_filter = {'certid__isnull': False, 'status__in': status_choice}
if abnormal_register:
status_filter['abnormal_register'] = abnormal_register
obj_base_filter = AppIOSDeveloperInfo.objects.filter(user_id__in=user_objs, **status_filter)
can_used_developer_pk_list = get_new_developer_by_app_obj(app_obj, obj_base_filter, apple_to_app)
@ -398,28 +402,30 @@ def get_developer_user_by_app_udid(user_objs, udid, app_obj, private_first=True,
else:
status_choice = Config.DEVELOPER_SIGN_STATUS
base_msg = f"{'read mode' if read_only else 'write mode'} did:{udid} app_obj:{app_obj}"
# 已经存在设备查找策略
obj, status = get_developer_user_by_app_exist_udid(user_objs, udid, app_obj, status_choice)
if status:
return obj, status
else:
logger.warning(
f"udid:{udid} app_obj:{app_obj} find udid from normal developer failed. now find abnormal device developer")
logger.warning(f"{base_msg} find udid from normal developer failed. now find abnormal device developer")
obj, status = get_developer_user_by_app_exist_udid(user_objs, udid, app_obj, [AppleDeveloperStatus.DEVICE_ABNORMAL])
if status:
return obj, status
else:
logger.warning(
f"udid:{udid} app_obj:{app_obj} find udid from abnormal developer failed. now find can wait developer")
logger.warning(f"{base_msg} find udid from abnormal developer failed. now find can wait developer")
if UserConfig(app_obj.user_id).DEVELOPER_WAIT_ABNORMAL_STATE:
obj, status = get_developer_user_by_app_exist_udid(user_objs, udid, app_obj, Config.DEVELOPER_WAIT_STATUS)
if status:
return obj, status
else:
logger.warning(
f"udid:{udid} app_obj:{app_obj} find udid from abnormal developer failed. now find register developer")
logger.warning(f"{base_msg} find udid from abnormal developer failed. now find register developer")
if read_only:
return None, None
# 新设备查找策略
# 查询开发者正常的状态
@ -427,14 +433,13 @@ def get_developer_user_by_app_udid(user_objs, udid, app_obj, private_first=True,
if obj:
return obj, status
else:
logger.warning(
f"udid:{udid} app_obj:{app_obj} register udid from normal developer failed. now find abnormal device developer")
logger.warning(f"{base_msg} register udid from normal developer failed. now find abnormal device developer")
# 个人配置允许查询异常设备
if UserConfig(app_obj.user_id).DEVELOPER_WAIT_ABNORMAL_DEVICE and UserConfig(
app_obj.user_id).DEVELOPER_ABNORMAL_DEVICE_WRITE:
status_choice = [AppleDeveloperStatus.DEVICE_ABNORMAL]
obj, status = get_developer_user_by_app_new_udid(user_objs, udid, app_obj, status_choice, private_first)
obj, status = get_developer_user_by_app_new_udid(user_objs, udid, app_obj, status_choice, private_first, True)
return obj, status
@ -627,13 +632,6 @@ class IosUtils(object):
res = check_app_permission(self.app_obj, BaseResponse())
if res.code != 1000:
return False, {'code': res.code, 'msg': res.msg}
self.get_developer_auth(True)
if not self.developer_obj:
msg = f"udid {self.udid} app {self.app_obj} not exists apple developer"
d_result['code'] = 1005
d_result['msg'] = msg
logger.error(d_result)
return False, d_result
return True, d_result
@staticmethod
@ -898,6 +896,8 @@ class IosUtils(object):
return status, msg
d_result = {'code': 1000, 'msg': 'success'}
self.get_developer_auth(True)
if self.developer_obj:
result = check_sign_is_exists(self.user_obj, self.app_obj, self.udid, self.developer_obj)
if result:
return result

@ -86,6 +86,8 @@ class DeveloperView(APIView):
res.status_choices.extend([
{'id': 'open_auto_check', 'name': '开启自动检测', 'disabled': False},
{'id': 'close_auto_check', 'name': '关闭自动检测', 'disabled': False},
{'id': 'open_abnormal_register', 'name': '开启设备异常状态注册', 'disabled': False},
{'id': 'close_abnormal_register', 'name': '关闭设备异常状态注册', 'disabled': False},
])
res.apple_auth_list = get_choices_dict(AppIOSDeveloperInfo.auth_type_choices)
return Response(res.dict)
@ -159,6 +161,13 @@ class DeveloperView(APIView):
AppIOSDeveloperInfo.objects.filter(user_id=request.user, issuer_id__in=issuer_ids).update(
auto_check=auto_check)
return Response(res.dict)
if status and status in ['open_abnormal_register', 'close_abnormal_register']:
abnormal_register = True
if status == 'close_abnormal_register':
abnormal_register = False
AppIOSDeveloperInfo.objects.filter(user_id=request.user, issuer_id__in=issuer_ids).update(
abnormal_register=abnormal_register)
return Response(res.dict)
if issuer_ids and status is not None and status not in Config.DEVELOPER_DISABLED_STATUS:
status_text = get_choices_name_from_key(AppIOSDeveloperInfo.status_choices, status)
if status_text:
@ -266,12 +275,10 @@ class DeveloperView(APIView):
f"developer {developer_obj} usable_number {data.get('usable_number', developer_obj.usable_number)} get failed Exception:{e}")
developer_obj.description = data.get("description", developer_obj.description)
update_fields.append("description")
developer_obj.clean_status = data.get("clean_status", developer_obj.clean_status)
update_fields.append("clean_status")
developer_obj.auto_check = data.get("auto_check", developer_obj.auto_check)
update_fields.append("auto_check")
developer_obj.abnormal_register = data.get("abnormal_register", developer_obj.abnormal_register)
update_fields.extend(["abnormal_register", "description", "clean_status", "auto_check"])
private_key_id = data.get("private_key_id", developer_obj.private_key_id)
p8key = data.get("p8key", developer_obj.p8key)

Loading…
Cancel
Save