fix some bugs

super_signature
nineven 5 years ago
parent 68eceea99f
commit ebfa2126a6
  1. 48
      fir_client/src/components/FirSuperSignBase.vue
  2. 10
      fir_client/src/utils/index.js
  3. 1
      fir_ser/api/admin.py
  4. 31
      fir_ser/api/migrations/0006_udidsyncdeveloper.py
  5. 34
      fir_ser/api/models.py
  6. 12
      fir_ser/api/utils/app/iossignapi.py
  7. 83
      fir_ser/api/utils/app/supersignutils.py
  8. 20
      fir_ser/api/utils/serializer.py
  9. 30
      fir_ser/api/views/supersign.py
  10. 9
      fir_ser/supersign/scripts/apple_api.rb

@ -21,6 +21,7 @@
<el-input v-model="editdeveloperinfo.description"></el-input> <el-input v-model="editdeveloperinfo.description"></el-input>
</el-form-item> </el-form-item>
<div style="" > <div style="" >
<el-button v-if="isedit" @click="syncdevices">同步设备信息</el-button>
<el-button @click="updateorcreate">保存</el-button> <el-button @click="updateorcreate">保存</el-button>
<el-button @click="canceledit">取消</el-button> <el-button @click="canceledit">取消</el-button>
</div> </div>
@ -52,7 +53,7 @@
placeholder="输入用户APPID" /> placeholder="输入用户APPID" />
<el-button type="primary" icon="el-icon-search" @click="handleCurrentChange(pagination.currentPage)">搜索</el-button> <el-button type="primary" icon="el-icon-search" @click="handleCurrentChange(pagination.currentPage)">搜索</el-button>
<div style="width: 40%;margin-right: 30px;float:right"> <div style="width: 40%;margin-right: 30px;float:right">
<el-link :underline="false">总设备量{{ developer_used_info.all_usable_number}} 已经使用{{ developer_used_info.all_use_number}} 还剩{{ developer_used_info.now_can_use_number}} 可用</el-link> <el-link :underline="false">总设备量{{ developer_used_info.all_usable_number}} 已经使用平台{{ developer_used_info.all_use_number}} 其他{{developer_used_info.other_used_sum}} 还剩{{developer_used_info.all_usable_number- developer_used_info.flyapp_used_sum}} 可用</el-link>
<el-progress <el-progress
type="line" type="line"
:color="developer_usedColor" :color="developer_usedColor"
@ -70,6 +71,18 @@
prop="email" prop="email"
label="用户" label="用户"
width="220"> width="220">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>开发者账户已使用设备数: {{ scope.row.developer_used_number }}</p>
<p>开发者账户可用设备数: {{ 100-scope.row.developer_used_number }}</p>
<p>由于您设置可用设备数: {{ scope.row.usable_number}} ,所以现在可用设备数: {{ scope.row.usable_number-scope.row.developer_used_number }}</p>
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.email }}</el-tag>
</div>
</el-popover>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="is_actived" prop="is_actived"
@ -85,12 +98,29 @@
prop="usable_number" prop="usable_number"
label="可用设备数" label="可用设备数"
width="100"> width="100">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>可用设备数: {{ scope.row.usable_number-scope.row.developer_used_number }}</p>
<div slot="reference" class="name-wrapper">
<el-tag size="medium"> {{ scope.row.usable_number-scope.row.developer_used_number }}</el-tag>
</div>
</el-popover>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="use_number" prop="use_number"
label="已消耗设备数" label="已消耗设备数"
width="120"> width="120">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>开发者账户已使用设备数本平台: {{ scope.row.use_number }}</p>
<p>开发者账户已使用设备数其他: {{ scope.row.developer_used_other_number }}</p>
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.use_number }}</el-tag>
</div>
</el-popover>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -280,7 +310,7 @@
<script> <script>
import {iosdeveloper, iosdevices, iosdevicesudid, userinfos} from "../restful"; import {iosdeveloper, iosdevices, iosdevicesudid, userinfos} from "../restful";
import {removeAaary} from "../utils"; import {removeAaary,IsNum} from "../utils";
export default { export default {
name: "FirSuperSignBase", name: "FirSuperSignBase",
@ -334,14 +364,8 @@
this.pagination.currentPage=val; this.pagination.currentPage=val;
this.get_data_from_tabname(this.activeName,{"size":this.pagination.pagesize,"page":this.pagination.currentPage}) this.get_data_from_tabname(this.activeName,{"size":this.pagination.pagesize,"page":this.pagination.currentPage})
}, },
IsNum(s){ syncdevices(){
if(s!=null){ this.iosdeveloperFun({"methods":"PUT","data":{"email":this.editdeveloperinfo.email,"act":"syncdevice"}});
var r,re;
re = /\d*/i; //\d,*
r = s.match(re);
return (r==s)?true:false;
}
return false;
}, },
inputcode(developer){ inputcode(developer){
this.$prompt('请输入验证码', '提示', { this.$prompt('请输入验证码', '提示', {
@ -349,7 +373,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
closeOnClickModal:false, closeOnClickModal:false,
}).then(({ value }) => { }).then(({ value }) => {
if(value.toString().length>5 && this.IsNum(value)){ if(value.toString().length>5 && IsNum(value)){
this.iosdeveloperFun({"methods":"PUT","data":{"email":developer.email,"act":"nowactive","code":value.replace(/^\s+|\s+$/g, "")}}); this.iosdeveloperFun({"methods":"PUT","data":{"email":developer.email,"act":"nowactive","code":value.replace(/^\s+|\s+$/g, "")}});
} }
}).catch(() => { }).catch(() => {
@ -461,7 +485,7 @@
if(this.developer_used_info.all_usable_number ===0){ if(this.developer_used_info.all_usable_number ===0){
this.percentage=0 this.percentage=0
}else { }else {
this.percentage=parseInt(this.developer_used_info.all_use_number*100/this.developer_used_info.all_usable_number); this.percentage=parseInt(this.developer_used_info.flyapp_used_sum*100/this.developer_used_info.all_usable_number);
} }
if(this.dialogaddDeveloperVisible){ if(this.dialogaddDeveloperVisible){
this.canceledit(); this.canceledit();

@ -206,3 +206,13 @@ export function deepCopy(source) {
} }
return result; return result;
} }
export function IsNum(s){
if(s!=null){
var r,re;
re = /\d*/i; //\d表示数字,*表示匹配多个数字
r = s.match(re);
return (r==s)?true:false;
}
return false;
}

@ -14,4 +14,5 @@ admin.site.register(AppUDID)
admin.site.register(AppIOSDeveloperInfo) admin.site.register(AppIOSDeveloperInfo)
admin.site.register(APPSuperSignUsedInfo) admin.site.register(APPSuperSignUsedInfo)
admin.site.register(APPToDeveloper) admin.site.register(APPToDeveloper)
admin.site.register(UDIDsyncDeveloper)

@ -0,0 +1,31 @@
# Generated by Django 3.0.3 on 2020-05-05 17:41
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('api', '0005_apptodeveloper_release_file'),
]
operations = [
migrations.CreateModel(
name='UDIDsyncDeveloper',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('udid', models.CharField(db_index=True, max_length=64, verbose_name='udid唯一标识')),
('product', models.CharField(blank=True, max_length=64, null=True, verbose_name='产品')),
('serial', models.CharField(blank=True, max_length=64, null=True, verbose_name='序列号')),
('version', models.CharField(blank=True, max_length=64, null=True, verbose_name='型号')),
('created_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
('developerid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.AppIOSDeveloperInfo', verbose_name='所使用苹果开发者账户')),
],
options={
'verbose_name': 'iOS开发平台同步设备信息',
'verbose_name_plural': 'iOS开发平台同步设备信息',
'unique_together': {('udid', 'developerid')},
},
),
]

@ -6,8 +6,8 @@ from django.contrib.contenttypes.models import ContentType
from api.utils.app.randomstrings import make_random_uuid, make_app_uuid from api.utils.app.randomstrings import make_random_uuid, make_app_uuid
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
######################################## 用户表 ########################################
######################################## 用户表 ########################################
class UserInfo(AbstractUser): class UserInfo(AbstractUser):
@ -55,6 +55,7 @@ class UserInfo(AbstractUser):
self.uid = make_random_uuid() self.uid = make_random_uuid()
super(UserInfo, self).save(*args, **kwargs) super(UserInfo, self).save(*args, **kwargs)
class Token(models.Model): class Token(models.Model):
""" """
The default authorization token model. The default authorization token model.
@ -108,13 +109,14 @@ class Apps(models.Model):
issupersign = models.BigIntegerField(verbose_name="是否超级签名包", default=False) issupersign = models.BigIntegerField(verbose_name="是否超级签名包", default=False)
description = models.TextField('描述', blank=True, null=True, default=None, ) description = models.TextField('描述', blank=True, null=True, default=None, )
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间") updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
class Meta: class Meta:
verbose_name = '应用信息' verbose_name = '应用信息'
verbose_name_plural = "应用信息" verbose_name_plural = "应用信息"
indexes = [models.Index(fields=['app_id']), models.Index(fields=['id', 'user_id', 'type'])] indexes = [models.Index(fields=['app_id']), models.Index(fields=['id', 'user_id', 'type'])]
def __str__(self): def __str__(self):
return "%s %s-%s %s %s" % (self.name,self.get_type_display(),self.short,self.has_combo,self.issupersign) return "%s %s-%s %s" % (self.name, self.get_type_display(), self.short, self.issupersign)
class AppReleaseInfo(models.Model): class AppReleaseInfo(models.Model):
@ -151,7 +153,8 @@ class AppStorage(models.Model):
access_key = models.CharField(max_length=128, blank=True, null=True, verbose_name="存储访问key") access_key = models.CharField(max_length=128, blank=True, null=True, verbose_name="存储访问key")
secret_key = models.CharField(max_length=128, blank=True, null=True, verbose_name="存储访问secret") secret_key = models.CharField(max_length=128, blank=True, null=True, verbose_name="存储访问secret")
bucket_name = models.CharField(max_length=128, blank=True, null=True, verbose_name="存储空间bucket_name") bucket_name = models.CharField(max_length=128, blank=True, null=True, verbose_name="存储空间bucket_name")
domain_name=models.CharField(max_length=128,blank=True, null=True, verbose_name="下载域名",help_text='fly-storage.dvcloud.xin,可以自定义端口') domain_name = models.CharField(max_length=128, blank=True, null=True, verbose_name="下载域名",
help_text='fly-storage.dvcloud.xin,可以自定义端口')
is_https = models.BooleanField(default=True, verbose_name="是否支持https") is_https = models.BooleanField(default=True, verbose_name="是否支持https")
additionalparameters = models.TextField(blank=True, null=True, verbose_name="额外参数", additionalparameters = models.TextField(blank=True, null=True, verbose_name="额外参数",
help_text='阿里云:{"sts_role_arn":"arn信息","endpoint":""} ', default=None) help_text='阿里云:{"sts_role_arn":"arn信息","endpoint":""} ', default=None)
@ -166,6 +169,7 @@ class AppStorage(models.Model):
def __str__(self): def __str__(self):
return "%s %s" % (self.user_id.get_username(), self.name) return "%s %s" % (self.user_id.get_username(), self.name)
class AppUDID(models.Model): class AppUDID(models.Model):
app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP") app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP")
udid = models.CharField(max_length=64, verbose_name="udid唯一标识", db_index=True) udid = models.CharField(max_length=64, verbose_name="udid唯一标识", db_index=True)
@ -179,7 +183,6 @@ class AppUDID(models.Model):
is_signed = models.BooleanField(verbose_name="是否完成签名打包", default=False) is_signed = models.BooleanField(verbose_name="是否完成签名打包", default=False)
binary_file = models.CharField(max_length=128, blank=True, verbose_name="签名包名称", null=True) binary_file = models.CharField(max_length=128, blank=True, verbose_name="签名包名称", null=True)
class Meta: class Meta:
verbose_name = '设备详情' verbose_name = '设备详情'
verbose_name_plural = "设备详情" verbose_name_plural = "设备详情"
@ -188,6 +191,7 @@ class AppUDID(models.Model):
def __str__(self): def __str__(self):
return "%s-%s" % (self.app_id.name, self.udid) return "%s-%s" % (self.app_id.name, self.udid)
class AppIOSDeveloperInfo(models.Model): class AppIOSDeveloperInfo(models.Model):
user_id = models.ForeignKey(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE) user_id = models.ForeignKey(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE)
email = models.EmailField( email = models.EmailField(
@ -210,11 +214,10 @@ class AppIOSDeveloperInfo(models.Model):
verbose_name_plural = "苹果开发者账户" verbose_name_plural = "苹果开发者账户"
unique_together = ('user_id', 'email',) unique_together = ('user_id', 'email',)
def __str__(self): def __str__(self):
return "%s-%s" % (self.user_id, self.email) return "%s-%s" % (self.user_id, self.email)
class APPSuperSignUsedInfo(models.Model): class APPSuperSignUsedInfo(models.Model):
user_id = models.ForeignKey(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE) user_id = models.ForeignKey(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE)
app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP") app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP")
@ -222,6 +225,7 @@ class APPSuperSignUsedInfo(models.Model):
developerid = models.ForeignKey(to="AppIOSDeveloperInfo", on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户") developerid = models.ForeignKey(to="AppIOSDeveloperInfo", on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间") updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
class Meta: class Meta:
verbose_name = '设备使用统计' verbose_name = '设备使用统计'
verbose_name_plural = "设备使用统计" verbose_name_plural = "设备使用统计"
@ -229,6 +233,7 @@ class APPSuperSignUsedInfo(models.Model):
def __str__(self): def __str__(self):
return "%s-%s-%s" % (self.user_id, self.app_id, self.udid) return "%s-%s-%s" % (self.user_id, self.app_id, self.udid)
class APPToDeveloper(models.Model): class APPToDeveloper(models.Model):
app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP") app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP")
developerid = models.ForeignKey(to="AppIOSDeveloperInfo", on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户") developerid = models.ForeignKey(to="AppIOSDeveloperInfo", on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
@ -242,3 +247,20 @@ class APPToDeveloper(models.Model):
def __str__(self): def __str__(self):
return "%s-%s-%s" % (self.developerid, self.app_id, self.binary_file) return "%s-%s-%s" % (self.developerid, self.app_id, self.binary_file)
class UDIDsyncDeveloper(models.Model):
developerid = models.ForeignKey(to="AppIOSDeveloperInfo", on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
udid = models.CharField(max_length=64, verbose_name="udid唯一标识", db_index=True)
product = models.CharField(max_length=64, verbose_name="产品", blank=True, null=True, )
serial = models.CharField(max_length=64, verbose_name="序列号", blank=True, null=True, )
version = models.CharField(max_length=64, verbose_name="型号", blank=True, null=True, )
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
class Meta:
verbose_name = 'iOS开发平台同步设备信息'
verbose_name_plural = "iOS开发平台同步设备信息"
unique_together = ('udid', 'developerid',)
def __str__(self):
return "%s-%s-%s" % (self.product, self.udid, self.developerid)

@ -50,13 +50,15 @@ class AppDeveloperApi(object):
print(e) print(e)
return False return False
def create_cert(self,user_obj): def file_format_path_name(self,user_obj):
cert_dir_name = make_app_uuid(user_obj,self.username) cert_dir_name = make_app_uuid(user_obj,self.username)
cert_dir_path = os.path.join(SUPER_SIGN_ROOT,cert_dir_name) cert_dir_path = os.path.join(SUPER_SIGN_ROOT,cert_dir_name)
if not os.path.isdir(cert_dir_path): if not os.path.isdir(cert_dir_path):
os.makedirs(cert_dir_path) os.makedirs(cert_dir_path)
file_format_path_name = os.path.join(cert_dir_path,cert_dir_name) return os.path.join(cert_dir_path,cert_dir_name)
self.cmd=self.cmd + " cert add '%s'" %(file_format_path_name)
def create_cert(self,user_obj):
self.cmd=self.cmd + " cert add '%s'" %(self.file_format_path_name(user_obj))
result = exec_shell(self.cmd) result = exec_shell(self.cmd)
def get_profile(self,bundleId,app_id,device_udid,device_name,provisionName): def get_profile(self,bundleId,app_id,device_udid,device_name,provisionName):
@ -78,6 +80,10 @@ class AppDeveloperApi(object):
self.cmd=self.cmd + " device add '%s' '%s'" %(device_udid,device_name) self.cmd=self.cmd + " device add '%s' '%s'" %(device_udid,device_name)
result = exec_shell(self.cmd) result = exec_shell(self.cmd)
def get_device(self,user_obj):
self.cmd=self.cmd + " device get '%s' " %(self.file_format_path_name(user_obj))
result = exec_shell(self.cmd)
def add_app(self,bundleId,app_id): def add_app(self,bundleId,app_id):
self.cmd=self.cmd + " app add '%s' '%s'" %(bundleId,app_id) self.cmd=self.cmd + " app add '%s' '%s'" %(bundleId,app_id)
result = exec_shell(self.cmd) result = exec_shell(self.cmd)

@ -7,13 +7,15 @@
import uuid, xmltodict, os, re import uuid, xmltodict, os, re
from fir_ser.settings import SUPER_SIGN_ROOT, MEDIA_ROOT, SERVER_DOMAIN from fir_ser.settings import SUPER_SIGN_ROOT, MEDIA_ROOT, SERVER_DOMAIN
from api.utils.app.iossignapi import AppDeveloperApi, ResignApp from api.utils.app.iossignapi import AppDeveloperApi, ResignApp
from api.models import APPSuperSignUsedInfo, AppUDID, AppIOSDeveloperInfo, AppReleaseInfo,Apps,APPToDeveloper from api.models import APPSuperSignUsedInfo, AppUDID, AppIOSDeveloperInfo, AppReleaseInfo,Apps,APPToDeveloper,UDIDsyncDeveloper
from api.utils.app.randomstrings import make_app_uuid, make_from_user_uuid from api.utils.app.randomstrings import make_app_uuid, make_from_user_uuid
from django.db.models import F from django.db.models import F
from api.utils.storage.storage import Storage,LocalStorage from api.utils.serializer import get_developer_udided
from api.utils.storage.storage import LocalStorage
from api.utils.storage.caches import del_cache_response_by_short from api.utils.storage.caches import del_cache_response_by_short
def udid_bytes_to_dict(xml_stream): def udid_bytes_to_dict(xml_stream):
new_uuid_info = {} new_uuid_info = {}
try: try:
@ -69,7 +71,6 @@ def make_udid_mobileconfig(udid_url, PayloadOrganization, PayloadUUID=uuid.uuid1
def get_post_udid_url(request, short): def get_post_udid_url(request, short):
server_domain = get_http_server_doamin(request) server_domain = get_http_server_doamin(request)
# PATH_INFO = request.META.get('PATH_INFO') # PATH_INFO = request.META.get('PATH_INFO')
# PATH_INFO_lists = PATH_INFO.strip('/').split('/') # PATH_INFO_lists = PATH_INFO.strip('/').split('/')
# PATH_INFO_lists[-1] = 'udid' # PATH_INFO_lists[-1] = 'udid'
@ -123,16 +124,29 @@ class IosUtils(object):
self.auth = auth self.auth = auth
def get_developer_user_by_app_udid(self): def get_developer_user_by_app_udid(self):
usedeviceobj = APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'), app_id=self.app_obj, usedeviceobj = APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'), #app_id=self.app_obj,
user_id=self.user_obj).first() user_id=self.user_obj).first()
if usedeviceobj and usedeviceobj.developerid.use_number < usedeviceobj.developerid.usable_number: #只要账户下面存在udid,就可以使用该苹果开发者账户,避免多个开发者账户下面出现同一个udid
developer_obj = usedeviceobj.developerid if usedeviceobj :#and usedeviceobj.developerid.use_number < usedeviceobj.developerid.usable_number:
developer_obj = usedeviceobj.developeridjj
else:
developer_udid_obj = UDIDsyncDeveloper.objects.filter(udid=self.udid_info.get('udid')).first()
if developer_udid_obj:
developer_obj = developer_udid_obj.developerid
else: else:
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj, is_actived=True, # developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj, is_actived=True,
use_number__lt=F("usable_number")).order_by( # use_number__lt=F("usable_number")).order_by(
"created_time").first() # "created_time").first()
for developer_obj in AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj,
is_actived=True, ).order_by("created_time"):
usable_number = developer_obj.usable_number
flyapp_used = get_developer_udided(developer_obj)[1]
if flyapp_used < usable_number:
return developer_obj return developer_obj
return None
def create_cert(self): def create_cert(self):
app_api_obj = AppDeveloperApi(**self.auth) app_api_obj = AppDeveloperApi(**self.auth)
app_api_obj.create_cert(self.user_obj) app_api_obj.create_cert(self.user_obj)
@ -148,6 +162,7 @@ class IosUtils(object):
developer_obj.is_actived=True developer_obj.is_actived=True
developer_obj.certid=cert_id developer_obj.certid=cert_id
developer_obj.save() developer_obj.save()
def download_profile(self): def download_profile(self):
app_api_obj = AppDeveloperApi(**self.auth) app_api_obj = AppDeveloperApi(**self.auth)
bundleId = self.app_obj.bundle_id bundleId = self.app_obj.bundle_id
@ -156,14 +171,6 @@ class IosUtils(object):
device_name = self.udid_info.get('product') device_name = self.udid_info.get('product')
app_api_obj.get_profile(bundleId, app_id, device_udid, device_name, self.get_profile_full_path()) app_api_obj.get_profile(bundleId, app_id, device_udid, device_name, self.get_profile_full_path())
# def file_format_path(self):
# cert_dir_name = make_app_uuid(self.app_obj.user_id, self.auth.get("username"))
# cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name)
# if not os.path.isdir(cert_dir_path):
# os.makedirs(cert_dir_path)
# file_format_path_name = os.path.join(cert_dir_path, cert_dir_name)
# return file_format_path_name
def get_profile_full_path(self): def get_profile_full_path(self):
cert_dir_name = make_app_uuid(self.user_obj, self.auth.get("username")) cert_dir_name = make_app_uuid(self.user_obj, self.auth.get("username"))
cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name, "profile") cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name, "profile")
@ -201,17 +208,24 @@ class IosUtils(object):
#更新已经完成签名状态,设备消耗记录,和开发者已消耗数量 #更新已经完成签名状态,设备消耗记录,和开发者已消耗数量
AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).update(**newdata) AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).update(**newdata)
if APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'),developerid=self.developer_obj).count() == 0: appsupersign_obj=APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'),developerid=self.developer_obj)
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
developer_obj.save() developer_obj.save()
if not appsupersign_obj.filter(app_id=self.app_obj, user_id=self.user_obj).first():
APPSuperSignUsedInfo.objects.create(app_id=self.app_obj, user_id=self.user_obj, developerid=self.developer_obj, APPSuperSignUsedInfo.objects.create(app_id=self.app_obj, user_id=self.user_obj, developerid=self.developer_obj,
udid=AppUDID.objects.filter(app_id=self.app_obj,udid=self.udid_info.get('udid')).first()) udid__udid=self.udid_info.get('udid'))
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.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'))
if not app_udid_obj:
device=AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).values("serial", 'product', 'udid','version').first()
UDIDsyncDeveloper.objects.create(developerid=self.developer_obj, **device)
#创建 #创建
apptodev_obj=APPToDeveloper.objects.filter(developerid=self.developer_obj,app_id=self.app_obj).first() apptodev_obj=APPToDeveloper.objects.filter(developerid=self.developer_obj,app_id=self.app_obj).first()
if apptodev_obj: if apptodev_obj:
@ -367,8 +381,37 @@ class IosUtils(object):
developer_obj.certid=cert_id developer_obj.certid=cert_id
developer_obj.save() developer_obj.save()
@staticmethod
def get_device_from_developer(developer_obj,user_obj):
auth = {
"username": developer_obj.email,
"password": developer_obj.password,
"certid": developer_obj.certid
}
app_api_obj = AppDeveloperApi(**auth)
app_api_obj.get_device(user_obj)
file_format_path_name = file_format_path(user_obj,auth)
devices_info = ""
try:
with open(file_format_path_name+".devices.info", "r") as f:
devices_info = f.read().replace("\n\t", "").replace("[", "").replace("]", "")
except Exception as e:
print(e)
for devicestr in devices_info.split(">"):
formatdevice = re.findall(r'.*Device id="(.*)",.*name="(.*)",.*udid="(.*?)",.*model=(.*),.*', devicestr)
if formatdevice:
device = {
"serial": formatdevice[0][0],
"product": formatdevice[0][1],
"udid": formatdevice[0][2],
"version": formatdevice[0][3],
}
app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=developer_obj,udid=device.get("udid"))
if app_udid_obj:
pass
else:
UDIDsyncDeveloper.objects.create(developerid=developer_obj,**device)
def file_format_path(user_obj,auth): def file_format_path(user_obj,auth):
cert_dir_name = make_app_uuid(user_obj, auth.get("username")) cert_dir_name = make_app_uuid(user_obj, auth.get("username"))

