前端页面增加苹果开发者p8key 用户添加

super_sign_new
nineven 4 years ago
parent 068561ae99
commit 4da62f86b9
  1. 86
      fir_client/src/components/FirSuperSignBase.vue
  2. 37
      fir_ser/api/migrations/0014_auto_20210129_1600.py
  3. 18
      fir_ser/api/migrations/0015_auto_20210129_1730.py
  4. 16
      fir_ser/api/models.py
  5. 2
      fir_ser/api/utils/serializer.py
  6. 38
      fir_ser/api/views/supersign.py

@ -7,6 +7,23 @@
<el-form ref="storageinfoform" :model="editdeveloperinfo"
label-width="80px" style="margin:0 auto;">
<div v-if="editdeveloperinfo.auth_type===0">
<el-form-item label-width="110px" label="issuer_id">
<el-input :disabled='isedit' v-model="editdeveloperinfo.issuer_id"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="private_key_id">
<el-input v-model="editdeveloperinfo.private_key_id"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="p8key">
<el-input type="textarea"
:rows="6" v-model="editdeveloperinfo.p8key" :placeholder="placeholder"></el-input>
</el-form-item>
</div>
<div v-if="editdeveloperinfo.auth_type===1">
<el-form-item label-width="110px" label="APP_ID">
<el-input :disabled='isedit' v-model="editdeveloperinfo.email"></el-input>
</el-form-item>
@ -14,6 +31,8 @@
<el-form-item label-width="110px" label="password">
<el-input v-model="editdeveloperinfo.password" :placeholder="placeholder"></el-input>
</el-form-item>
</div>
<el-form-item label-width="110px" label="设备数量">
<el-input v-model="editdeveloperinfo.usable_number"></el-input>
</el-form-item>
@ -91,7 +110,7 @@
fixed
prop="email"
label="用户"
width="220">
width="300">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>开发者账户已使用设备数: {{ scope.row.developer_used_number }}</p>
@ -101,7 +120,12 @@
?scope.row.usable_number-scope.row.developer_used_number :0 }}</p>
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.email }}</el-tag>
<el-tag size="medium" v-if="scope.row.email"><i class="el-icon-s-custom"></i> {{
scope.row.email }}
</el-tag>
<el-tag size="medium" v-if="scope.row.issuer_id"><i class="el-icon-key"></i> {{
scope.row.issuer_id }}
</el-tag>
</div>
</el-popover>
</template>
@ -139,7 +163,7 @@
<el-table-column
prop="usable_number"
label="可用设备"
width="100">
width="60">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>可用设备数: {{ scope.row.usable_number-scope.row.developer_used_number > 0
@ -156,7 +180,7 @@
<el-table-column
prop="use_number"
label="设备消耗"
width="100">
width="60">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>开发者账户已使用设备数本平台: {{ scope.row.use_number }}</p>
@ -205,6 +229,29 @@
<el-form ref="storageinfoform" :model="editdeveloperinfo"
label-width="80px" style="margin:0 auto;">
<el-form-item label-width="100px" label="认证类型">
<el-select v-model="editdeveloperinfo.auth_type" placeholder="认证类型"
style="margin-left: -100px">
<el-option v-for="st in apple_auth_list" :key="st.id" :label="st.name"
:value="st.id"></el-option>
</el-select>
</el-form-item>
<div v-if="editdeveloperinfo.auth_type===0">
<el-form-item label-width="110px" label="issuer_id">
<el-input :disabled='isedit' v-model="editdeveloperinfo.issuer_id"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="private_key_id">
<el-input v-model="editdeveloperinfo.private_key_id" :placeholder="placeholder"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="p8key">
<el-input type="textarea"
:rows="6" v-model="editdeveloperinfo.p8key" :placeholder="placeholder"></el-input>
</el-form-item>
</div>
<div v-if="editdeveloperinfo.auth_type===1">
<el-form-item label-width="110px" label="APP_ID">
<el-input :disabled='isedit' v-model="editdeveloperinfo.email"></el-input>
</el-form-item>
@ -212,6 +259,9 @@
<el-form-item label-width="110px" label="password">
<el-input v-model="editdeveloperinfo.password" :placeholder="placeholder"></el-input>
</el-form-item>
</div>
<el-form-item label-width="110px" label="设备数量">
<el-input v-model="editdeveloperinfo.usable_number"></el-input>
</el-form-item>
@ -401,7 +451,7 @@
appidseach: "",
dialogaddDeveloperVisible: false,
title: "",
editdeveloperinfo: {},
editdeveloperinfo: {auth_type: 0},
isedit: false,
placeholder: "",
codeactiveVisible: false,
@ -410,6 +460,8 @@
percentage: 0,
authcode: "",
authemail: "",
apple_auth_list: [],
apple_auth_type: 0
}
},
methods: {
@ -479,7 +531,7 @@
},
canceledit() {
this.dialogaddDeveloperVisible = false;
this.editdeveloperinfo = {};
this.editdeveloperinfo = {auth_type: 0};
this.isedit = false;
this.placeholder = ""
},
@ -488,17 +540,29 @@
this.title = '编辑开发者账户';
this.dialogaddDeveloperVisible = true;
this.isedit = true;
this.placeholder = "为空表示不修改密码"
this.placeholder = "为空表示不修改该信息"
},
updateorcreate() {
if (this.isedit) {
this.iosdeveloperFun({"methods": "PUT", "data": this.editdeveloperinfo})
} else {
if (this.editdeveloperinfo.auth_type === 1) {
if (this.editdeveloperinfo.email && this.editdeveloperinfo.password && this.editdeveloperinfo.usable_number) {
this.iosdeveloperFun({"methods": "POST", "data": this.editdeveloperinfo});
} else {
this.$message.warning("输入格式有误")
}
} else if (this.editdeveloperinfo.auth_type === 0) {
if (this.editdeveloperinfo.issuer_id && this.editdeveloperinfo.private_key_id && this.editdeveloperinfo.usable_number && this.editdeveloperinfo.p8key) {
this.iosdeveloperFun({"methods": "POST", "data": this.editdeveloperinfo});
} else {
this.$message.warning("输入格式有误")
}
} else {
this.$message.error("输入格式有误")
}
}
},
handleDeleteDeveloper(developer_info) {
@ -527,6 +591,7 @@
} else if (tabname === "devicesudid") {
this.iosdevicesudidFun('GET', data)
} else if (tabname === "adddeveloper") {
this.iosdeveloperFun({"methods": "GET", "data": data})
// this.title='';
// this.dialogaddDeveloperVisible=true;
} else if (tabname === "iosdeveloper") {
@ -577,6 +642,7 @@
if (data.code === 1000) {
this.app_developer_lists = data.data;
this.pagination.total = data.count;
this.apple_auth_list = data.apple_auth_list;
loading.close();
if (data.use_num) {
this.developer_used_info = data.use_num;
@ -589,12 +655,12 @@
this.canceledit();
this.$message.success("操作成功");
this.activeName = "iosdeveloper";
this.editdeveloperinfo = {};
this.editdeveloperinfo = {auth_type: 0};
}
if (!this.edit && this.editdeveloperinfo.email) {
if (!this.edit && (this.editdeveloperinfo.email || this.editdeveloperinfo.issuer_id)) {
this.$message.success("添加成功");
this.activeName = "iosdeveloper";
this.editdeveloperinfo = {};
this.editdeveloperinfo = {auth_type: 0};
}
} else if (data.code === 1008) {
this.$message.error(data.msg);

@ -0,0 +1,37 @@
# Generated by Django 3.0.3 on 2021-01-29 16:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0013_auto_20210128_1815'),
]
operations = [
migrations.AddField(
model_name='appiosdeveloperinfo',
name='auth_type',
field=models.SmallIntegerField(choices=[(0, 'p8key认证'), (1, '用户名密码认证')], default=0, verbose_name='认证类型'),
),
migrations.AddField(
model_name='appiosdeveloperinfo',
name='issuer_id',
field=models.CharField(blank=True, max_length=64, null=True, verbose_name='标识创建认证令牌的发放者'),
),
migrations.AddField(
model_name='appiosdeveloperinfo',
name='p8key',
field=models.CharField(blank=True, max_length=512, null=True, verbose_name='p8key'),
),
migrations.AddField(
model_name='appiosdeveloperinfo',
name='private_key_id',
field=models.CharField(blank=True, max_length=64, null=True, verbose_name='密钥 ID'),
),
migrations.AlterUniqueTogether(
name='appiosdeveloperinfo',
unique_together={('user_id', 'issuer_id'), ('user_id', 'email')},
),
]

@ -0,0 +1,18 @@
# Generated by Django 3.0.3 on 2021-01-29 17:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0014_auto_20210129_1600'),
]
operations = [
migrations.AlterField(
model_name='appiosdeveloperinfo',
name='p8key',
field=models.TextField(blank=True, max_length=512, null=True, verbose_name='p8key'),
),
]

@ -224,11 +224,25 @@ class AppIOSDeveloperInfo(models.Model):
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='')
issuer_id = models.CharField(max_length=64, blank=True, null=True, verbose_name="标识创建认证令牌的发放者")
private_key_id = models.CharField(max_length=64, blank=True, null=True, verbose_name="密钥 ID")
p8key = models.TextField(max_length=512, blank=True, null=True, verbose_name="p8key")
auth_type_choices = ((0, 'p8key认证'), (1, '用户名密码认证'))
auth_type = models.SmallIntegerField(choices=auth_type_choices, default=0, verbose_name="认证类型")
class Meta:
verbose_name = '苹果开发者账户'
verbose_name_plural = "苹果开发者账户"
unique_together = ('user_id', 'email',)
unique_together = (('user_id', 'email',), ('user_id', 'issuer_id'))
def save(self, *args, **kwargs):
if self.auth_type == 0:
if self.issuer_id and self.private_key_id and self.p8key:
return super(AppIOSDeveloperInfo, self).save(*args, **kwargs)
if self.auth_type == 1:
if self.email and self.password:
return super(AppIOSDeveloperInfo, self).save(*args, **kwargs)
raise
def __str__(self):
return "%s-%s" % (self.user_id, self.email)

