|
|
@@ -2492,8 +2492,9 @@ class CropCount(ListView):
|
|
|
print(count)
|
|
|
#修改
|
|
|
if crop_id:
|
|
|
+ print("修改")
|
|
|
try:
|
|
|
- crops =GardenArea.objects.get(name=area,user=username)
|
|
|
+ crops =GardenArea.objects.get(name=area)
|
|
|
crop = Areacrop.objects.filter(id=crop_id).update(
|
|
|
cropname=cropname,
|
|
|
area=crops,
|
|
|
@@ -2505,9 +2506,10 @@ class CropCount(ListView):
|
|
|
print(e)
|
|
|
data = "0"
|
|
|
else:
|
|
|
+ print("新增")
|
|
|
#新增
|
|
|
try:
|
|
|
- crops =GardenArea.objects.get(name=area,user=username)
|
|
|
+ crops =GardenArea.objects.get(name=area)
|
|
|
Areacrop.objects.create(
|
|
|
cropname=cropname,
|
|
|
area=crops,
|
|
|
@@ -2535,35 +2537,35 @@ class CropCount_View(ListView):
|
|
|
for i in art:
|
|
|
art_list = Areacrop.objects.filter(area=i)
|
|
|
for x in art_list:
|
|
|
- if x.end_time:
|
|
|
- time = int(x.upl_time.strftime("%Y%m%d"))
|
|
|
- time_now = int(x.end_time.strftime("%Y%m%d"))
|
|
|
- data = time_now-time
|
|
|
- curro = "当前阶段已结束"
|
|
|
- h2 = {"cropname":x.cropname,
|
|
|
- "area":x.area.name,
|
|
|
- "crop_count":x.crop_count,
|
|
|
- "img":x.area.img,
|
|
|
- "time":data,
|
|
|
- "upl_time":x.upl_time.strftime('%Y-%m-%d'),
|
|
|
- "id":x.id
|
|
|
- }
|
|
|
- dat.append({"data":h2,"curro":curro})
|
|
|
- else:
|
|
|
- time = int(x.upl_time.strftime("%Y%m%d"))
|
|
|
- time_now = int(timezone.now().strftime("%Y%m%d"))
|
|
|
- data = time_now-time
|
|
|
- print(data)
|
|
|
- curro = ""
|
|
|
- h2 = {"cropname":x.cropname,
|
|
|
- "area":x.area.name,
|
|
|
- "crop_count":x.crop_count,
|
|
|
- "img":x.area.img,
|
|
|
- "time":data,
|
|
|
- "id":x.id,
|
|
|
- "upl_time":x.upl_time.strftime('%Y-%m-%d')
|
|
|
- }
|
|
|
- dat.append({"data":h2,"curro":curro})
|
|
|
+ # if x.end_time:
|
|
|
+ # time = int(x.upl_time.strftime("%Y%m%d"))
|
|
|
+ # time_now = int(x.end_time.strftime("%Y%m%d"))
|
|
|
+ # data = time_now-time
|
|
|
+ # curro = "当前阶段已结束"
|
|
|
+ # h2 = {"cropname":x.cropname,
|
|
|
+ # "area":x.area.name,
|
|
|
+ # "crop_count":x.crop_count,
|
|
|
+ # "img":x.area.img,
|
|
|
+ # "time":data,
|
|
|
+ # "upl_time":x.upl_time.strftime('%Y-%m-%d'),
|
|
|
+ # "id":x.id
|
|
|
+ # }
|
|
|
+ # dat.append({"data":h2,"curro":curro})
|
|
|
+ # else:
|
|
|
+ time = int(x.upl_time.strftime("%Y%m%d"))
|
|
|
+ time_now = int(timezone.now().strftime("%Y%m%d"))
|
|
|
+ data = time_now-time
|
|
|
+ print(data)
|
|
|
+ curro = ""
|
|
|
+ h2 = {"cropname":x.cropname,
|
|
|
+ "area":x.area.name,
|
|
|
+ "crop_count":x.crop_count,
|
|
|
+ "img":x.area.img,
|
|
|
+ "time":data,
|
|
|
+ "id":x.id,
|
|
|
+ "upl_time":x.upl_time.strftime('%Y-%m-%d')
|
|
|
+ }
|
|
|
+ dat.append({"data":h2,"curro":curro})
|
|
|
nums = len(dat)
|
|
|
dat = dat[(9*(page-1)):(page*9)]
|
|
|
data = json.dumps({"dat":dat,"nums":nums})
|
|
|
@@ -3086,7 +3088,7 @@ class Person_Farm_Edit(ListView):
|
|
|
return HttpResponse(data)
|
|
|
|
|
|
|
|
|
-# 地块发布
|
|
|
+# 园区发布
|
|
|
class Person_Area_Pub(ListView):
|
|
|
def get(self,request):
|
|
|
pass
|
|
|
@@ -3111,7 +3113,7 @@ class Person_Area_Pub(ListView):
|
|
|
location = request.POST.get('location')
|
|
|
addr = request.POST.get('addr')
|
|
|
guide_img = request.POST.get('guide_img')
|
|
|
- if GardenArea.objects.filter(user=user,name=name).exists():
|
|
|
+ if GardenArea.objects.filter(user=user).exists():
|
|
|
try:
|
|
|
gar_obj = GardenArea.objects.get(user=user)
|
|
|
gar_obj.name = name
|