|
|
@ -187,9 +187,10 @@ def get_auth_form_developer(developer_obj): |
|
|
|
return auth |
|
|
|
return auth |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_api_obj(auth): |
|
|
|
def get_api_obj(developer_obj): |
|
|
|
|
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
if auth.get("issuer_id"): |
|
|
|
if auth.get("issuer_id"): |
|
|
|
app_api_obj = AppDeveloperApiV2(**auth) |
|
|
|
app_api_obj = AppDeveloperApiV2(**auth, developer_pk=developer_obj.pk) |
|
|
|
else: |
|
|
|
else: |
|
|
|
app_api_obj = None |
|
|
|
app_api_obj = None |
|
|
|
return app_api_obj |
|
|
|
return app_api_obj |
|
|
@ -212,17 +213,16 @@ def err_callback(func, *args, **kwargs): |
|
|
|
|
|
|
|
|
|
|
|
def disable_developer_and_send_email(app_obj, developer_obj): |
|
|
|
def disable_developer_and_send_email(app_obj, developer_obj): |
|
|
|
logger.error(f"app {app_obj} developer {developer_obj} sign failed. so disabled") |
|
|
|
logger.error(f"app {app_obj} developer {developer_obj} sign failed. so disabled") |
|
|
|
developer_obj.is_actived = False |
|
|
|
developer_obj.status = 5 |
|
|
|
developer_obj.save(update_fields=['is_actived']) |
|
|
|
developer_obj.save(update_fields=['status']) |
|
|
|
send_ios_developer_active_status(developer_obj.user_id, |
|
|
|
send_ios_developer_active_status(developer_obj.user_id, |
|
|
|
MSGTEMPLATE.get('ERROR_DEVELOPER') % ( |
|
|
|
MSGTEMPLATE.get('ERROR_DEVELOPER') % ( |
|
|
|
developer_obj.user_id.first_name, app_obj.name, |
|
|
|
developer_obj.user_id.first_name, app_obj.name, |
|
|
|
developer_obj.issuer_id)) |
|
|
|
developer_obj.issuer_id)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_new_developer_by_app_obj(user_objs, app_obj, apple_to_app=False): |
|
|
|
def get_new_developer_by_app_obj(app_obj, obj_base_filter, apple_to_app=False): |
|
|
|
can_used_developer_pk_list = [] |
|
|
|
can_used_developer_pk_list = [] |
|
|
|
obj_base_filter = AppIOSDeveloperInfo.objects.filter(user_id__in=user_objs, is_actived=True, certid__isnull=False) |
|
|
|
|
|
|
|
if apple_to_app: |
|
|
|
if apple_to_app: |
|
|
|
# 存在指定开发者,则新设备优先注册到指定开发者 |
|
|
|
# 存在指定开发者,则新设备优先注册到指定开发者 |
|
|
|
developer_obj_lists = obj_base_filter.filter(appledevelopertoappuse__app_id=app_obj) |
|
|
|
developer_obj_lists = obj_base_filter.filter(appledevelopertoappuse__app_id=app_obj) |
|
|
@ -250,9 +250,7 @@ def get_new_developer_by_app_obj(user_objs, app_obj, apple_to_app=False): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def filter_developer_by_pk_list(developer_pk_list, f_key, app_search_flag=True): |
|
|
|
def filter_developer_by_pk_list(developer_pk_list, f_key, app_search_flag=True): |
|
|
|
developer_obj_dict = AppIOSDeveloperInfo.objects.filter(pk__in=developer_pk_list, |
|
|
|
developer_obj_dict = AppIOSDeveloperInfo.objects.filter(pk__in=developer_pk_list).values( |
|
|
|
is_actived=True, |
|
|
|
|
|
|
|
certid__isnull=False).values( |
|
|
|
|
|
|
|
f_key, 'pk').annotate(count=Count('pk')) |
|
|
|
f_key, 'pk').annotate(count=Count('pk')) |
|
|
|
if not app_search_flag: |
|
|
|
if not app_search_flag: |
|
|
|
developer_obj_dict = developer_obj_dict.filter(count__lt=F('app_limit_number')) |
|
|
|
developer_obj_dict = developer_obj_dict.filter(count__lt=F('app_limit_number')) |
|
|
@ -268,18 +266,24 @@ def get_developer_by_pk_list(developer_pk_list, f_key, app_search_flag=True): |
|
|
|
return developer_obj |
|
|
|
return developer_obj |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_developer_user_by_app_udid(user_objs, udid, app_obj, private_first=True): |
|
|
|
def get_developer_user_by_app_udid(user_objs, udid, app_obj, private_first=True, read_only=True): |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
:param read_only: |
|
|
|
:param user_objs: [user_obj] |
|
|
|
:param user_objs: [user_obj] |
|
|
|
:param udid: udid |
|
|
|
:param udid: udid |
|
|
|
:param app_obj: app_obj |
|
|
|
:param app_obj: app_obj |
|
|
|
:param private_first: 专属应用优先使用专属开发者,而不是公共开发者 |
|
|
|
:param private_first: 专属应用优先使用专属开发者,而不是公共开发者 |
|
|
|
:return: (developer_obj, is_exist_devices) |
|
|
|
:return: (developer_obj, is_exist_devices) |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if read_only: |
|
|
|
|
|
|
|
status_choice = [1, 2, 3, 4, 5] |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
status_choice = [1] |
|
|
|
|
|
|
|
status_filter = {'developerid__certid__isnull': False, 'developerid__status__in': status_choice} |
|
|
|
|
|
|
|
|
|
|
|
developer_udid_queryset = UDIDsyncDeveloper.objects.filter(developerid__user_id__in=user_objs, |
|
|
|
developer_udid_queryset = UDIDsyncDeveloper.objects.filter(developerid__user_id__in=user_objs, |
|
|
|
developerid__is_actived=True, |
|
|
|
**status_filter).values('developerid').all().distinct() |
|
|
|
developerid__certid__isnull=False).values( |
|
|
|
|
|
|
|
'developerid').all().distinct() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 根据udid和应用查找该用户开发者账户【主要可能是开发者未激活】 |
|
|
|
# 根据udid和应用查找该用户开发者账户【主要可能是开发者未激活】 |
|
|
|
developer_pk_list = developer_udid_queryset.filter(udid=udid, developerid__apptodeveloper__app_id=app_obj) |
|
|
|
developer_pk_list = developer_udid_queryset.filter(udid=udid, developerid__apptodeveloper__app_id=app_obj) |
|
|
@ -317,8 +321,7 @@ def get_developer_user_by_app_udid(user_objs, udid, app_obj, private_first=True) |
|
|
|
exist_app_developer_pk_list.append(developer_obj.pk) |
|
|
|
exist_app_developer_pk_list.append(developer_obj.pk) |
|
|
|
|
|
|
|
|
|
|
|
# 查询状态正常的专属开发者信息,判断是否为专属应用 |
|
|
|
# 查询状态正常的专属开发者信息,判断是否为专属应用 |
|
|
|
apple_to_app = AppleDeveloperToAppUse.objects.filter(app_id=app_obj, developerid__is_actived=True, |
|
|
|
apple_to_app = AppleDeveloperToAppUse.objects.filter(app_id=app_obj, **status_filter).first() |
|
|
|
developerid__certid__isnull=False).first() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 存在专属开发者账户,但是也同时存在已经安装的设备,优先选择已经安装设备的开发者账户?是or否 |
|
|
|
# 存在专属开发者账户,但是也同时存在已经安装的设备,优先选择已经安装设备的开发者账户?是or否 |
|
|
|
# 是:使应用趋向于一个开发者,为后期更新提供方便 |
|
|
|
# 是:使应用趋向于一个开发者,为后期更新提供方便 |
|
|
@ -326,12 +329,15 @@ def get_developer_user_by_app_udid(user_objs, udid, app_obj, private_first=True) |
|
|
|
if not private_first and apple_to_app and exist_app_developer_pk_list: |
|
|
|
if not private_first and apple_to_app and exist_app_developer_pk_list: |
|
|
|
return AppIOSDeveloperInfo.objects.filter(pk=exist_app_developer_pk_list[0]).first(), False |
|
|
|
return AppIOSDeveloperInfo.objects.filter(pk=exist_app_developer_pk_list[0]).first(), False |
|
|
|
|
|
|
|
|
|
|
|
can_used_developer_pk_list = get_new_developer_by_app_obj(user_objs, app_obj, apple_to_app) |
|
|
|
status_filter = {'certid__isnull': False, 'status__in': status_choice} |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
# 存在指定开发者账户,但是获取可用的开发者账户为空,那么开始匹配全部开发者 |
|
|
|
# 存在指定开发者账户,但是获取可用的开发者账户为空,那么开始匹配全部开发者 |
|
|
|
if not can_used_developer_pk_list and apple_to_app: |
|
|
|
if not can_used_developer_pk_list and apple_to_app: |
|
|
|
logger.info(f"udid:{udid} app_obj:{app_obj} private developer is null. start find all developer") |
|
|
|
logger.info(f"udid:{udid} app_obj:{app_obj} private developer is null. start find all developer") |
|
|
|
can_used_developer_pk_list = get_new_developer_by_app_obj(user_objs, app_obj) |
|
|
|
can_used_developer_pk_list = get_new_developer_by_app_obj(app_obj, obj_base_filter) |
|
|
|
|
|
|
|
|
|
|
|
if can_used_developer_pk_list and exist_app_developer_pk_list: |
|
|
|
if can_used_developer_pk_list and exist_app_developer_pk_list: |
|
|
|
can_used_developer_pk_list = list(set(can_used_developer_pk_list) & set(exist_app_developer_pk_list)) |
|
|
|
can_used_developer_pk_list = list(set(can_used_developer_pk_list) & set(exist_app_developer_pk_list)) |
|
|
@ -346,14 +352,14 @@ def get_developer_user_by_app_udid(user_objs, udid, app_obj, private_first=True) |
|
|
|
return None, None |
|
|
|
return None, None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_developer_obj_by_others(user_obj, udid, app_obj): |
|
|
|
def get_developer_obj_by_others(user_obj, udid, app_obj, read_only): |
|
|
|
result, is_exist = get_developer_user_by_app_udid([user_obj], udid, app_obj) |
|
|
|
result, is_exist = get_developer_user_by_app_udid([user_obj], udid, app_obj, read_only=read_only) |
|
|
|
if result: |
|
|
|
if result: |
|
|
|
return result |
|
|
|
return result |
|
|
|
receive_user_id_list = IosDeveloperPublicPoolBill.objects.filter(to_user_id=user_obj).values('user_id').distinct() |
|
|
|
receive_user_id_list = IosDeveloperPublicPoolBill.objects.filter(to_user_id=user_obj).values('user_id').distinct() |
|
|
|
if receive_user_id_list: |
|
|
|
if receive_user_id_list: |
|
|
|
result, is_exist = get_developer_user_by_app_udid(UserInfo.objects.filter(pk__in=receive_user_id_list), udid, |
|
|
|
result, is_exist = get_developer_user_by_app_udid(UserInfo.objects.filter(pk__in=receive_user_id_list), udid, |
|
|
|
app_obj) |
|
|
|
app_obj, read_only=read_only) |
|
|
|
f_count = get_ios_developer_public_num(user_obj) |
|
|
|
f_count = get_ios_developer_public_num(user_obj) |
|
|
|
|
|
|
|
|
|
|
|
if (f_count == 0 and is_exist) or f_count > 0: |
|
|
|
if (f_count == 0 and is_exist) or f_count > 0: |
|
|
@ -370,8 +376,8 @@ class IosUtils(object): |
|
|
|
self.user_obj = user_obj |
|
|
|
self.user_obj = user_obj |
|
|
|
self.get_developer_auth() |
|
|
|
self.get_developer_auth() |
|
|
|
|
|
|
|
|
|
|
|
def get_developer_auth(self): |
|
|
|
def get_developer_auth(self, read_only=True): |
|
|
|
self.developer_obj = get_developer_obj_by_others(self.user_obj, self.udid, self.app_obj) |
|
|
|
self.developer_obj = get_developer_obj_by_others(self.user_obj, self.udid, self.app_obj, read_only) |
|
|
|
if self.developer_obj: |
|
|
|
if self.developer_obj: |
|
|
|
self.auth = get_auth_form_developer(self.developer_obj) |
|
|
|
self.auth = get_auth_form_developer(self.developer_obj) |
|
|
|
else: |
|
|
|
else: |
|
|
@ -399,8 +405,7 @@ class IosUtils(object): |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def modify_capability(developer_obj, app_obj, developer_app_id): |
|
|
|
def modify_capability(developer_obj, app_obj, developer_app_id): |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
return get_api_obj(developer_obj).modify_capability(app_obj, developer_app_id) |
|
|
|
return get_api_obj(auth).modify_capability(app_obj, developer_app_id) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_profile_full_path(self): |
|
|
|
def get_profile_full_path(self): |
|
|
|
cert_dir_name = make_app_uuid(self.user_obj, get_apple_udid_key(self.auth)) |
|
|
|
cert_dir_name = make_app_uuid(self.user_obj, get_apple_udid_key(self.auth)) |
|
|
@ -553,16 +558,18 @@ class IosUtils(object): |
|
|
|
return True, 'continue' |
|
|
|
return True, 'continue' |
|
|
|
sync_device_obj = UDIDsyncDeveloper.objects.filter(udid=device_udid, |
|
|
|
sync_device_obj = UDIDsyncDeveloper.objects.filter(udid=device_udid, |
|
|
|
developerid=developer_obj).first() |
|
|
|
developerid=developer_obj).first() |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
# auth = get_auth_form_developer(developer_obj) |
|
|
|
# 库里面存在,并且设备是可用状态,因此无需api注册 |
|
|
|
# 库里面存在,并且设备是可用状态,因此无需api注册 |
|
|
|
if sync_device_obj: |
|
|
|
if sync_device_obj: |
|
|
|
logger.info(f"app {app_obj} device {sync_device_obj.serial} already in developer {developer_obj}") |
|
|
|
logger.info(f"app {app_obj} device {sync_device_obj.serial} already in developer {developer_obj}") |
|
|
|
if not sync_device_obj.status: |
|
|
|
if not sync_device_obj.status: |
|
|
|
# 库里面存在,并且设备是禁用状态,需要调用api启用 |
|
|
|
# 库里面存在,并且设备是禁用状态,需要调用api启用 |
|
|
|
status, result = get_api_obj(auth).set_device_status("enable", sync_device_obj.serial, |
|
|
|
status, result = get_api_obj(developer_obj).set_device_status("enable", sync_device_obj.serial, |
|
|
|
sync_device_obj.product, sync_device_obj.udid, |
|
|
|
sync_device_obj.product, |
|
|
|
failed_call_prefix, |
|
|
|
sync_device_obj.udid, |
|
|
|
err_callback(IosUtils.get_device_from_developer, |
|
|
|
failed_call_prefix, |
|
|
|
|
|
|
|
err_callback( |
|
|
|
|
|
|
|
IosUtils.get_device_from_developer, |
|
|
|
developer_obj)) |
|
|
|
developer_obj)) |
|
|
|
if not status: # 已经包含异常操作,暂定 |
|
|
|
if not status: # 已经包含异常操作,暂定 |
|
|
|
return status, result |
|
|
|
return status, result |
|
|
@ -570,8 +577,10 @@ class IosUtils(object): |
|
|
|
sync_device_obj.save(update_fields=['status']) |
|
|
|
sync_device_obj.save(update_fields=['status']) |
|
|
|
else: |
|
|
|
else: |
|
|
|
# 库里面不存在,注册设备,新设备注册默认就是启用状态 |
|
|
|
# 库里面不存在,注册设备,新设备注册默认就是启用状态 |
|
|
|
status, device_obj = get_api_obj(auth).register_device(device_udid, device_name, failed_call_prefix, |
|
|
|
status, device_obj = get_api_obj(developer_obj).register_device(device_udid, device_name, |
|
|
|
err_callback(IosUtils.get_device_from_developer, |
|
|
|
failed_call_prefix, |
|
|
|
|
|
|
|
err_callback( |
|
|
|
|
|
|
|
IosUtils.get_device_from_developer, |
|
|
|
developer_obj)) |
|
|
|
developer_obj)) |
|
|
|
if not status: |
|
|
|
if not status: |
|
|
|
return status, device_obj |
|
|
|
return status, device_obj |
|
|
@ -620,11 +629,10 @@ class IosUtils(object): |
|
|
|
developer_app_id_obj = DeveloperAppID.objects.filter(developerid=developer_obj, |
|
|
|
developer_app_id_obj = DeveloperAppID.objects.filter(developerid=developer_obj, |
|
|
|
app_id=app_obj).first() |
|
|
|
app_id=app_obj).first() |
|
|
|
if not developer_app_id_obj: |
|
|
|
if not developer_app_id_obj: |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
|
|
|
|
bundle_id = app_obj.bundle_id |
|
|
|
bundle_id = app_obj.bundle_id |
|
|
|
app_id = app_obj.app_id |
|
|
|
app_id = app_obj.app_id |
|
|
|
s_type = app_obj.supersign_type |
|
|
|
s_type = app_obj.supersign_type |
|
|
|
status, result = get_api_obj(auth).create_app(bundle_id, app_id, s_type, failed_callback) |
|
|
|
status, result = get_api_obj(developer_obj).create_app(bundle_id, app_id, s_type, failed_callback) |
|
|
|
if status and result.get('aid'): |
|
|
|
if status and result.get('aid'): |
|
|
|
developer_app_id_obj = DeveloperAppID.objects.create(aid=result.get('aid'), developerid=developer_obj, |
|
|
|
developer_app_id_obj = DeveloperAppID.objects.create(aid=result.get('aid'), developerid=developer_obj, |
|
|
|
app_id=app_obj) |
|
|
|
app_id=app_obj) |
|
|
@ -659,12 +667,13 @@ class IosUtils(object): |
|
|
|
developer_app_id = developer_app_id_obj.aid |
|
|
|
developer_app_id = developer_app_id_obj.aid |
|
|
|
profile_id = developer_app_id_obj.profile_id |
|
|
|
profile_id = developer_app_id_obj.profile_id |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
status, result = get_api_obj(auth).make_and_download_profile(app_obj, |
|
|
|
status, result = get_api_obj(developer_obj).make_and_download_profile(app_obj, |
|
|
|
get_profile_full_path(developer_obj, app_obj), |
|
|
|
get_profile_full_path(developer_obj, |
|
|
|
auth, developer_app_id, |
|
|
|
app_obj), |
|
|
|
device_id_lists, profile_id, |
|
|
|
auth, developer_app_id, |
|
|
|
failed_call_prefix, failed_callback, |
|
|
|
device_id_lists, profile_id, |
|
|
|
) |
|
|
|
failed_call_prefix, failed_callback, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if not status: |
|
|
|
if not status: |
|
|
|
return False, result |
|
|
|
return False, result |
|
|
@ -690,6 +699,8 @@ class IosUtils(object): |
|
|
|
if result: |
|
|
|
if result: |
|
|
|
return result |
|
|
|
return result |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.get_developer_auth(read_only=False) |
|
|
|
|
|
|
|
|
|
|
|
logger.info("udid %s not exists app_id %s ,need sign" % (self.udid, self.app_obj)) |
|
|
|
logger.info("udid %s not exists app_id %s ,need sign" % (self.udid, self.app_obj)) |
|
|
|
|
|
|
|
|
|
|
|
if consume_user_download_times_by_app_obj(self.app_obj): |
|
|
|
if consume_user_download_times_by_app_obj(self.app_obj): |
|
|
@ -835,8 +846,7 @@ class IosUtils(object): |
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def do_disable_device(developer_obj, udid_lists, udid_obj): |
|
|
|
def do_disable_device(developer_obj, udid_lists, udid_obj): |
|
|
|
if udid_lists.count((udid_obj.udid.udid,)) == 1: |
|
|
|
if udid_lists.count((udid_obj.udid.udid,)) == 1: |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
app_api_obj = get_api_obj(developer_obj) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
|
|
|
|
app_api_obj.set_device_status("disable", udid_obj.udid.serial, udid_obj.udid.product, udid_obj.udid.udid, |
|
|
|
app_api_obj.set_device_status("disable", udid_obj.udid.serial, udid_obj.udid.product, udid_obj.udid.udid, |
|
|
|
udid_obj.udid.udid) |
|
|
|
udid_obj.udid.udid) |
|
|
|
UDIDsyncDeveloper.objects.filter(udid=udid_obj.udid.udid, developerid=developer_obj).update(status=False) |
|
|
|
UDIDsyncDeveloper.objects.filter(udid=udid_obj.udid.udid, developerid=developer_obj).update(status=False) |
|
|
@ -883,12 +893,11 @@ class IosUtils(object): |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def clean_app_by_developer_obj(app_obj, developer_obj): |
|
|
|
def clean_app_by_developer_obj(app_obj, developer_obj): |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
|
|
|
|
developer_app_id_obj = DeveloperAppID.objects.filter(developerid=developer_obj, app_id=app_obj).first() |
|
|
|
developer_app_id_obj = DeveloperAppID.objects.filter(developerid=developer_obj, app_id=app_obj).first() |
|
|
|
if developer_app_id_obj: |
|
|
|
if developer_app_id_obj: |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
app_api_obj = get_api_obj(developer_obj) |
|
|
|
app_api_obj.del_profile(developer_app_id_obj.profile_id, app_obj.app_id) |
|
|
|
app_api_obj.del_profile(developer_app_id_obj.profile_id, app_obj.app_id) |
|
|
|
app_api_obj2 = get_api_obj(auth) |
|
|
|
app_api_obj2 = get_api_obj(developer_obj) |
|
|
|
app_api_obj2.del_app(developer_app_id_obj.aid, app_obj.bundle_id, app_obj.app_id) |
|
|
|
app_api_obj2.del_app(developer_app_id_obj.aid, app_obj.bundle_id, app_obj.app_id) |
|
|
|
developer_app_id_obj.delete() |
|
|
|
developer_app_id_obj.delete() |
|
|
|
|
|
|
|
|
|
|
@ -930,8 +939,7 @@ class IosUtils(object): |
|
|
|
:param developer_obj: |
|
|
|
:param developer_obj: |
|
|
|
:return: |
|
|
|
:return: |
|
|
|
""" |
|
|
|
""" |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
app_api_obj = get_api_obj(developer_obj) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
|
|
|
|
status, result = app_api_obj.active() |
|
|
|
status, result = app_api_obj.active() |
|
|
|
if status: |
|
|
|
if status: |
|
|
|
cert_is_exists = True |
|
|
|
cert_is_exists = True |
|
|
@ -946,10 +954,8 @@ class IosUtils(object): |
|
|
|
IosUtils.clean_developer(developer_obj, developer_obj.user_id) |
|
|
|
IosUtils.clean_developer(developer_obj, developer_obj.user_id) |
|
|
|
developer_obj.certid = None |
|
|
|
developer_obj.certid = None |
|
|
|
developer_obj.cert_expire_time = None |
|
|
|
developer_obj.cert_expire_time = None |
|
|
|
developer_obj.is_actived = True |
|
|
|
developer_obj.status = 1 |
|
|
|
else: |
|
|
|
developer_obj.save(update_fields=['certid', 'cert_expire_time', 'status']) |
|
|
|
developer_obj.is_actived = False |
|
|
|
|
|
|
|
developer_obj.save(update_fields=['certid', 'cert_expire_time', 'is_actived']) |
|
|
|
|
|
|
|
return status, result |
|
|
|
return status, result |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
@ -961,36 +967,32 @@ class IosUtils(object): |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def create_developer_cert(developer_obj, user_obj): |
|
|
|
def create_developer_cert(developer_obj, user_obj): |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
app_api_obj = get_api_obj(developer_obj) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
|
|
|
|
status, result = app_api_obj.create_cert(user_obj) |
|
|
|
status, result = app_api_obj.create_cert(user_obj) |
|
|
|
if status: |
|
|
|
if status: |
|
|
|
if auth.get("issuer_id"): |
|
|
|
cert_id = result.id |
|
|
|
cert_id = result.id |
|
|
|
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( |
|
|
|
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( |
|
|
|
status=1, |
|
|
|
is_actived=True, |
|
|
|
certid=cert_id, cert_expire_time=format_apple_date(result.expirationDate)) |
|
|
|
certid=cert_id, cert_expire_time=format_apple_date(result.expirationDate)) |
|
|
|
resign_app_obj = IosUtils.get_resign_obj(user_obj, developer_obj) |
|
|
|
resign_app_obj = IosUtils.get_resign_obj(user_obj, developer_obj) |
|
|
|
resign_app_obj.make_p12_from_cert(cert_id) |
|
|
|
resign_app_obj.make_p12_from_cert(cert_id) |
|
|
|
|
|
|
|
return status, result |
|
|
|
return status, result |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def revoke_developer_cert(developer_obj, user_obj): |
|
|
|
def revoke_developer_cert(developer_obj, user_obj): |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
app_api_obj = get_api_obj(developer_obj) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
|
|
|
|
status, result = app_api_obj.revoke_cert() |
|
|
|
status, result = app_api_obj.revoke_cert() |
|
|
|
if not status: |
|
|
|
if not status: |
|
|
|
logger.warning('%s revoke cert failed,but i need clean cert_id %s' % (developer_obj.issuer_id, result)) |
|
|
|
logger.warning('%s revoke cert failed,but i need clean cert_id %s' % (developer_obj.issuer_id, result)) |
|
|
|
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( |
|
|
|
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=developer_obj.issuer_id).update( |
|
|
|
is_actived=True, |
|
|
|
status=4, |
|
|
|
certid=None, cert_expire_time=None) |
|
|
|
certid=None, cert_expire_time=None) |
|
|
|
return status, result |
|
|
|
return status, result |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def check_developer_cert(developer_obj, user_obj): |
|
|
|
def check_developer_cert(developer_obj, user_obj): |
|
|
|
# 暂时无用 |
|
|
|
# 暂时无用 |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
app_api_obj = get_api_obj(developer_obj) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
|
|
|
|
status, result = app_api_obj.get_cert_obj_by_cid() |
|
|
|
status, result = app_api_obj.get_cert_obj_by_cid() |
|
|
|
if not status: |
|
|
|
if not status: |
|
|
|
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( |
|
|
|
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( |
|
|
@ -1000,22 +1002,21 @@ class IosUtils(object): |
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def auto_get_cert_id_by_p12(developer_obj, user_obj): |
|
|
|
def auto_get_cert_id_by_p12(developer_obj, user_obj): |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
app_api_obj = get_api_obj(developer_obj) |
|
|
|
file_format_path_name = file_format_path(user_obj, auth) |
|
|
|
file_format_path_name = file_format_path(user_obj, auth) |
|
|
|
app_dev_pem = file_format_path_name + ".pem.bak" |
|
|
|
app_dev_pem = file_format_path_name + ".pem.bak" |
|
|
|
status, result = app_api_obj.auto_set_certid_by_p12(app_dev_pem) |
|
|
|
status, result = app_api_obj.auto_set_certid_by_p12(app_dev_pem) |
|
|
|
if status: |
|
|
|
if status: |
|
|
|
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( |
|
|
|
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( |
|
|
|
is_actived=True, |
|
|
|
status=1, |
|
|
|
certid=result.id, cert_expire_time=format_apple_date(result.expirationDate)) |
|
|
|
certid=result.id, cert_expire_time=format_apple_date(result.expirationDate)) |
|
|
|
return status, result |
|
|
|
return status, result |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def get_device_from_developer(developer_obj): |
|
|
|
def get_device_from_developer(developer_obj): |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
app_api_obj = get_api_obj(developer_obj) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
|
|
|
|
status, result = app_api_obj.get_device() |
|
|
|
status, result = app_api_obj.get_device() |
|
|
|
if status and auth.get("issuer_id"): |
|
|
|
if status and developer_obj.issuer_id: |
|
|
|
|
|
|
|
|
|
|
|
udid_developer_obj_list = UDIDsyncDeveloper.objects.filter(developerid=developer_obj).values_list('udid') |
|
|
|
udid_developer_obj_list = UDIDsyncDeveloper.objects.filter(developerid=developer_obj).values_list('udid') |
|
|
|
udid_developer_list = [x[0] for x in udid_developer_obj_list if len(x) > 0] |
|
|
|
udid_developer_list = [x[0] for x in udid_developer_obj_list if len(x) > 0] |
|
|
|