@ -232,7 +232,7 @@ class DeveloperSerializer(serializers.ModelSerializer):
class Meta:
model = models.AppIOSDeveloperInfo
# depth = 1
exclude = ["password", "id", "user_id"]
exclude = ["password", "id", "user_id", "p8key"]
developer_used_number = serializers.SerializerMethodField()
developer_used_other_number = serializers.SerializerMethodField()

@ -38,23 +38,37 @@ class DeveloperView(APIView):
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user)
res.use_num = get_developer_devices(developer_obj)
if appid:
developer_obj = developer_obj.filter(email=appid)
developer_obj1 = developer_obj.filter(email=appid)
developer_obj2 = developer_obj.filter(issuer_id=appid)
developer_obj = developer_obj1 | developer_obj2
page_obj = AppsPageNumber()
app_page_serializer = page_obj.paginate_queryset(queryset=developer_obj.order_by("-updated_time"),
request=request,
view=self)
Developer_serializer = DeveloperSerializer(app_page_serializer, many=True, )
developer_serializer = DeveloperSerializer(app_page_serializer, many=True, )
res.data = Developer_serializer.data
res.data = developer_serializer.data
res.count = developer_obj.count()
res.apple_auth_list = []
apple_auth_org_list = list(AppIOSDeveloperInfo.auth_type_choices)
for auth_t in apple_auth_org_list:
res.apple_auth_list.append({'id': auth_t[0], 'name': auth_t[1]})
return Response(res.dict)
def put(self, request):
data = request.data
email = data.get("email", None)
issuer_id = data.get("issuer_id", None)
if email:
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user, email=email).first()
elif issuer_id:
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user, issuer_id=issuer_id).first()
else:
return self.get(request)
if developer_obj:
act = data.get("act", None)
if act:
@ -114,7 +128,7 @@ class DeveloperView(APIView):
request.user, developer_obj, developer_obj.__dict__))
try:
usable_number = int(data.get("usable_number", developer_obj.usable_number))
if usable_number >= 0 and usable_number <= 100:
if 0 <= usable_number <= 100:
developer_obj.usable_number = usable_number
except Exception as e:
logger.error("developer %s usable_number %s get failed Exception:%s" % (
@ -124,6 +138,11 @@ class DeveloperView(APIView):
if password != "" and password != developer_obj.password:
developer_obj.password = password
developer_obj.is_actived = False
developer_obj.private_key_id = data.get("private_key_id", developer_obj.private_key_id)
p8key = data.get("p8key", developer_obj.p8key)
if p8key != "" and p8key != developer_obj.p8key:
developer_obj.p8key = p8key
developer_obj.is_actived = False
try:
developer_obj.save()
logger.info("user %s iosdeveloper %s update now data %s" % (
@ -136,11 +155,22 @@ class DeveloperView(APIView):
def post(self, request):
data = request.data
if data.get("auth_type") == 0:
datainfo = {
"usable_number": data.get("usable_number", ""),
"description": data.get("description", ""),
"issuer_id": data.get("issuer_id", ""),
"private_key_id": data.get("private_key_id", ""),
"p8key": data.get("p8key", ""),
"auth_type": 0
}
else:
datainfo = {
"usable_number": data.get("usable_number", ""),
"description": data.get("description", ""),
"password": data.get("password", ""),
"email": data.get("email", ""),
"auth_type": 1
}
try:
logger.error("user %s add new developer %s data %s" % (

Loading…
Cancel
Save