Просмотр исходного кода

Merge branch 'master' of http://39.104.94.153:3000/yf_zd/second

yf_ymm 5 лет назад
Родитель
Сommit
e50a35304f
1 измененных файлов с 37 добавлено и 32 удалено
  1. 37 32
      apps/Equipment/views.py

+ 37 - 32
apps/Equipment/views.py

@@ -2424,9 +2424,11 @@ class Sell_New(ListView):
         money = request.POST.get("money")
         time = request.POST.get("time")
         s_id = request.POST.get("id")
+        username = request.user.username
+        
         if s_id:
             try:
-                farm_obj = FarmList.objects.get(name=farm)
+                farm_obj = FarmList.objects.get(name=farm,user=username)
                 sell_obj = Sell_Manage.objects.get(id=s_id)
                 sell_obj.farm = farm_obj
                 sell_obj.name = name
@@ -2440,7 +2442,7 @@ class Sell_New(ListView):
                 data = "0"
         else:
             try:
-                farm_obj = FarmList.objects.get(name=farm)
+                farm_obj = FarmList.objects.get(name=farm,user=username)
                 Sell_Manage.objects.create(farm=farm_obj,name=name,num=num,money=money,upl_time=time)
                 data = "1"
             except Exception as e:
@@ -2479,6 +2481,7 @@ class CropCount(ListView):
     def get(self,request):
         return render(request, 'backstageNet/production/cropcount.html', context={})
     def post(self,request):
+        username = request.user.username
         crop_count = request.POST.get('crop_count')
         area = request.POST.get('area')
         crop_id = request.POST.get('id')
@@ -2489,6 +2492,7 @@ class CropCount(ListView):
         print(count)
         #修改
         if crop_id:
+            print("修改")
             try:
                 crops =GardenArea.objects.get(name=area)
                 crop = Areacrop.objects.filter(id=crop_id).update(
@@ -2502,6 +2506,7 @@ class CropCount(ListView):
                 print(e)
                 data = "0"
         else:
+            print("新增")
             #新增
             try:
                 crops =GardenArea.objects.get(name=area)
@@ -2532,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})
@@ -3083,7 +3088,7 @@ class Person_Farm_Edit(ListView):
         return HttpResponse(data)
 
 
-# 地块发布
+# 园区发布
 class Person_Area_Pub(ListView):
     def get(self,request):
         pass