|
@@ -33,6 +33,8 @@ class LangAVSSView(TemplateView):
|
|
|
return self.do_delete(request_dict, response)
|
|
|
elif operation == 'add_single':
|
|
|
return self.do_add_single(request_dict, response)
|
|
|
+ elif operation == 'translate':
|
|
|
+ return self.do_translate(request_dict, response)
|
|
|
else:
|
|
|
return response.json(404)
|
|
|
|
|
@@ -118,7 +120,8 @@ class LangAVSSView(TemplateView):
|
|
|
for location in locations:
|
|
|
# print(location['filename'])
|
|
|
# print(location['line'])
|
|
|
- langlocaltionmodel = LangLocationModel.objects.filter(lk=lkModel, filename=location['filename'])
|
|
|
+ langlocaltionmodel = LangLocationModel.objects.filter(lk=lkModel,
|
|
|
+ filename=location['filename'])
|
|
|
if langlocaltionmodel.exists():
|
|
|
langlocaltionmodel.update(line=location['line'])
|
|
|
else:
|
|
@@ -235,13 +238,13 @@ class LangAVSSView(TemplateView):
|
|
|
print(word_key_type)
|
|
|
lk_qs = LangKeyModel.objects.filter(word_key=word_key)
|
|
|
if lk_qs.exists():
|
|
|
- # lk = lk_qs[0]
|
|
|
- # if lk.type == 2:
|
|
|
- # lk.type = 0
|
|
|
- # lk.save()
|
|
|
- # else:
|
|
|
- # lk_qs.delete()
|
|
|
- # LangValModel.objects.filter(lk__word_key=word_key).delete()
|
|
|
+ # lk = lk_qs[0]
|
|
|
+ # if lk.type == 2:
|
|
|
+ # lk.type = 0
|
|
|
+ # lk.save()
|
|
|
+ # else:
|
|
|
+ # lk_qs.delete()
|
|
|
+ # LangValModel.objects.filter(lk__word_key=word_key).delete()
|
|
|
lk = lk_qs[0]
|
|
|
print(lk.type)
|
|
|
if lk.type < word_key_type:
|
|
@@ -261,3 +264,23 @@ class LangAVSSView(TemplateView):
|
|
|
return response.json(0)
|
|
|
else:
|
|
|
return response.json(444)
|
|
|
+
|
|
|
+ def do_translate(self, request_dict, response):
|
|
|
+ print("进来了")
|
|
|
+ lang = request_dict.get('lang', None)
|
|
|
+ if not lang:
|
|
|
+ return response.json(444)
|
|
|
+ langkeymodel = LangKeyModel.objects.filter(langvalmodel__la__lang=lang, type__in=(2, 3, 6, 7)).values(
|
|
|
+ 'word_key',
|
|
|
+ 'langkeyclassmodel__clazz__name',
|
|
|
+ 'langvalmodel__word_val')
|
|
|
+ result = {}
|
|
|
+ for item in langkeymodel:
|
|
|
+ classname = item['langkeyclassmodel__clazz__name']
|
|
|
+ key = item['word_key']
|
|
|
+ value = item['langvalmodel__word_val']
|
|
|
+ if classname not in result:
|
|
|
+ result[classname] = {key: value}
|
|
|
+ else:
|
|
|
+ result[classname][key] = value
|
|
|
+ return response.json(0, result)
|