@ -222,6 +222,26 @@ class DeveloperSerializer(serializers.ModelSerializer):
# depth = 1 # depth = 1
exclude = ["password", "id","user_id"] exclude = ["password", "id","user_id"]
developer_used_number = serializers.SerializerMethodField()
developer_used_other_number = serializers.SerializerMethodField()
def get_developer_used_number(self,obj):
return models.UDIDsyncDeveloper.objects.filter(developerid=obj).count()
def get_developer_used_other_number(self,obj):
return get_developer_udided(obj)[0]
def get_developer_udided(developer_obj):
SuperSignUsed_obj = models.APPSuperSignUsedInfo.objects.filter(developerid=developer_obj )
UDIDsyncDeveloper_obj = models.UDIDsyncDeveloper.objects.filter(developerid=developer_obj)
develoer_udid_lists=[]
supersign_udid_lists=[]
if UDIDsyncDeveloper_obj:
develoer_udid_lists=list(UDIDsyncDeveloper_obj.values_list("udid"))
if SuperSignUsed_obj:
supersign_udid_lists=list(SuperSignUsed_obj.values_list("udid__udid"))
return len(set(develoer_udid_lists)-set(supersign_udid_lists)),len(develoer_udid_lists)
class SuperSignUsedSerializer(serializers.ModelSerializer): class SuperSignUsedSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = models.APPSuperSignUsedInfo model = models.APPSuperSignUsedInfo

