Ver código fonte

게시판 댓글 삭제 기능 추가

잉여개발기 (SPDV) 2 anos atrás
pai
commit
a476c71dab
5 arquivos alterados com 73 adições e 39 exclusões
  1. 1 0
      app.py
  2. 8 1
      route/bbs_w_comment_tool.py
  3. 32 7
      route/bbs_w_delete.py
  4. 31 30
      route/bbs_w_post.py
  5. 1 1
      version.json

+ 1 - 0
app.py

@@ -659,6 +659,7 @@ app.route('/bbs/edit/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(b
 app.route('/bbs/tool/<int:bbs_num>/<int:post_num>/<comment_num>')(bbs_w_comment_tool)
 app.route('/bbs/raw/<int:bbs_num>/<int:post_num>/<comment_num>')(view_raw_2)
 app.route('/bbs/edit/<int:bbs_num>/<int:post_num>/<comment_num>', methods = ['POST', 'GET'])(bbs_w_edit)
+app.route('/bbs/delete/<int:bbs_num>/<int:post_num>/<comment_num>', methods = ['POST', 'GET'])(bbs_w_delete)
 
 # Func-api
 # 폐지 예정

+ 8 - 1
route/bbs_w_comment_tool.py

@@ -14,10 +14,17 @@ def bbs_w_comment_tool(bbs_num = '', post_num = '', comment_num = ''):
             <ul class="opennamu_ul">
                 <li><a href="/bbs/raw/''' + url_pas(bbs_num_str) + '/' + url_pas(post_num_str) + '/' + url_pas(comment_num) + '">' + load_lang('raw') + '''</a></li>
                 <li><a href="/bbs/edit/''' + url_pas(bbs_num_str) + '/' + url_pas(post_num_str) + '/' + url_pas(comment_num) + '">' + load_lang('edit') + '''</a></li>
-                <!-- <li><a href="/bbs/w/''' + url_pas(bbs_num_str) + '/' + url_pas(post_num_str) + '/blind">' + load_lang('hide') + '''</a></li> -->
             </ul>
         '''
 
+        if admin_check() == 1:
+            data += '''
+                <h3>''' + load_lang('owner') + '''</h2>
+                <ul class="opennamu_ul">
+                    <li><a href="/bbs/delete/''' + url_pas(bbs_num_str) + '/' + url_pas(post_num_str) + '/' + url_pas(comment_num) + '">' + load_lang('delete') + '''</a></li>
+                </ul>
+            '''
+
         return easy_minify(flask.render_template(skin_check(),
             imp = [load_lang('bbs_comment_tool'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
             data = data,

+ 32 - 7
route/bbs_w_delete.py

@@ -2,7 +2,7 @@ from .tool.func import *
 
 from .api_bbs_w_post import api_bbs_w_post
 
-def bbs_w_delete(bbs_num = '', post_num = ''):
+def bbs_w_delete(bbs_num = '', post_num = '', comment_num = ''):
     with get_db_connect() as conn:
         curs = conn.cursor()
 
@@ -24,14 +24,39 @@ def bbs_w_delete(bbs_num = '', post_num = ''):
             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])
-            curs.execute(db_change('delete from bbs_data where set_id = ? or set_id like ?'), [bbs_num_str + '-' + post_num_str, bbs_num_str + '-' + post_num_str + '-%'])
-            
-            return redirect('/bbs/w/' + bbs_num_str)
+            if comment_num == '':
+                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])
+                curs.execute(db_change('delete from bbs_data where set_id = ? or set_id like ?'), [bbs_num_str + '-' + post_num_str, bbs_num_str + '-' + post_num_str + '-%'])
+                
+                return redirect('/bbs/w/' + bbs_num_str)
+            else:
+                comment_num_split = comment_num.split('-')
+                
+                set_id = bbs_num_str + '-' + post_num_str
+                set_id_sub = '-'.join(comment_num_split[:-1])
+                if set_id_sub != '':
+                    set_id += '-' + set_id_sub
+
+                set_code = comment_num_split[len(comment_num_split) - 1]
+
+                print(set_id, set_code)
+
+                curs.execute(db_change("update bbs_data set set_data = '' where set_code = ? and set_id = ?"), [set_code, set_id])
+                
+                return redirect('/bbs/w/' + bbs_num_str + '/' + post_num_str)
         else:
+            sub = '(' + bbs_name + ')'
+            sub += ' (' + post_num_str + ')'
+            
+            name = load_lang('bbs_post_delete')
+            if comment_num == '':
+                name = load_lang('bbs_comment_delete')
+            else:
+                sub += ' (' + comment_num + ')'
+
             return easy_minify(flask.render_template(skin_check(),
-                imp = [load_lang('bbs_post_delete'), wiki_set(), wiki_custom(), wiki_css(['(' + bbs_name + ')' + ' (' + post_num_str + ')', 0])],
+                imp = [name, wiki_set(), wiki_custom(), wiki_css([sub, 0])],
                 data = render_simple_set('''
                     <form method="post">
                         <span>''' + load_lang('delete_warning') + '''</span>

+ 31 - 30
route/bbs_w_post.py

@@ -19,36 +19,37 @@ def bbs_w_post_comment(user_id, sub_code, comment_num, bbs_num_str, post_num_str
     comment_add_count += comment_count
 
     for temp_dict in thread_data:
-        color = 'default'
-        if user_id == temp_dict['comment_user_id']:
-            color = 'green'
-
-        sub_code_check = re.sub(r'^[0-9]+-[0-9]+-', '', sub_code + '-' + temp_dict['code'])
-        margin_count = sub_code_check.count('-')
-
-        date = ''
-        date += '<a href="javascript:opennamu_change_comment(\'' + sub_code_check + '\');">(' + load_lang('comment') + ')</a> '
-        date += '<a href="/bbs/tool/' + bbs_num_str + '/' + post_num_str + '/' + sub_code_check + '">(' + load_lang('tool') + ')</a> '
-        date += temp_dict['comment_date']
-
-        comment_data += '<span style="padding-left: 20px;"></span>' * margin_count
-        comment_data += api_topic_thread_make(
-            ip_pas(temp_dict['comment_user_id']),
-            date,
-            render_set(
-                doc_data = temp_dict['comment'],
-                data_in = 'bbs_comment_' + sub_code_check
-            ),
-            sub_code_check,
-            color = color,
-            add_style = 'width: calc(100% - ' + str(margin_count * 20) + 'px);'
-        )
-
-        comment_default = ''
-        if comment_num == sub_code_check:
-            comment_default = 'selected'
-
-        comment_select += '<option value="' + sub_code_check + '" ' + comment_default + '>' + sub_code_check + '</option>'
+        if temp_dict['comment_user_id'] != '':
+            color = 'default'
+            if user_id == temp_dict['comment_user_id']:
+                color = 'green'
+
+            sub_code_check = re.sub(r'^[0-9]+-[0-9]+-', '', sub_code + '-' + temp_dict['code'])
+            margin_count = sub_code_check.count('-')
+
+            date = ''
+            date += '<a href="javascript:opennamu_change_comment(\'' + sub_code_check + '\');">(' + load_lang('comment') + ')</a> '
+            date += '<a href="/bbs/tool/' + bbs_num_str + '/' + post_num_str + '/' + sub_code_check + '">(' + load_lang('tool') + ')</a> '
+            date += temp_dict['comment_date']
+
+            comment_data += '<span style="padding-left: 20px;"></span>' * margin_count
+            comment_data += api_topic_thread_make(
+                ip_pas(temp_dict['comment_user_id']),
+                date,
+                render_set(
+                    doc_data = temp_dict['comment'],
+                    data_in = 'bbs_comment_' + sub_code_check
+                ),
+                sub_code_check,
+                color = color,
+                add_style = 'width: calc(100% - ' + str(margin_count * 20) + 'px);'
+            )
+
+            comment_default = ''
+            if comment_num == sub_code_check:
+                comment_default = 'selected'
+
+            comment_select += '<option value="' + sub_code_check + '" ' + comment_default + '>' + sub_code_check + '</option>'
 
         temp_data = bbs_w_post_comment(user_id, sub_code + '-' + temp_dict['code'], comment_num, bbs_num_str, post_num_str)
 

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.6-RC5-dev88",
+        "r_ver" : "v3.4.6-RC5-dev89",
         "c_ver" : "3500374",
         "s_ver" : "3500112"
     }