Parcourir la source

接口增加参数

yf_ymm il y a 5 ans
Parent
commit
7a02c2d25f
4 fichiers modifiés avec 106 ajouts et 4 suppressions
  1. 32 1
      apps/AppInfo/admin.py
  2. 22 0
      apps/AppInfo/models.py
  3. 7 1
      apps/Equipment/urls.py
  4. 45 2
      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'),
+    
+    
+    
     
     
     

+ 45 - 2
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
 
 
@@ -3651,4 +3651,47 @@ 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):
+        return render(request, 'backstageNet/limit/expertList.html', context={})
+    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")