Forráskód Böngészése

https://github.com/openNAMU/openNAMU/issues/1756

잉여개발기 (SPDV) 2 éve
szülő
commit
25808ab485
8 módosított fájl, 73 hozzáadás és 14 törlés
  1. 1 0
      app.py
  2. 1 0
      route/__init__.py
  3. 11 3
      route/bbs_w.py
  4. 6 0
      route/bbs_w_delete.py
  5. 46 0
      route/bbs_w_pinned.py
  6. 5 1
      route/bbs_w_tool.py
  7. 2 9
      route/topic_comment_tool.py
  8. 1 1
      version.json

+ 1 - 0
app.py

@@ -561,6 +561,7 @@ app.route('/bbs/set/<int:bbs_num>', methods = ['POST', 'GET'])(bbs_w_set)
 app.route('/bbs/edit/<int:bbs_num>', methods = ['POST', 'GET'])(bbs_w_edit)
 app.route('/bbs/w/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_post)
 # app.route('/bbs/blind/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_hide)
+app.route('/bbs/pinned/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_pinned)
 app.route('/bbs/delete/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_delete)
 app.route('/bbs/raw/<int:bbs_num>/<int:post_num>')(view_raw_2)
 app.route('/bbs/tool/<int:bbs_num>/<int:post_num>')(bbs_w_tool)

+ 1 - 0
route/__init__.py

@@ -20,6 +20,7 @@ from route.api_bbs_w_comment_one import api_bbs_w_comment_one
 from route.bbs_w_edit import bbs_w_edit
 from route.bbs_make import bbs_make
 # from route.bbs_w_hide import bbs_w_hide
+from route.bbs_w_pinned import bbs_w_pinned
 from route.bbs_w_delete import bbs_w_delete
 from route.bbs_w import bbs_w
 from route.bbs_delete import bbs_delete

+ 11 - 3
route/bbs_w.py

@@ -63,11 +63,17 @@ def bbs_w(bbs_num = '', tool = 'bbs'):
         '''
 
         if tool == 'bbs':
+            curs.execute(db_change('select set_code, set_id, set_name from bbs_data where set_name = "pinned" and set_id like ? order by set_data desc'), [bbs_num])
+            db_data = curs.fetchall()
+            db_data = list(db_data) if db_data else []
+            
             curs.execute(db_change('select set_code, set_id from bbs_data where set_name = "title" and set_id like ? order by set_code + 0 desc'), [bbs_num])
+            db_data_2 = curs.fetchall()
+            db_data += list(db_data_2) if db_data_2 else []
         else:
             curs.execute(db_change('select set_code, set_id, set_data from bbs_data where set_name = "date" order by set_data desc limit 50'))
-        
-        db_data = curs.fetchall()
+            db_data = curs.fetchall()
+
         for for_b in db_data:
             curs.execute(db_change('select set_name, set_data, set_code, set_id from bbs_data where set_code = ? and set_id = ?'), [for_b[0], for_b[1]])
             db_data = curs.fetchall()
@@ -87,8 +93,10 @@ def bbs_w(bbs_num = '', tool = 'bbs'):
             if tool != 'bbs':
                 bbs_name_select = '(' + bbs_name_dict[for_b[1]] + ')'
 
+            notice = 1 if len(for_b) > 2 else 0
+
             data += '''
-                <tr>
+                <tr class="''' + ('opennamu_comment_color_red' if notice == 1 else '') + '''">
                     <td>''' + ip_pas(temp_dict['user_id']) + '''</td>
                     <td>''' + temp_dict['date'] + '''</td>
                     <td>''' + last_comment_date + '''</td>

+ 6 - 0
route/bbs_w_delete.py

@@ -1,5 +1,7 @@
 from .tool.func import *
 
+from .api_bbs_w_post import api_bbs_w_post
+
 def bbs_w_delete(bbs_num = '', post_num = ''):
     with get_db_connect() as conn:
         curs = conn.cursor()
@@ -17,6 +19,10 @@ def bbs_w_delete(bbs_num = '', post_num = ''):
         if admin_check() != 1:
             return redirect('/bbs/w/' + bbs_num_str)
         
+        temp_dict = json.loads(api_bbs_w_post(bbs_num_str + '-' + post_num_str).data)
+        if not 'user_id' in temp_dict:
+            return redirect('/bbs/main')
+        
         if flask.request.method == 'POST':
             curs.execute(db_change('delete from bbs_data where set_code = ? and set_id = ?'), [post_num_str, bbs_num_str])
             curs.execute(db_change('delete from bbs_set where set_code = ? and set_id = ?'), [post_num_str, bbs_num_str])

+ 46 - 0
route/bbs_w_pinned.py

@@ -0,0 +1,46 @@
+from .tool.func import *
+
+from .api_bbs_w_post import api_bbs_w_post
+
+def bbs_w_pinned(bbs_num = '', post_num = ''):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        curs.execute(db_change('select set_data from bbs_set where set_id = ? and set_name = "bbs_name"'), [bbs_num])
+        db_data = curs.fetchall()
+        if not db_data:
+            return redirect('/bbs/main')
+
+        bbs_name = db_data[0][0]
+        
+        bbs_num_str = str(bbs_num)
+        post_num_str = str(post_num)
+
+        if admin_check() != 1:
+            return redirect('/bbs/w/' + bbs_num_str)
+        
+        temp_dict = json.loads(api_bbs_w_post(bbs_num_str + '-' + post_num_str).data)
+        if not 'user_id' in temp_dict:
+            return redirect('/bbs/main')
+        
+        if flask.request.method == 'POST':
+            curs.execute(db_change('select set_data from bbs_data where set_code = ? and set_id = ? and set_name = "pinned"'), [post_num_str, bbs_num_str])
+            if not curs.fetchall():
+                curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('pinned', ?, ?, ?)"), [post_num_str, bbs_num_str, get_time()])
+            else:
+                curs.execute(db_change('delete from bbs_data where set_code = ? and set_id = ? and set_name = "pinned"'), [post_num_str, bbs_num_str])
+            
+            return redirect('/bbs/w/' + bbs_num_str)
+        else:
+            curs.execute(db_change('select set_data from bbs_data where set_code = ? and set_id = ? and set_name = "pinned"'), [post_num_str, bbs_num_str])
+            pinned = load_lang('pinned') if not curs.fetchall() else load_lang('pinned_release')
+
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [load_lang('bbs_post_pinned'), wiki_set(), wiki_custom(), wiki_css(['(' + bbs_name + ')' + ' (' + post_num_str + ')', 0])],
+                data = render_simple_set('''
+                    <form method="post">
+                        <button type="submit">''' + pinned + '''</button>
+                    </form>
+                '''),
+                menu = [['bbs/w/' + bbs_num_str + '/' + post_num_str, load_lang('return')]]
+            ))

+ 5 - 1
route/bbs_w_tool.py

@@ -17,10 +17,14 @@ def bbs_w_tool(bbs_num = '', post_num = ''):
         '''
 
         if admin_check() == 1:
+            curs.execute(db_change('select set_data from bbs_data where set_code = ? and set_id = ? and set_name = "pinned"'), [post_num_str, bbs_num_str])
+            pinned = load_lang('pinned') if not curs.fetchall() else load_lang('pinned_release')
+
             data += '''
-                <h2>''' + load_lang('admin') + '''</h2>
+                <h3>''' + load_lang('admin') + '''</h3>
                 <ul class="opennamu_ul">
                     <li><a href="/bbs/blind/''' + url_pas(bbs_num_str) + '/' + url_pas(post_num_str) + '">' + load_lang('hide') + '''</a></li>
+                    <li><a href="/bbs/pinned/''' + url_pas(bbs_num_str) + '/' + url_pas(post_num_str) + '">' + pinned + '''</a></li>
                 </ul>
             '''
 

+ 2 - 9
route/topic_comment_tool.py

@@ -30,22 +30,15 @@ def topic_comment_tool(topic_num = 1, num = 1):
         '''
 
         if admin_check(3) == 1:
-            curs.execute(db_change(
-                "select id from topic where code = ? and id = ? and top = 'O'"
-            ), [topic_num, num])
+            curs.execute(db_change("select id from topic where code = ? and id = ? and top = 'O'"), [topic_num, num])
             top_topic_d = curs.fetchall()
 
-            curs.execute(db_change(
-                "select end from rb where block = ? and ongoing = '1'"
-            ), [data[0][1]])
-            user_ban_d = curs.fetchall()
-
             ban += '''
                 <h2>''' + load_lang('admin_tool') + '''</h2>
                 <ul class="opennamu_ul">
                     <li>
                         <a href="/auth/give/ban/''' + url_pas(data[0][1]) + '''">
-                            ''' + (load_lang('release') if user_ban_d else load_lang('ban')) + '''
+                            ''' + (load_lang('release') if ban_check(data[0][1]) == 1 else load_lang('ban')) + '''
                         </a>
                     </li>
                     <li>

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.6-RC5-dev55",
+        "r_ver" : "v3.4.6-RC5-dev56",
         "c_ver" : "3500373",
         "s_ver" : "3500112"
     }