Remove debug_upload functionality and fix 404 error handling in system settings

This commit is contained in:
Fam Zheng 2025-11-25 23:51:14 +00:00
parent 9060186edb
commit 94472f1b49
2 changed files with 10 additions and 74 deletions

View File

@ -1773,43 +1773,6 @@ class LogReportView(BaseView):
SystemLog.objects.create(log=json.dumps(log))
return JsonResponse({})
class DebugUploadView(BaseView):
name = 'debug-upload'
def post(self, request):
image, fn = get_image(request)
if not image:
return JsonResponse({"error": "image not found in request"})
qrcode = request.data.get('qrcode').split("code=")[-1]
phonemodel = request.data.get('phonemodel')
phonemodel = phonemodel.split("<")[0].strip().replace(" ", "")
r = GlobalConfig.objects.filter(name='debug_upload_dir').first()
if r:
upload_dir = r.get_value()
else:
upload_dir = "default"
save_dir = "/emblem/data/debug-upload/{}/{}".format(upload_dir, phonemodel)
if not os.path.exists(save_dir):
os.makedirs(save_dir)
r = GlobalConfig.objects.filter(name='debug_upload_neg_or_pos').first()
if r:
neg_or_pos = r.get_value();
else:
neg_or_pos = "unknown"
with tempfile.NamedTemporaryFile(suffix=fn) as tf:
tf.write(image)
tf.flush()
ts = time.time()
save_file = os.path.join(save_dir, "{}_{}_{}_{}.jpg".format(qrcode, neg_or_pos, phonemodel, ts))
url = 'http://alg:3028/alg/rectify'
with open(tf.name, 'rb') as tfr:
r = requests.post(url, data=tfr)
r.raise_for_status()
with open(save_file, 'wb') as sfw:
sfw.write(r.content)
return JsonResponse({"info": "ok"})
def make_camera_rules(q):
def make_camera_config_obj(cc):
return {

View File

@ -5,18 +5,6 @@
<hr>
<div>
<hr>
<div class="section mb-2">
<h4>数据采集模式配置</h4>
<div>
保存目录
<input type="text" class="form-control" v-model="debug_upload_dir" />
</div>
<div>
类别标签
<input type="text" class="form-control" v-model="debug_upload_neg_or_pos" />
</div>
<button class="my-1 btn btn-primary" @click="save_debug_upload_configs">保存</button>
</div>
<div class="section mb-2">
<h4>默认验证模型配置</h4>
<div>
@ -56,8 +44,6 @@ export default {
},
data: function () {
return {
debug_upload_dir: '',
debug_upload_neg_or_pos: '',
verification_models: [],
default_verification_model_id: '',
};
@ -66,36 +52,23 @@ export default {
},
methods: {
async reload() {
var r = await this.$root.api_get("/api/v1/global-config/?name=debug_upload_dir");
this.debug_upload_dir = r.data.value || '';
r = await this.$root.api_get("/api/v1/global-config/?name=debug_upload_neg_or_pos");
this.debug_upload_neg_or_pos = r.data.value || '';
// Load verification models
r = await this.$root.api_get_all("/api/v1/verification-model/");
this.verification_models = r;
// Load default verification model
try {
r = await this.$root.api_get("/api/v1/global-config/?name=default_verification_model");
var r = await this.$root.api_get_all("/api/v1/verification-model/");
this.verification_models = r;
} catch (e) {
this.verification_models = [];
}
// Load default verification model - treat 404 as empty
try {
var r = await this.$root.api_get("/api/v1/global-config/?name=default_verification_model");
this.default_verification_model_id = r.data.value || '';
} catch (e) {
// 404 or any other error - treat as empty/default
this.default_verification_model_id = '';
}
},
async save_debug_upload_configs() {
await this.$root.api_post("/api/v1/global-config/", {
name: 'debug_upload_dir',
value: this.debug_upload_dir,
});
await this.$root.api_post("/api/v1/global-config/", {
name: 'debug_upload_neg_or_pos',
value: this.debug_upload_neg_or_pos,
});
await this.reload();
this.$root.notify("保存成功", "数据采集模式配置已更新");
},
async save_default_verification_model() {
await this.$root.api_post("/api/v1/global-config/", {
name: 'default_verification_model',