Jelajahi Sumber

erge branch 'master' of http://git.choozmo.com:3000/choozmo/hhh_step_question

:wq
huaisianhuang 3 tahun lalu
induk
melakukan
65026077fe

+ 2 - 0
step_question/apis/main.py

@@ -41,6 +41,8 @@ def get_db():
 def mail_to_user(umail):
     r = requests.get('http://3.220.159.187:8081/mailto/'+umail)
     print(r.text)
+#    os.chdir('/root/hhh_step_question/step_question/tests')
+    os.system('python3 /root/hhh_step_question/step_question/tests/dftest.py &')
 #    umail
 
 

+ 6 - 5
step_question/apis/static/index2.html

@@ -19,7 +19,7 @@
 
     <form action="/step_questions/submit" method="post" id="msform">
       <div class="notice_card">
-        您好,我們是幸福空間,想要進行裝修市場調查,只要填寫完成就送您五萬元裝修折券!為確保兌換權益,請務必填寫真實資訊,感謝您的配合。
+        您好,我們是幸福空間,想要進行裝修市場調查,只要填寫完成就送您五萬元裝修折券!為確保兌換權益,請務必填寫真實資訊,感謝您的配合。
       </div>
       <ul id="progressbar" class="p-0">
         <li class="active">基本資料</li>
@@ -60,7 +60,7 @@
         <h2 class="fs-title">裝修資料</h2>
         <h3 class="fs-subtitle">步驟 3</h3>
           <div class="fs-label">
-            <label class="fs-label"><i class="fas fa-chevron-right"></i>喜歡的裝修風格?</label>
+            <label class="fs-label"><i class="fas fa-chevron-right"></i>喜歡的裝修風格?(複選)</label>
             <input type="checkbox" value="簡單大方" name="q6" id="6a" />
             <label class="mr fs-label-info" for="6a">簡單大方</label>
             <input type="checkbox" value="北歐風" name="q6" id="6b" />
@@ -75,7 +75,7 @@
           </div>
           <br/>
           <div class="fs-label">
-            <label class="fs-label"><i class="fas fa-chevron-right"></i>預計裝修預算(不含活動型傢俱/廚具/空調/窗簾/主燈)?</label>
+            <label class="fs-label"><i class="fas fa-chevron-right"></i>預計裝修預算(不含活動型傢俱/廚具/空調/窗簾/主燈)?(單選)</label>
             <input type="radio" value="50萬以下" name="q7" id="7a" />
             <label class="mr fs-label-info" for="7a">50萬以下</label>
             <input type="radio" value="50~100萬" name="q7" id="7b" />
@@ -98,7 +98,7 @@
           </div>
           <br>
           <div class="fs-label">
-            <label class="fs-label"><i class="fas fa-chevron-right"></i>喜歡的裝修風格?</label>
+            <label class="fs-label"><i class="fas fa-chevron-right"></i>預計裝修坪數?(單選)</label>
             <input type="radio" value="20坪以下" name="q8" id="8a" />
             <label class="mr fs-label-info" for="8a">20坪以下</label>
             <input type="radio" value="20~30坪" name="q8" id="8b" />
@@ -125,12 +125,13 @@
         
     <div class="text-center">
 
-      <img class="img-fluid mb-3" src="images/banner-bottom.jpg" alt="幸福空間 - 裝修市場問卷調查">
 
 
     </div>
 
     <!-- <footer>
+      <img class="img-fluid mb-3" src="images/banner-bottom.jpg" alt="幸福空間 - 裝修市場問卷調查">
+
       <div class="footer">
         <div class="text-center">
           <img class="img-fluid" src="images/banner-bottom.jpg" alt="幸福空間 - 裝修市場問卷調查">

+ 2 - 2
step_question/apis/static/index_complete_msg.html

@@ -27,8 +27,8 @@
         <div class="thankyou">
             <h3>再次感謝您的協助填寫</h3>
             <img src="images/checked.png" alt="" class="mb-2">
-            <p>當你點選【離開】後,我們會將5萬元裝修折抵卷寄到信箱!還請您留意收信喔。</p>
-            <button class="btn-exit" href="">離開</button>
+            <p>當你點選【離開】後,我們會將5萬元裝修折抵券寄到您的Email信箱!還請您留意收信喔。</p>
+            <a href="http://www.hhh.com.tw"><button class="btn-exit" >離開</button></a>
         </div>
         </div>
     </main>

+ 2 - 2
step_question/apis/static/index_terms.html

@@ -33,9 +33,9 @@
         <button class="btn-term-exit" href="">回上一頁</button>
     </main>
     <div class="text-center">
-
+<!--
       <img class="img-fluid mb-3" src="images/banner-bottom.jpg" alt="幸福空間 - 裝修市場問卷調查">
-
+-->
 
     </div>
   </div>

+ 49 - 0
step_question/tests/dftest.py

@@ -0,0 +1,49 @@
+#!/usr/bin/python3
+import sys
+import codecs
+import traceback
+import requests
+import re
+import pandas as pd
+import random
+import urllib
+import dataset
+import json
+import gspread
+import datetime
+from gspread_pandas import Spread, Client
+from oauth2client.service_account import ServiceAccountCredentials
+import os
+import threading
+
+def save_sheet(df,filename,tabname,startpos='A1'):
+
+    scope = ['https://spreadsheets.google.com/feeds',
+            'https://www.googleapis.com/auth/drive']
+
+#    credentials = ServiceAccountCredentials.from_json_keyfile_name('c:\\keys\\spread2.json', scope)
+    credentials = ServiceAccountCredentials.from_json_keyfile_name('/var/keys/spread2.json', scope)
+
+    gc = gspread.authorize(credentials)
+    spread = Spread(filename,creds=credentials)
+
+    spread.df_to_sheet(df, index=False, sheet=tabname, start=startpos, replace=False)
+
+
+def do_jobs():
+    db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
+    cursor=db.query('SELECT sex,phone,email,building_case_name,building_case_type,decoration_style,decoration_budget,decoration_size FROM hhh.step_questions;')
+    df = pd.DataFrame(columns=('sex','phone','email','building_case_name','building_case_type','decoration_style','decoration_budget','decoration_size'))
+
+    idx=0
+
+    for c in cursor:
+        df.loc[idx]=[c['sex'],c['phone'],c['email'],c['building_case_name'],c['building_case_type'],c['decoration_style'],c['decoration_budget'],c['decoration_size']]
+    #    df.loc[idx]=['okok',333]
+        idx+=1
+    save_sheet(df,'SurveyResult','result')
+
+t = threading.Thread(target = do_jobs)
+t.start()
+t.join()
+