Răsfoiți Sursa

문서 뒤바꾸기

Surplus_Up (2DU) 6 ani în urmă
părinte
comite
8dd0bf97d3
3 a modificat fișierele cu 88 adăugiri și 30 ștergeri
  1. 2 0
      language/en-US.json
  2. 3 1
      language/ko-KR.json
  3. 83 29
      route/edit_move.py

+ 2 - 0
language/en-US.json

@@ -186,6 +186,8 @@
         "edit_req_check" : "Check edit request",
         "history_add" : "Add history",
         "all_register_num" : "The number of application forms",
+        "replace_move" : "Reversing documents",
+        "merge_move" : "Merging documents",
         "_comment_2.1_" : "Filter",
             "_comment_2.1.1_" : "List",
                 "interwiki_list" : "Interwiki(s) list",

+ 3 - 1
language/ko-KR.json

@@ -330,5 +330,7 @@
     "no_applications_now" : "회원가입 신청이 없습니다.",
     "application_not_found" : "존재하지 않는 회원가입 신청입니다.",
     "approval_requirement_disabled": "현재 가입시 승인필요 설정이 비활성화되어있습니다. 필요시 설정에서 활성화할 수 있습니다.",
-    "all_register_num" : "모든 가입 신청자의 수"
+    "all_register_num" : "모든 가입 신청자의 수",
+    "replace_move" : "문서 바꾸기",
+    "merge_move" : "문서 병합"
 }

+ 83 - 29
route/edit_move.py

@@ -15,20 +15,22 @@ def edit_move_2(conn, name):
         if slow_edit_check() == 1:
             return re_error('/error/24')
 
-        curs.execute(db_change("select title from history where title = ?"), [flask.request.form.get('title', None)])
+        move_title = flask.request.form.get('title', 'test')
+
+        curs.execute(db_change("select title from history where title = ?"), [move_title])
         if curs.fetchall():
-            if admin_check(None, 'merge documents') == 1:
-                curs.execute(db_change("select data from data where title = ?"), [flask.request.form.get('title', None)])
+            if flask.request.form.get('move_option', 'normal') == 'merge' and admin_check(None, 'merge documents') == 1:
+                curs.execute(db_change("select data from data where title = ?"), [move_title])
                 data = curs.fetchall()
                 if data:
-                    curs.execute(db_change("delete from data where title = ?"), [flask.request.form.get('title', None)])
-                    curs.execute(db_change("delete from back where link = ?"), [flask.request.form.get('title', None)])
+                    curs.execute(db_change("delete from data where title = ?"), [move_title])
+                    curs.execute(db_change("delete from back where link = ?"), [move_title])
 
                 curs.execute(db_change("select data from data where title = ?"), [name])
                 data = curs.fetchall()
                 if data:
-                    curs.execute(db_change("update data set title = ? where title = ?"), [flask.request.form.get('title', None), name])
-                    curs.execute(db_change("update back set link = ? where link = ?"), [flask.request.form.get('title', None), name])
+                    curs.execute(db_change("update data set title = ? where title = ?"), [move_title, name])
+                    curs.execute(db_change("update back set link = ? where link = ?"), [move_title, name])
 
                     data_in = data[0][0]
                 else:
@@ -41,13 +43,13 @@ def edit_move_2(conn, name):
                     ip_check(),
                     flask.request.form.get('send', ''),
                     '0',
-                    'marge <a>' + name + '</a> - <a>' + flask.request.form.get('title', 'test') + '</a> move'
+                    'marge <a>' + name + '</a> - <a>' + move_title + '</a> move'
                 )
 
                 curs.execute(db_change("update back set type = 'no' where title = ? and not type = 'cat' and not type = 'no'"), [name])
-                curs.execute(db_change("delete from back where title = ? and not type = 'cat' and type = 'no'"), [flask.request.form.get('title', None)])
+                curs.execute(db_change("delete from back where title = ? and not type = 'cat' and type = 'no'"), [move_title])
 
-                curs.execute(db_change("select id from history where title = ? order by id + 0 desc limit 1"), [flask.request.form.get('title', None)])
+                curs.execute(db_change("select id from history where title = ? order by id + 0 desc limit 1"), [move_title])
                 data = curs.fetchall()
 
                 num = data[0][0]
@@ -55,19 +57,65 @@ def edit_move_2(conn, name):
                 curs.execute(db_change("select id from history where title = ? order by id + 0 asc"), [name])
                 data = curs.fetchall()
                 for move in data:
-                    curs.execute(db_change("update history set title = ?, id = ? where title = ? and id = ?"), [flask.request.form.get('title', None), str(int(num) + int(move[0])), name, move[0]])
+                    curs.execute(db_change("update history set title = ?, id = ? where title = ? and id = ?"), [
+                        move_title, 
+                        str(int(num) + int(move[0])), 
+                        name, 
+                        move[0]
+                    ])
 
                 conn.commit()
 
