Bläddra i källkod

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

yf_zd 5 år sedan
förälder
incheckning
e9af7ae39d
4 ändrade filer med 147 tillägg och 36 borttagningar
  1. 32 1
      apps/AppInfo/admin.py
  2. 22 0
      apps/AppInfo/models.py
  3. 7 1
      apps/Equipment/urls.py
  4. 86 34
      apps/Equipment/views.py

+ 32 - 1
apps/AppInfo/admin.py

@@ -5,7 +5,8 @@ from django.utils.translation import ugettext_lazy as _
 from django.contrib.auth.forms import UserCreationForm, UserChangeForm
 # Register your models here.
 from apps.AppInfo.models import MyUser, QXZdata, QXZstatus, Equip, Equip_type, QXZdata_New, JKdata, Article, Video_data,Product,Blog,QXZstatus_New,QXZswitchstatus,QXZswitchdata,\
-CKArticle,GardenManage,GardenArea,Areacrop,Store_Manage,Hotel_Info,Hotel_Photo,FarmUser,FarmList,Pick_Pub,Sell_Manage,Person_Pick,QXZAutoswitch, Pic_Info,Sightsee_Info,QXZ_Alarm_Log
+CKArticle,GardenManage,GardenArea,Areacrop,Store_Manage,Hotel_Info,Hotel_Photo,FarmUser,FarmList,Pick_Pub,Sell_Manage,Person_Pick,QXZAutoswitch, Pic_Info,Sightsee_Info,QXZ_Alarm_Log,\
+Expert
 
 
 
@@ -784,3 +785,33 @@ class QXZ_Alarm_LogAdmin(admin.ModelAdmin):
     list_per_page = 10
     
 
+
+# 专家表
+@admin.register(Expert)
+class ExpertAdmin(admin.ModelAdmin):
+    actions_on_bottom = False
+    actions_on_top = True
+    # 详情显示项:
+    fields = [
+        'name',
+        'relation',
+        'desc',
+        'pic',
+        'upl_time',
+    ]
+    # 列表显示项:
+    list_display = [
+        'name',
+        'relation',
+        'desc',
+        'pic',
+        'upl_time',
+    ]
+    # 筛选过滤项:
+    list_filter = ('upl_time',)
+    # 搜索项:
+    search_fields = ['name']
+    # 设置每页显示记录数:
+    list_per_page = 10    
+
+

+ 22 - 0
apps/AppInfo/models.py

@@ -663,3 +663,25 @@ class QXZ_Alarm_Log(models.Model):
     ekey = models.CharField(u'监测指标',max_length=20, blank=True, null=True)
     # info = models.CharField(u'内容',max_length=20, blank=True)
     upl_time = models.DateTimeField(u'上报时间', default=timezone.now)
+
+    class Meta:
+        verbose_name = u'气象站短信预警记录'
+        verbose_name_plural = verbose_name
+        ordering = ['-upl_time']
+        get_latest_by = 'upl_time'
+
+
+
+# 专家数据表
+class Expert(models.Model):
+    name = models.CharField(u'专家名字',max_length=20, blank=True, null=True)
+    relation = models.CharField(u'联系方式',max_length=20, blank=True, null=True)
+    desc = models.CharField(u'专家描述',max_length=50, blank=True, null=True)
+    pic = models.CharField(u'专家图片',max_length=200, blank=True, null=True)
+    upl_time = models.DateTimeField(u'创建时间', default=timezone.now)
+    
+    class Meta:
+        verbose_name = u'专家数据表'
+        verbose_name_plural = verbose_name
+        ordering = ['-upl_time']
+        get_latest_by = 'upl_time'

+ 7 - 1
apps/Equipment/urls.py

@@ -20,7 +20,7 @@ from apps.Equipment.views import (
     Video_Upload,JKview,Person_Area_Pub,CropCount_View,Sell_Del,Pick_Del,
     Pick_New,Repertory_New_View,Park_Land,Contrast_Detail,Contrast_List,Person_View,Person_List,
     Area_Create,Area_Map,Person_Limit,Limit_View,Expert,learnDepot,Create_User,Change_Pwd,Delete_User,User_Change_Pwd,QXZ_Auto,QXZ_Value_Mqtt,QXZ_Status2, QXZ_Report_Detail2,
-    Sightsee_Photo,Pic_locat,Home_Farm,Guide_Img,Alarm_Record)
+    Sightsee_Photo,Pic_locat,Home_Farm,Guide_Img,Alarm_Record,Expert_Img,Expert_Info)
 
 app_name = 'Equipment'
 
@@ -251,6 +251,12 @@ urlpatterns = [
     
     url(r'^alarm_record$', Alarm_Record.as_view(), name='alarm_record'),
     
+    url(r'^expert_info$', Expert_Info.as_view(), name='expert_info'),
+    
+    url(r'^expert_img$', Expert_Img.as_view(), name='expert_img'),
+    
+    
+    
     
     
     

+ 86 - 34
apps/Equipment/views.py

@@ -24,7 +24,7 @@ from apps.AppInfo.models import (
     Hotel_Info, Hotel_Photo, JKdata, MyUser, Pick_Pub, Product, QXZdata,
     QXZdata_New, QXZstatus, QXZstatus_New, QXZswitchdata, QXZswitchstatus,
     Video_data,GardenArea,Store_Manage,Areacrop,Sell_Manage,Person_Pick,QXZAutoswitch,Sightsee_Info,Pic_Info,
-    QXZ_Alarm_Log)
+    QXZ_Alarm_Log,Expert)
 from apps.Equipment.all_dict import qxz_dict
 
 
@@ -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
@@ -3651,4 +3656,51 @@ class Alarm_Record(ListView):
         dat = dat[(10*(page-1)):(page*10)]
         data = {"dat":dat,"nums":nums}
         data = json.dumps(data)
-        return HttpResponse(data)
+        return HttpResponse(data)
+    
+
+
+class Expert_Img(ListView):
+    def get(self,request):
+        pass
+    def post(self,request):
+        # e_id = request.POST.get('id')
+        # news_sta = Article.objects.get(id=e_id)
+        guide_photo = request.FILES['upload']
+        if guide_photo:
+            print("新闻图片:", guide_photo)
+            news_photo_dir = 'media/uploads/'
+            end_name = guide_photo.name.split('.')[-1]
+            # 判断如果路径不存在,即创建路径
+            if os.path.exists(news_photo_dir) == False:
+                os.makedirs(news_photo_dir)
+            img = Image.open(guide_photo)
+            now_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
+            pic_name = now_time + '.' + end_name
+            print("pic_name:", pic_name)
+            img.save(news_photo_dir + pic_name)
+            news_photo = news_photo_dir + pic_name
+            print("new_photo:",news_photo)
+            data = {"code": 0,"msg": "","data": {"src": news_photo}}
+        else:
+            new_photo = "0"
+            data = {"code": 404,"msg": "","data": {"src": news_photo}}
+        data = json.dumps(data)
+        return HttpResponse(data)
+
+
+
+class Expert_Info(ListView):
+    def get(self,request):
+        page = int(request.GET.get("page"))
+        expert = Expert.objects.all()
+        nums = expert.count()
+        expert = expert[(10*(page-1)):(page*10)]
+        return render(request, 'backstageNet/limit/expertList.html', context={"expert":expert,"nums":nums})
+    def post(self, request):
+        name = request.POST.get('name')
+        relation = request.POST.get('relation')
+        desc = request.POST.get('desc')
+        pic = request.POST.get('pic')
+        Expert.objects.create(name=name,relation=relation,desc=desc,pic=pic)
+        return HttpResponse("1")