|
@@ -4608,14 +4608,38 @@ class System_Photo(ListView):
|
|
|
def get(self,request):
|
|
def get(self,request):
|
|
|
return render(request, 'backstageNet/systemSet/imageUpload.html', context={})
|
|
return render(request, 'backstageNet/systemSet/imageUpload.html', context={})
|
|
|
def post(self,request):
|
|
def post(self,request):
|
|
|
-
|
|
|
|
|
|
|
+ upl_time = timezone.now()
|
|
|
basestr = request.FILES.get("upload")
|
|
basestr = request.FILES.get("upload")
|
|
|
- base_dir = 'media/uploads/'
|
|
|
|
|
|
|
+ basestr1 = request.FILES.get("upload1")
|
|
|
now_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
|
now_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
|
|
if basestr:
|
|
if basestr:
|
|
|
|
|
+ base_dir = 'media/uploads/'
|
|
|
img = Image.open(basestr)
|
|
img = Image.open(basestr)
|
|
|
- img.save(base_dir + now_time +".png")
|
|
|
|
|
- SystemPhoto.objects.create(name=base_dir +now_time +".png",pic_1=base_dir +now_time +".png")
|
|
|
|
|
|
|
+ code = 1
|
|
|
|
|
+ else:
|
|
|
|
|
+ base_dir = 'media/uploads1/'
|
|
|
|
|
+ code = 2
|
|
|
|
|
+ img = Image.open(basestr1)
|
|
|
|
|
+ if os.path.exists(base_dir) == False:
|
|
|
|
|
+ os.makedirs(base_dir)
|
|
|
|
|
+ img.save(base_dir + now_time +".png")
|
|
|
|
|
+ pic_list = SystemPhoto.objects.filter(code=code).order_by("upl_time")
|
|
|
|
|
+ if code == 1:
|
|
|
|
|
+ if len(pic_list) <= 2:
|
|
|
|
|
+ SystemPhoto.objects.create(code=code,pic_img=base_dir +now_time +".png")
|
|
|
|
|
+ else:
|
|
|
|
|
+ for i in pic_list[:1]:
|
|
|
|
|
+ i.pic_img=base_dir +now_time +".png"
|
|
|
|
|
+ i.upl_time=upl_time
|
|
|
|
|
+ i.save()
|
|
|
|
|
+ else:
|
|
|
|
|
+ if len(pic_list) <=3:
|
|
|
|
|
+ SystemPhoto.objects.create(code=code,pic_img=base_dir +now_time +".png")
|
|
|
|
|
+ else:
|
|
|
|
|
+ for i in pic_list[:1]:
|
|
|
|
|
+ i.pic_img=base_dir +now_time +".png"
|
|
|
|
|
+ i.upl_time=upl_time
|
|
|
|
|
+ i.save()
|
|
|
return HttpResponse("1")
|
|
return HttpResponse("1")
|
|
|
|
|
|
|
|
|
|
|
|
@@ -4623,14 +4647,17 @@ class System_Photo(ListView):
|
|
|
|
|
|
|
|
# 系统管理上传图片
|
|
# 系统管理上传图片
|
|
|
class System_Photo_Save(ListView):
|
|
class System_Photo_Save(ListView):
|
|
|
- def get(self,request):
|
|
|
|
|
- pass
|
|
|
|
|
def post(self,request):
|
|
def post(self,request):
|
|
|
- pic_1 = request.POST.get('pic_1')
|
|
|
|
|
- pic_2 = request.POST.get('pic_2')
|
|
|
|
|
- if pic_1:
|
|
|
|
|
- name = pic_1
|
|
|
|
|
- elif pic_2:
|
|
|
|
|
- name = pic_2
|
|
|
|
|
- SystemPhoto.objects.create(name=name,pic_1=pic_1,pic_2=pic_2)
|
|
|
|
|
- return HttpResponse("1")
|
|
|
|
|
|
|
+ code = request.POST.get("code")
|
|
|
|
|
+ data = []
|
|
|
|
|
+ if code != "1" and code != "2":
|
|
|
|
|
+ return HttpResponse("0")
|
|
|
|
|
+ else:
|
|
|
|
|
+ pic_list = SystemPhoto.objects.filter(code=code)
|
|
|
|
|
+ for i in pic_list:
|
|
|
|
|
+ data.append({
|
|
|
|
|
+ "pic_img":i.pic_img
|
|
|
|
|
+ })
|
|
|
|
|
+ data = json.dumps(data)
|
|
|
|
|
+ return HttpResponse(data)
|
|
|
|
|
+
|