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. 148
      fir_ser/api/models.py
  6. 12
      fir_ser/api/utils/app/iossignapi.py
  7. 87
      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-form-item>
<div style="" >
<el-button v-if="isedit" @click="syncdevices">同步设备信息</el-button>
<el-button @click="updateorcreate">保存</el-button>
<el-button @click="canceledit">取消</el-button>
</div>
@ -52,7 +53,7 @@
placeholder="输入用户APPID" />
<el-button type="primary" icon="el-icon-search" @click="handleCurrentChange(pagination.currentPage)">搜索</el-button>
<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
type="line"
:color="developer_usedColor"
@ -70,6 +71,18 @@
prop="email"
label="用户"
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
prop="is_actived"
@ -85,12 +98,29 @@
prop="usable_number"
label="可用设备数"
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
prop="use_number"
label="已消耗设备数"
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
@ -280,7 +310,7 @@
<script>
import {iosdeveloper, iosdevices, iosdevicesudid, userinfos} from "../restful";
import {removeAaary} from "../utils";
import {removeAaary,IsNum} from "../utils";
export default {
name: "FirSuperSignBase",
@ -334,14 +364,8 @@
this.pagination.currentPage=val;
this.get_data_from_tabname(this.activeName,{"size":this.pagination.pagesize,"page":this.pagination.currentPage})
},
IsNum(s){
if(s!=null){
var r,re;
re = /\d*/i; //\d,*
r = s.match(re);
return (r==s)?true:false;
}
return false;
syncdevices(){
this.iosdeveloperFun({"methods":"PUT","data":{"email":this.editdeveloperinfo.email,"act":"syncdevice"}});
},
inputcode(developer){
this.$prompt('请输入验证码', '提示', {
@ -349,7 +373,7 @@
cancelButtonText: '取消',
closeOnClickModal:false,
}).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, "")}});
}
}).catch(() => {
@ -461,7 +485,7 @@
if(this.developer_used_info.all_usable_number ===0){
this.percentage=0
}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){
this.canceledit();

@ -205,4 +205,14 @@ export function deepCopy(source) {
result[key] = typeof source[key]==='object'? deepCopy(source[key]): source[key];
}
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(APPSuperSignUsedInfo)
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')},
},
),
]