@ -8,8 +8,8 @@ from rest_framework.views import APIView
from api.utils.response import BaseResponse 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 api.models import AppIOSDeveloperInfo,APPSuperSignUsedInfo,AppUDID from api.models import AppIOSDeveloperInfo,APPSuperSignUsedInfo,AppUDID,UDIDsyncDeveloper
from api.utils.serializer import DeveloperSerializer, UserInfoSerializer,SuperSignUsedSerializer,DeviceUDIDSerializer from api.utils.serializer import DeveloperSerializer, SuperSignUsedSerializer,DeviceUDIDSerializer,get_developer_udided
from rest_framework.pagination import PageNumberPagination from rest_framework.pagination import PageNumberPagination
from api.utils.app.supersignutils import IosUtils from api.utils.app.supersignutils import IosUtils
from django.db.models import Sum,F from django.db.models import Sum,F
@ -33,18 +33,21 @@ class DeveloperView(APIView):
appid = request.query_params.get("appid", None) appid = request.query_params.get("appid", None)
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user) developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user)
other_used_sum=0
flyapp_used_sum=0
for dev_obj in developer_obj:
other_used,flyapp_used=get_developer_udided(dev_obj)
other_used_sum+=other_used
flyapp_used_sum+=flyapp_used
use_number_obj = developer_obj.filter(is_actived=True) use_number_obj = developer_obj.filter(is_actived=True)
if use_number_obj: if use_number_obj:
use_number_dict=use_number_obj.aggregate(usable_number=Sum('usable_number'),use_number=Sum('use_number')) use_number_dict=use_number_obj.aggregate(usable_number=Sum('usable_number'),use_number=Sum('use_number'))
use_number_dict2=use_number_obj.filter(use_number__lt=F("usable_number")).aggregate(usable_number=Sum('usable_number'),use_number=Sum('use_number'))
now_can_use_number=0
if use_number_dict2 and use_number_dict2.get("usable_number",0) and use_number_dict2.get("use_number", 0):
now_can_use_number = use_number_dict2.get("usable_number",0)-use_number_dict2.get("use_number", 0)
res.use_num={ res.use_num={
"all_usable_number":use_number_dict.get("usable_number", 0), "all_usable_number":use_number_dict.get("usable_number", 0),
"all_use_number":use_number_dict.get("use_number", 0), "all_use_number":use_number_dict.get("use_number", 0),
"now_can_use_number":now_can_use_number "other_used_sum":other_used_sum,
"flyapp_used_sum":flyapp_used_sum,
} }
if appid: if appid:
@ -86,8 +89,17 @@ class DeveloperView(APIView):
pass pass
else: else:
IosUtils.create_developer_cert(developer_obj,request.user) IosUtils.create_developer_cert(developer_obj,request.user)
IosUtils.get_device_from_developer(developer_obj, request.user)
elif act == "syncdevice":
IosUtils.get_device_from_developer(developer_obj,request.user)
else: else:
developer_obj.usable_number=data.get("usable_number",developer_obj.usable_number) try:
usable_number=int(data.get("usable_number",developer_obj.usable_number))
if usable_number >= 0 and usable_number <= 100:
developer_obj.usable_number = usable_number
except Exception as e:
print(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:

@ -17,6 +17,13 @@ class DevelopPortalHandle
File.write(file_format_path_name+".info",cert) File.write(file_format_path_name+".info",cert)
end end
def getDevice(file_format_path_name)
all_devices= Spaceship::Portal.device.all(include_disabled: true)
if 0 < all_devices.length then
File.write(file_format_path_name+".devices.info",all_devices)
end
end
def createApp(appid,appname) def createApp(appid,appname)
app = Spaceship::Portal.app.find(appid) app = Spaceship::Portal.app.find(appid)
if !app then if !app then
@ -115,6 +122,8 @@ end
handle.enableDevice(device_udid) handle.enableDevice(device_udid)
when "disable" when "disable"
handle.disableDevice(device_udid) handle.disableDevice(device_udid)
when "get"
handle.getDevice(device_udid)
end end
when "app" when "app"

Loading…
Cancel
Save