|
@@ -34,7 +34,7 @@ class RegionCountryView(View):
|
|
if operation == 'initUserRegion':
|
|
if operation == 'initUserRegion':
|
|
return self.do_initUserRegion(token.userID, request_dict, response)
|
|
return self.do_initUserRegion(token.userID, request_dict, response)
|
|
elif operation == 'initRegionDate':
|
|
elif operation == 'initRegionDate':
|
|
- return self.do_initRegionDate(token.userID, request_dict, response)
|
|
|
|
|
|
+ return self.do_initRegionDate(request_dict, response)
|
|
else:
|
|
else:
|
|
return response.json(404)
|
|
return response.json(404)
|
|
|
|
|
|
@@ -47,11 +47,13 @@ class RegionCountryView(View):
|
|
|
|
|
|
def do_initRegionDate(self, request_dict, response):
|
|
def do_initRegionDate(self, request_dict, response):
|
|
filepath = request_dict.get('filepath')
|
|
filepath = request_dict.get('filepath')
|
|
- fobj = open(filepath)
|
|
|
|
- region_list = json.loads(fobj)
|
|
|
|
|
|
|
|
- now_time = int(time.time())
|
|
|
|
|
|
+ with open(filepath, 'r', encoding='UTF-8') as f:
|
|
|
|
+ region_list = json.load(f)
|
|
|
|
|
|
|
|
+ #region_list = json.loads(fobj)
|
|
|
|
+ now_time = int(time.time())
|
|
|
|
+ regin_list = []
|
|
for region in region_list:
|
|
for region in region_list:
|
|
name = region['name']
|
|
name = region['name']
|
|
region_id = region['region_id']
|
|
region_id = region['region_id']
|
|
@@ -61,5 +63,6 @@ class RegionCountryView(View):
|
|
cn = countries['cn']
|
|
cn = countries['cn']
|
|
en = countries['en']
|
|
en = countries['en']
|
|
number = countries['number']
|
|
number = countries['number']
|
|
|
|
+ regin_list.append(RegionCountryModel(number=number, region_id=region_id, name=name, cn=cn, en=en, add_time=now_time, update_time=now_time))
|
|
|
|
|
|
- RegionCountryModel.objects.create(number=number, region_id=region_id, name=name, cn=cn, en=en, add_time=now_time, update_time=now_time)
|
|
|
|
|
|
+ RegionCountryModel.objects.bulk_create(regin_list)
|