@ -3,11 +3,11 @@ from django.db import models
# Create your models here.
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
######################################## 用户表 ########################################
######################################## 用户表 ########################################
class UserInfo(AbstractUser):
@ -19,9 +19,9 @@ class UserInfo(AbstractUser):
blank=True,
null=True
)
uid = models.CharField(max_length=64, unique=True,db_index=True) # user_id,唯一标识
uid = models.CharField(max_length=64, unique=True, db_index=True) # user_id,唯一标识
mobile = models.BigIntegerField(verbose_name="手机", unique=True, help_text="用于手机验证码登录", null=True)
qq = models.BigIntegerField(verbose_name="QQ", blank=True, null=True, db_index=True)
qq = models.BigIntegerField(verbose_name="QQ", blank=True, null=True, db_index=True)
is_active = models.BooleanField(default=True, verbose_name="账户状态,默认启用")
job = models.TextField("职位", max_length=128, blank=True, null=True)
@ -38,10 +38,10 @@ class UserInfo(AbstractUser):
date_joined = models.DateTimeField(auto_now_add=True, verbose_name="注册时间")
download_times = models.IntegerField(default=100, verbose_name="下载次数")
all_download_times = models.BigIntegerField(default=0, verbose_name="总共下载次数")
domain_name = models.CharField(verbose_name="域名",blank=True,null=True,max_length=64)
history_release_limit = models.IntegerField(default=10,verbose_name="app 历史记录版本",blank=True,null=True)
storage = models.OneToOneField(to='AppStorage',related_name='app_storage',
on_delete=models.SET_NULL, verbose_name="存储",null=True,blank=True)
domain_name = models.CharField(verbose_name="域名", blank=True, null=True, max_length=64)
history_release_limit = models.IntegerField(default=10, verbose_name="app 历史记录版本", blank=True, null=True)
storage = models.OneToOneField(to='AppStorage', related_name='app_storage',
on_delete=models.SET_NULL, verbose_name="存储", null=True, blank=True)
class Meta:
verbose_name = '账户信息'
@ -55,6 +55,7 @@ class UserInfo(AbstractUser):
self.uid = make_random_uuid()
super(UserInfo, self).save(*args, **kwargs)
class Token(models.Model):
"""
The default authorization token model.
@ -92,43 +93,44 @@ class VerifyName(models.Model):
######################################## APP表 ########################################
class Apps(models.Model):
app_id = models.CharField(max_length=64, unique=True,db_index=True) # ,唯一标识
user_id = models.ForeignKey(to="UserInfo",verbose_name="用户ID",on_delete=models.CASCADE)
type_choices = ((0, 'android'),(1, 'ios'))
app_id = models.CharField(max_length=64, unique=True, db_index=True) # ,唯一标识
user_id = models.ForeignKey(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE)
type_choices = ((0, 'android'), (1, 'ios'))
type = models.SmallIntegerField(choices=type_choices, default=0, verbose_name="类型")
name = models.CharField(max_length=32,blank=True, null=True,verbose_name="应用名称")
short = models.CharField(max_length=16,unique=True,verbose_name="短链接",db_index=True)
bundle_id = models.CharField(max_length=64,blank=True,verbose_name="bundle id")
name = models.CharField(max_length=32, blank=True, null=True, verbose_name="应用名称")
short = models.CharField(max_length=16, unique=True, verbose_name="短链接", db_index=True)
bundle_id = models.CharField(max_length=64, blank=True, verbose_name="bundle id")
has_combo = models.OneToOneField(to="Apps", related_name='combo_app_info',
verbose_name="关联应用",on_delete=models.SET_NULL,null=True,blank=True)
verbose_name="关联应用", on_delete=models.SET_NULL, null=True, blank=True)
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
count_hits = models.BigIntegerField(verbose_name="下载次数",default=0)
password = models.CharField(verbose_name="访问密码",default='',help_text='默认 没有密码',max_length=32)
isshow = models.BigIntegerField(verbose_name="下载页可见",default=1)
issupersign = models.BigIntegerField(verbose_name="是否超级签名包",default=False)
count_hits = models.BigIntegerField(verbose_name="下载次数", default=0)
password = models.CharField(verbose_name="访问密码", default='', help_text='默认 没有密码', max_length=32)
isshow = models.BigIntegerField(verbose_name="下载页可见", default=1)
issupersign = models.BigIntegerField(verbose_name="是否超级签名包", default=False)
description = models.TextField('描述', blank=True, null=True, default=None, )
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
class Meta:
verbose_name = '应用信息'
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):
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):
is_master = models.BooleanField(verbose_name="是否master版本",default=True)
release_id = models.CharField(max_length=64, unique=True,verbose_name="release 版本id",db_index=True)
app_id = models.ForeignKey(to="Apps",on_delete=models.CASCADE,verbose_name="属于哪个APP")
build_version = models.CharField(max_length=16,verbose_name="build版本",blank=True)
app_version = models.CharField(max_length=16,verbose_name="app版本",blank=True)
release_choices=((0,'android'),(1,'adhoc'),(2,'Inhouse'),(3,'unknown'))
is_master = models.BooleanField(verbose_name="是否master版本", default=True)
release_id = models.CharField(max_length=64, unique=True, verbose_name="release 版本id", db_index=True)
app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP")
build_version = models.CharField(max_length=16, verbose_name="build版本", blank=True)
app_version = models.CharField(max_length=16, verbose_name="app版本", blank=True)
release_choices = ((0, 'android'), (1, 'adhoc'), (2, 'Inhouse'), (3, 'unknown'))
release_type = models.SmallIntegerField(choices=release_choices, default=0, verbose_name="版本类型")
minimum_os_version = models.CharField(max_length=64,verbose_name="应用可安装的最低系统版本")
minimum_os_version = models.CharField(max_length=64, verbose_name="应用可安装的最低系统版本")
binary_size = models.BigIntegerField(verbose_name="应用大小")
binary_url = models.CharField(max_length=128,blank=True,verbose_name="第三方下载URL")
icon_url = models.CharField(max_length=128,blank=True,verbose_name="图标url")
binary_url = models.CharField(max_length=128, blank=True, verbose_name="第三方下载URL")
icon_url = models.CharField(max_length=128, blank=True, verbose_name="图标url")
changelog = models.TextField('更新日志', blank=True, null=True, default=None, )
udid = models.TextField('ios内测版 udid', blank=True, null=True, default='', )
@ -143,17 +145,18 @@ class AppReleaseInfo(models.Model):
class AppStorage(models.Model):
user_id = models.ForeignKey(to="UserInfo",verbose_name="用户ID",on_delete=models.CASCADE)
name = models.CharField(max_length=64,blank=True, null=True, verbose_name="存储名字")
user_id = models.ForeignKey(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE)
name = models.CharField(max_length=64, blank=True, null=True, verbose_name="存储名字")
# is_used = models.BooleanField(verbose_name="是否使用该存储",default=True)
storage_choices=((0,'本地存储'),(1,'七牛云存储'),(2,'阿里云存储'),(3,'默认存储'))
storage_choices = ((0, '本地存储'), (1, '七牛云存储'), (2, '阿里云存储'), (3, '默认存储'))
storage_type = models.SmallIntegerField(choices=storage_choices, default=3, verbose_name="存储类型")
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")
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,可以自定义端口')
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")
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,可以自定义端口')
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)
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
@ -164,21 +167,21 @@ class AppStorage(models.Model):
verbose_name_plural = "存储配置"
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):
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)
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, )
imei= models.CharField(max_length=64, verbose_name="型号", blank=True, null=True, )
iccid= models.CharField(max_length=64, verbose_name="型号", blank=True, null=True, )
imei = models.CharField(max_length=64, verbose_name="型号", blank=True, null=True, )
iccid = models.CharField(max_length=64, verbose_name="型号", blank=True, null=True, )
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
is_signed = models.BooleanField(verbose_name="是否完成签名打包",default=False)
binary_file = models.CharField(max_length=128,blank=True,verbose_name="签名包名称",null=True)
is_signed = models.BooleanField(verbose_name="是否完成签名打包", default=False)
binary_file = models.CharField(max_length=128, blank=True, verbose_name="签名包名称", null=True)
class Meta:
verbose_name = '设备详情'
@ -186,21 +189,22 @@ class AppUDID(models.Model):
unique_together = ('app_id', 'udid',)
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):
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(
verbose_name='email address',
max_length=64,
blank=True,
null=True
)
password = models.CharField(max_length=64,)
is_actived = models.BooleanField(default=False,verbose_name="是否已经激活")
certid = models.CharField(max_length=64,blank=True,verbose_name="超级签名自动创建证书ID",null=True)
usable_number = models.IntegerField(verbose_name="可使用设备数",default=100)
use_number = models.IntegerField(verbose_name="已消耗设备数",default=0)
password = models.CharField(max_length=64, )
is_actived = models.BooleanField(default=False, verbose_name="是否已经激活")
certid = models.CharField(max_length=64, blank=True, verbose_name="超级签名自动创建证书ID", null=True)
usable_number = models.IntegerField(verbose_name="可使用设备数", default=100)
use_number = models.IntegerField(verbose_name="已消耗设备数", default=0)
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
description = models.TextField('备注', blank=True, null=True, default='')
@ -210,30 +214,31 @@ class AppIOSDeveloperInfo(models.Model):
verbose_name_plural = "苹果开发者账户"
unique_together = ('user_id', 'email',)
def __str__(self):
return "%s-%s" % (self.user_id,self.email)
return "%s-%s" % (self.user_id, self.email)
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")
udid = models.ForeignKey(to="AppUDID",on_delete=models.CASCADE, verbose_name="所消耗的udid")
developerid = models.ForeignKey(to="AppIOSDeveloperInfo",on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
udid = models.ForeignKey(to="AppUDID", on_delete=models.CASCADE, verbose_name="所消耗的udid")
developerid = models.ForeignKey(to="AppIOSDeveloperInfo", on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
class Meta:
verbose_name = '设备使用统计'
verbose_name_plural = "设备使用统计"
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):
app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP")
developerid = models.ForeignKey(to="AppIOSDeveloperInfo",on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
binary_file = models.CharField(max_length=128,blank=True,verbose_name="签名包名称",null=True,unique=True)
release_file = models.CharField(max_length=128,blank=True,verbose_name="源包名称",null=True)
developerid = models.ForeignKey(to="AppIOSDeveloperInfo", on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
binary_file = models.CharField(max_length=128, blank=True, verbose_name="签名包名称", null=True, unique=True)
release_file = models.CharField(max_length=128, blank=True, verbose_name="源包名称", null=True)
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
class Meta:
@ -241,4 +246,21 @@ class APPToDeveloper(models.Model):
verbose_name_plural = "应用开发者绑定"
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)
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_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)
self.cmd=self.cmd + " cert add '%s'" %(file_format_path_name)
return os.path.join(cert_dir_path,cert_dir_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)
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)
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):
self.cmd=self.cmd + " app add '%s' '%s'" %(bundleId,app_id)
result = exec_shell(self.cmd)

@ -7,13 +7,15 @@
import uuid, xmltodict, os, re
from fir_ser.settings import SUPER_SIGN_ROOT, MEDIA_ROOT, SERVER_DOMAIN
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 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
def udid_bytes_to_dict(xml_stream):
new_uuid_info = {}
try:
@ -69,7 +71,6 @@ def make_udid_mobileconfig(udid_url, PayloadOrganization, PayloadUUID=uuid.uuid1
def get_post_udid_url(request, short):
server_domain = get_http_server_doamin(request)
# PATH_INFO = request.META.get('PATH_INFO')
# PATH_INFO_lists = PATH_INFO.strip('/').split('/')
# PATH_INFO_lists[-1] = 'udid'
@ -123,15 +124,28 @@ class IosUtils(object):
self.auth = auth
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()
if usedeviceobj and usedeviceobj.developerid.use_number < usedeviceobj.developerid.usable_number:
developer_obj = usedeviceobj.developerid
#只要账户下面存在udid,就可以使用该苹果开发者账户,避免多个开发者账户下面出现同一个udid
if usedeviceobj :#and usedeviceobj.developerid.use_number < usedeviceobj.developerid.usable_number:
developer_obj = usedeviceobj.developeridjj
else:
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj, is_actived=True,
use_number__lt=F("usable_number")).order_by(
"created_time").first()
return developer_obj
developer_udid_obj = UDIDsyncDeveloper.objects.filter(udid=self.udid_info.get('udid')).first()
if developer_udid_obj:
developer_obj = developer_udid_obj.developerid
else:
# developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj, is_actived=True,
# use_number__lt=F("usable_number")).order_by(
# "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 None
def create_cert(self):
app_api_obj = AppDeveloperApi(**self.auth)
@ -148,6 +162,7 @@ class IosUtils(object):
developer_obj.is_actived=True
developer_obj.certid=cert_id
developer_obj.save()
def download_profile(self):
app_api_obj = AppDeveloperApi(**self.auth)
bundleId = self.app_obj.bundle_id
@ -156,14 +171,6 @@ class IosUtils(object):
device_name = self.udid_info.get('product')
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):
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")
@ -201,17 +208,24 @@ class IosUtils(object):
#更新已经完成签名状态,设备消耗记录,和开发者已消耗数量
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.use_number=developer_obj.use_number + 1
developer_obj.save()
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())
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,
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'))
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()
if apptodev_obj:
@ -367,8 +381,37 @@ class IosUtils(object):
developer_obj.certid=cert_id
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):
cert_dir_name = make_app_uuid(user_obj, auth.get("username"))

@ -222,6 +222,26 @@ class DeveloperSerializer(serializers.ModelSerializer):
# depth = 1
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 Meta:
model = models.APPSuperSignUsedInfo

@ -8,8 +8,8 @@ from rest_framework.views import APIView
from api.utils.response import BaseResponse
from api.utils.auth import ExpiringTokenAuthentication
from rest_framework.response import Response
from api.models import AppIOSDeveloperInfo,APPSuperSignUsedInfo,AppUDID
from api.utils.serializer import DeveloperSerializer, UserInfoSerializer,SuperSignUsedSerializer,DeviceUDIDSerializer
from api.models import AppIOSDeveloperInfo,APPSuperSignUsedInfo,AppUDID,UDIDsyncDeveloper
from api.utils.serializer import DeveloperSerializer, SuperSignUsedSerializer,DeviceUDIDSerializer,get_developer_udided
from rest_framework.pagination import PageNumberPagination
from api.utils.app.supersignutils import IosUtils
from django.db.models import Sum,F
@ -33,18 +33,21 @@ class DeveloperView(APIView):
appid = request.query_params.get("appid", None)
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)
if use_number_obj:
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={
"all_usable_number":use_number_dict.get("usable_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:
@ -86,8 +89,17 @@ class DeveloperView(APIView):
pass
else:
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:
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)
password = data.get("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)
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)
app = Spaceship::Portal.app.find(appid)
if !app then
@ -115,6 +122,8 @@ end
handle.enableDevice(device_udid)
when "disable"
handle.disableDevice(device_udid)
when "get"
handle.getDevice(device_udid)
end
when "app"

Loading…
Cancel
Save