-                return redirect('/w/' + url_pas(flask.request.form.get('title', None)))
+                return redirect('/w/' + url_pas(move_title))
+            elif flask.request.form.get('move_option', 'normal') == 'reverse':
+                var_name = ''
+                i = 0
+                while 1:
+                    curs.execute(db_change("select title from history where title = ?"), ['test ' + str(i)])
+                    if not curs.fetchall():
+                        curs.execute(db_change("select data from data where title = ?"), [name])
+                        data = curs.fetchall()
+                        if data:
+                            curs.execute(db_change("update data set title = ? where title = ?"), ['test ' + str(i), name])
+                            curs.execute(db_change("update back set link = ? where link = ?"), ['test ' + str(i), name])
+
+                        curs.execute(db_change("update history set title = ? where title = ?"), ['test ' + str(i), name])
+
+                        break
+                    else:
+                        i += 1
+
+                for title_name in [[move_title, name], ['test ' + str(i), move_title]]:
+                    curs.execute(db_change("select data from data where title = ?"), [title_name[0]])
+                    data = curs.fetchall()
+                    if data:
+                        curs.execute(db_change("update data set title = ? where title = ?"), [title_name[1], title_name[0]])
+                        curs.execute(db_change("update back set link = ? where link = ?"), [title_name[1], title_name[0]])
+
+                        data_in = data[0][0]
+                    else:
+                        data_in = ''
+
+                    history_plus(
+                        title_name[0],
+                        data_in,
+                        get_time(),
+                        ip_check(),
+                        flask.request.form.get('send', ''),
+                        '0',
+                        '<a>' + (title_name[0] if title_name[0] != 'test ' + str(i) else name) + '</a> - <a>' + title_name[1] + '</a> move'
+                    )
+
+                    curs.execute(db_change("update history set title = ? where title = ?"), [title_name[1], title_name[0]])
+                    conn.commit()
             else:
                 return re_error('/error/19')
         else:
             curs.execute(db_change("select data from data where title = ?"), [name])
             data = curs.fetchall()
             if data:
-                curs.execute(db_change("update data set title = ? where title = ?"), [flask.request.form.get('title', None), name])
-                curs.execute(db_change("update back set link = ? where link = ?"), [flask.request.form.get('title', None), name])
+                curs.execute(db_change("update data set title = ? where title = ?"), [move_title, name])
+                curs.execute(db_change("update back set link = ? where link = ?"), [move_title, name])
 
                 data_in = data[0][0]
             else:
@@ -80,29 +128,35 @@ def edit_move_2(conn, name):
                 ip_check(),
                 flask.request.form.get('send', ''),
                 '0',
-                '<a>' + name + '</a> - <a>' + flask.request.form.get('title', 'test') + '</a> move'
+                '<a>' + name + '</a> - <a>' + move_title + '</a> move'
             )
 
             curs.execute(db_change("update back set type = 'no' where title = ? and not type = 'cat' and not type = 'no'"), [name])
-            curs.execute(db_change("delete from back where title = ? and not type = 'cat' and type = 'no'"), [flask.request.form.get('title', None)])
+            curs.execute(db_change("delete from back where title = ? and not type = 'cat' and type = 'no'"), [move_title])
 
-            curs.execute(db_change("update history set title = ? where title = ?"), [flask.request.form.get('title', None), name])
+            curs.execute(db_change("update history set title = ? where title = ?"), [move_title, name])
             conn.commit()
 
-            return redirect('/w/' + url_pas(flask.request.form.get('title', None)))
+            return redirect('/w/' + url_pas(move_title))
     else:
         return easy_minify(flask.render_template(skin_check(),
             imp = [name, wiki_set(), custom(), other2([' (' + load_lang('move') + ')', 0])],
-            data =  '''
-                    <form method="post">
-                        ''' + ip_warring() + '''
-                        <input placeholder="''' + load_lang('document_name') + '" value="' + name + '''" name="title" type="text">
-                        <hr class=\"main_hr\">
-                        <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
-                        <hr class=\"main_hr\">
-                        ''' + captcha_get() + '''
-                        <button type="submit">''' + load_lang('move') + '''</button>
-                    </form>
-                    ''',
+            data = '''
+                <form method="post">
+                    ''' + ip_warring() + '''
+                    <input placeholder="''' + load_lang('document_name') + '" value="' + name + '''" name="title" type="text">
+                    <hr class=\"main_hr\">
+                    <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
+                    <hr class=\"main_hr\">
+                    <select name="move_option">
+                        <option value="normal"> ''' + load_lang('normal') + '''</option>
+                        <option value="reverse"> ''' + load_lang('replace_move') + '''</option>
+                        ''' + ('<option value="merge"> ' + load_lang('merge_move') + '</option>' if admin_check() == 1 else '') + '''
+                    </select>
+                    <hr class=\"main_hr\">
+                    ''' + captcha_get() + '''
+                    <button type="submit">''' + load_lang('move') + '''</button>
+                </form>
+            ''',
             menu = [['w/' + url_pas(name), load_lang('return')]]
         ))