Ver Fonte

Merge pull request #1075 from 2du/dev

Dev
잉여개발기 (SPDV) há 5 anos atrás
pai
commit
c476bc528d
9 ficheiros alterados com 98 adições e 141 exclusões
  1. 1 1
      app.py
  2. 1 1
      route/func_upload.py
  3. 55 94
      route/give_acl.py
  4. 10 11
      route/list_acl.py
  5. 2 8
      route/search_deep.py
  6. 12 5
      route/tool/func.py
  7. 10 16
      route/view_read.py
  8. 2 2
      version.json
  9. 5 3
      views/main_css/js/load_editor.js

+ 1 - 1
app.py

@@ -148,7 +148,7 @@ create_data['re_admin'] = ['who', 'what', 'time']
 create_data['alarm'] = ['name', 'data', 'date']
 create_data['ua_d'] = ['name', 'ip', 'ua', 'today', 'sub']
 create_data['scan'] = ['user', 'title', 'type']
-create_data['acl'] = ['title', 'decu', 'dis', 'view', 'why']
+create_data['acl'] = ['title', 'data', 'type']
 create_data['html_filter'] = ['html', 'kind', 'plus', 'plus_t']
 create_data['vote'] = ['name', 'id', 'subject', 'data', 'user', 'type', 'acl']
 for i in create_data:

+ 1 - 1
route/func_upload.py

@@ -92,7 +92,7 @@ def func_upload_2(conn, app_var):
                 ''
 
             curs.execute(db_change("insert into data (title, data) values (?, ?)"), ['file:' + name, file_d])
-            curs.execute(db_change("insert into acl (title, decu, dis, why, view) values (?, 'admin', '', '', '')"), ['file:' + name])
+            curs.execute(db_change("insert into acl (title, data, type) values (?, 'admin', 'decu')"), ['file:' + name])
 
             render_set(
                 title = 'file:' + name,

+ 55 - 94
route/give_acl.py

@@ -30,24 +30,18 @@ def give_acl_2(conn, name):
                 check_ok = 'disabled'
 
     if flask.request.method == 'POST':
+        acl_data = [['decu', flask.request.form.get('decu', '')]]
+        acl_data += [['dis', flask.request.form.get('dis', '')]]
+        acl_data += [['view', flask.request.form.get('view', '')]]
+        acl_data += [['why', flask.request.form.get('why', '')]]
+        
         curs.execute(db_change("select title from acl where title = ?"), [name])
         if curs.fetchall():
-            curs.execute(db_change("update acl set decu = ? where title = ?"), [flask.request.form.get('decu', ''), name])
-            curs.execute(db_change("update acl set dis = ? where title = ?"), [flask.request.form.get('dis', ''), name])
-            curs.execute(db_change("update acl set why = ? where title = ?"), [flask.request.form.get('why', ''), name])
-            curs.execute(db_change("update acl set view = ? where title = ?"), [flask.request.form.get('view', ''), name])
+            for i in acl_data:
+                curs.execute(db_change("update acl set data = ? where title = ? and type = ?"), [i[1], name, i[0]])
         else:
-            curs.execute(db_change("insert into acl (title, decu, dis, why, view) values (?, ?, ?, ?, ?)"), [
-                name,
-                flask.request.form.get('decu', ''),
-                flask.request.form.get('dis', ''),
-                flask.request.form.get('why', ''),
-                flask.request.form.get('view', '')
-            ])
-
-        curs.execute(db_change("select title from acl where title = ? and decu = '' and dis = '' and view = ''"), [name])
-        if curs.fetchall():
-            curs.execute(db_change("delete from acl where title = ?"), [name])
+            for i in acl_data:
+                curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [name, i[1], i[0]])
 
         all_d = ''
         for i in ['decu', 'dis', 'view']:
@@ -66,93 +60,57 @@ def give_acl_2(conn, name):
 
         return redirect('/acl/' + url_pas(name))
     else:
-        data = '' + \
-            '<h2>' + load_lang('document_acl') + '</h2>' + \
-            '<hr class="main_hr">' + \
-            '<select name="decu" ' + check_ok + '>' + \
-        ''
-
-        if re.search(r'^user:', name):
-            acl_list = get_acl_list('user')
-        else:
-            acl_list = get_acl_list()
-
-        curs.execute(db_change("select decu from acl where title = ?"), [name])
-        acl_data = curs.fetchall()
-        for data_list in acl_list:
-            if acl_data and acl_data[0][0] == data_list:
-                check = 'selected="selected"'
-            else:
-                check = ''
-
-            data += '<option value="' + data_list + '" ' + check + '>' + (data_list if data_list != '' else 'normal') + '</option>'
-
-        data += '</select>'
-
+        data = ''
+        acl_list = get_acl_list('user') if re.search(r'^user:', name) else get_acl_list()
         if not re.search(r'^user:', name):
+            acl_get_list = [
+                [load_lang('document_acl'), 'decu'], 
+                [load_lang('discussion_acl'), 'dis'], 
+                [load_lang('view_acl'), 'view']
+            ]
+        else:
+            acl_get_list = [load_lang('document_acl'), 'decu']
+            
+        for i in acl_get_list:
             data += '' + \
+                '<h2>' + i[0] + '</h2>' + \
                 '<hr class="main_hr">' + \
-                '<h2>' + load_lang('discussion_acl') + '</h2>' + \
-                '<hr class="main_hr">' + \
-                '<select name="dis" ' + check_ok + '>' + \
+                '<select name="' + i[1] + '" ' + check_ok + '>' + \
             ''
-
-            curs.execute(db_change("select dis, why, view from acl where title = ?"), [name])
+    
+            curs.execute(db_change("select data from acl where title = ? and type = ?"), [name, i[1]])
             acl_data = curs.fetchall()
             for data_list in acl_list:
-                if acl_data and acl_data[0][0] == data_list:
-                    check = 'selected="selected"'
-                else:
-                    check = ''
-
+                check = 'selected="selected"' if acl_data and acl_data[0][0] == data_list else ''
                 data += '<option value="' + data_list + '" ' + check + '>' + (data_list if data_list != '' else 'normal') + '</option>'
-
+    
             data += '</select>'
+            data += '<hr class="main_hr">'
 
-            data += '' + \
-                '<hr class="main_hr">' + \
-                '<h2>' + load_lang('view_acl') + '</h2>' + \
-                '<hr class="main_hr">' + \
-                '<select name="view" ' + check_ok + '>' + \
-            ''
-            for data_list in acl_list:
-                if acl_data and acl_data[0][2] == data_list:
-                    check = 'selected="selected"'
-                else:
-                    check = ''
-
-                data += '<option value="' + data_list + '" ' + check + '>' + (data_list if data_list != '' else 'normal') + '</option>'
-
-            data += '''
-                </select>
-                <hr class="main_hr">
-                <h2 id="exp">''' + load_lang('explanation') + '''</h2>
-                <ul class="inside_ul">
-                    <li>normal : ''' + load_lang('unset') + '''</li>
-                    <li>admin : ''' + load_lang('admin_acl') + '''</li>
-                    <li>user : ''' + load_lang('member_acl') + '''</li>
-                    <li>50_edit : ''' + load_lang('50_edit_acl') + '''</li>
-                    <li>all : ''' + load_lang('all_acl') + '''</li>
-                    <li>email : ''' + load_lang('email_acl') + '''</li>
-                    <li>owner : ''' + load_lang('owner_acl') + '''</li>
-                    <li>ban : ''' + load_lang('ban_acl') + '''</li>
-                    <li>before : ''' + load_lang('before_acl') + '''</li>
-                    <li>30_day : ''' + load_lang('30_day_acl') + '''</li>
-                    <li>ban_admin : ''' + load_lang('ban_admin_acl') + '''</li>
-                </ul>
-            '''
+        curs.execute(db_change("select data from acl where title = ? and type = ?"), [name, 'why'])
+        acl_data = curs.fetchall()
+        acl_why = html.escape(acl_data[0][0]) if acl_data else ''
+        data += '' + \
+            '<hr class="main_hr">' + \
+            '<input value="' + acl_why + '" placeholder="' + load_lang('why') + '" name="why" type="text" ' + check_ok + '>' + \
+        ''
 
-            if acl_data:
-                data += '' + \
-                    '<hr class="main_hr">' + \
-                    '<input value="' + html.escape(acl_data[0][1]) + '" placeholder="' + load_lang('why') + '" name="why" type="text" ' + check_ok + '>' + \
-                ''
-            else:
-                data += '' + \
-                    '<hr class="main_hr">' + \
-                    '<input placeholder="' + load_lang('why') + '" name="why" type="text" ' + check_ok + '>' + \
-                ''
-                
+        data += '''
+            <h2 id="exp">''' + load_lang('explanation') + '''</h2>
+            <ul class="inside_ul">
+                <li>normal : ''' + load_lang('unset') + '''</li>
+                <li>admin : ''' + load_lang('admin_acl') + '''</li>
+                <li>user : ''' + load_lang('member_acl') + '''</li>
+                <li>50_edit : ''' + load_lang('50_edit_acl') + '''</li>
+                <li>all : ''' + load_lang('all_acl') + '''</li>
+                <li>email : ''' + load_lang('email_acl') + '''</li>
+                <li>owner : ''' + load_lang('owner_acl') + '''</li>
+                <li>ban : ''' + load_lang('ban_acl') + '''</li>
+                <li>before : ''' + load_lang('before_acl') + '''</li>
+                <li>30_day : ''' + load_lang('30_day_acl') + '''</li>
+                <li>ban_admin : ''' + load_lang('ban_admin_acl') + '''</li>
+            </ul>
+        '''
 
         return easy_minify(flask.render_template(skin_check(),
             imp = [name, wiki_set(), custom(), other2(['(' + load_lang('acl') + ')', 0])],
@@ -160,9 +118,12 @@ def give_acl_2(conn, name):
                 <form method="post">
                     <a href="/setting/8">(''' + load_lang('main_acl_setting') + ''')</a>
                     ''' + data + '''
-                    <hr class="main_hr">
                     <button type="submit" ''' + check_ok + '''>''' + load_lang('save') + '''</button>
                 </form>
             ''',
-            menu = [['w/' + url_pas(name), load_lang('document')], ['manager', load_lang('admin')], ['admin_log?search=' + url_pas('acl (' + name + ')'), load_lang('acl_record')]]
+            menu = [
+                ['w/' + url_pas(name), load_lang('document')], 
+                ['manager', load_lang('admin')], 
+                ['admin_log?search=' + url_pas('acl (' + name + ')'), load_lang('acl_record')]
+            ]
         ))

+ 10 - 11
route/list_acl.py

@@ -3,33 +3,32 @@ from .tool.func import *
 def list_acl_2(conn):
     curs = conn.cursor()
 
+    num = int(number_check(flask.request.args.get('num', '1')))
+    sql_num = (num * 50 - 50) if num * 50 > 0 else 0
     div = '<ul class="inside_ul">'
 
-    curs.execute(db_change("select title, why from acl where decu != '' or dis != '' or view != '' order by title desc"))
+    curs.execute(db_change("select distinct title from acl where data != '' order by title desc limit ?, 50"), [sql_num])
     list_data = curs.fetchall()
     for data in list_data:
         if not re.search(r'^user:', data[0]) and not re.search(r'^file:', data[0]):
             curs.execute(db_change("select time from re_admin where what like ? order by time desc limit 1"), ['acl (' + data[0] + ')%'])
             time_data = curs.fetchall()
-            if time_data:
-                time_data = time_data[0][0] + ' | '
-            else:
-                time_data = ''
-                
-            if data[1] != '':
-                why = ' | ' + data[1]
-            else:
-                why = ''
+            time_data = (time_data[0][0] + ' | ') if time_data else ''
+            
+            curs.execute(db_change("select data from acl where title = ? and type = 'why'"), [data[0]])
+            why_data = curs.fetchall()
+            why_data = (' | ' + why_data[0][0]) if why_data and why_data[0][0] != '' else ''
 
             div += '' + \
                 '<li>' + \
                     time_data + \
                     '<a href="/acl/' + url_pas(data[0]) + '">' + data[0] + '</a>' + \
-                     why + \
+                    why_data + \
                 '</li>' + \
             ''
 
     div += '</ul>'
+    div += next_fix('/acl_list?num=', num, list_data)
 
     return easy_minify(flask.render_template(skin_check(),
         imp = [load_lang('acl_document_list'), wiki_set(), custom(), other2([0, 0])],

+ 2 - 8
route/search_deep.py

@@ -7,10 +7,7 @@ def search_deep_2(conn, name):
         return redirect()
 
     num = int(number_check(flask.request.args.get('num', '1')))
-    if num * 50 > 0:
-        sql_num = num * 50 - 50
-    else:
-        sql_num = 0
+    sql_num = (num * 50 - 50) if num * 50 > 0 else 0
 
     div = '<ul class="inside_ul">'
 
@@ -18,10 +15,7 @@ def search_deep_2(conn, name):
     test = ''
 
     curs.execute(db_change("select title from data where title = ?"), [name])
-    if curs.fetchall():
-        link_id = ''
-    else:
-        link_id = 'id="not_thing"'
+    link_id = '' if curs.fetchall() else 'id="not_thing"'
 
     div = '''
         <ul class="inside_ul">

+ 12 - 5
route/tool/func.py

@@ -260,7 +260,6 @@ def update(ver_num, set_data):
                 i[0]
             ])
 
-    # set 1
     if ver_num < 3190201:
         today_time = get_time()
 
@@ -325,6 +324,14 @@ def update(ver_num, set_data):
                 i[1]
             ])
 
+    if ver_num < 3205500:
+        curs.execute(db_change("select title, decu, dis, view, why from acl"))
+        for i in curs.fetchall():
+            curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [i[0], i[1], 'decu'])
+            curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [i[0], i[2], 'dis'])
+            curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [i[0], i[3], 'view'])
+            curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [i[0], i[4], 'why'])
+            
     conn.commit()
 
     print('Update completed')
@@ -892,7 +899,7 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
         if admin_check(5) == 1:
             return 0
 
-        curs.execute(db_change("select decu from acl where title = ?"), ['user:' + acl_n[0]])
+        curs.execute(db_change("select data from acl where title = ? and type = 'decu'"), ['user:' + acl_n[0]])
         acl_data = curs.fetchall()
         if acl_data:
             if acl_data[0][0] == 'all':
@@ -925,7 +932,7 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
     for i in range(0, end):
         if tool == '':
             if i == 0:
-                curs.execute(db_change("select decu from acl where title = ?"), [name])
+                curs.execute(db_change("select data from acl where title = ? and type = 'decu'"), [name])
             else:
                 curs.execute(db_change('select data from other where name = "edit"'))
 
@@ -934,7 +941,7 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
             if i == 0 and topic_num:
                 curs.execute(db_change("select acl from rd where code = ?"), [topic_num])
             elif i == 1:
-                curs.execute(db_change("select dis from acl where title = ?"), [name])
+                curs.execute(db_change("select data from acl where title = ? and type = 'dis'"), [name])
             else:
                 curs.execute(db_change('select data from other where name = "discussion"'))
 
@@ -957,7 +964,7 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
         else:
             # tool == 'render'
             if i == 0:
-                curs.execute(db_change("select view from acl where title = ?"), [name])
+                curs.execute(db_change("select data from acl where title = ? and type = 'view'"), [name])
             else:
                 curs.execute(db_change("select data from other where name = 'all_view_acl'"))
 

+ 10 - 16
route/view_read.py

@@ -9,28 +9,18 @@ def view_read_2(conn, name):
     run_redirect = ''
 
     num = flask.request.args.get('num', None)
-    if num:
-        num = int(number_check(num))
+    num = int(number_check(num)) if num else None
 
     curs.execute(db_change("select sub from rd where title = ? and not stop = 'O' order by date desc"), [name])
-    if curs.fetchall():
-        topic = 1
-    else:
-        topic = 0
+    topic = 1 if curs.fetchall() else 0
 
     curs.execute(db_change("select link from back where title = ? and type = 'cat' order by link asc"), [name])
 
     curs.execute(db_change("select title from data where title like ?"), ['%' + name + '/%'])
-    if curs.fetchall():
-        down = 1
-    else:
-        down = 0
+    down = 1 if curs.fetchall() else 0
 
     m = re.search(r"^(.*)\/(.*)$", name)
-    if m:
-        uppage = m.group(1)
-    else:
-        uppage = 0
+    uppage = m.group(1) if m else 0
 
     if re.search(r'^category:', name):
         curs.execute(db_change("select link from back where title = ? and type = 'cat' order by link asc"), [name])
@@ -146,10 +136,14 @@ def view_read_2(conn, name):
         acl = 0
         r_date = 0
     else:
-        curs.execute(db_change("select decu from acl where title = ?"), [name])
+        curs.execute(db_change("select title from acl where title = ?"), [name])
         acl = 1 if curs.fetchall() else 0
         menu_acl = 1 if acl_check(name) == 1 else 0
-        menu = [['edit/' + url_pas(name), load_lang('create'), menu_acl]] if response_data == 404 else [['edit/' + url_pas(name), load_lang('edit'), menu_acl]]
+        if response_data == 404:
+            menu = [['edit/' + url_pas(name), load_lang('create'), menu_acl]] 
+        else:
+            menu = [['edit/' + url_pas(name), load_lang('edit'), menu_acl]]
+            
         menu += [
             ['topic/' + url_pas(name), load_lang('discussion'), topic], 
             ['history/' + url_pas(name), load_lang('history')], 

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
     "beta" : {
-        "r_ver" : "v3.2.0-stable-13 (beta-55) (dev-2021-03-06-01)",
-        "c_ver" : "3203400",
+        "r_ver" : "v3.2.0-stable-13 (beta-56) (dev-2021-03-13-01)",
+        "c_ver" : "3205500",
         "s_ver" : "11"
     }
 }

+ 5 - 3
views/main_css/js/load_editor.js

@@ -61,7 +61,7 @@ function pasteListener(e) {
         let haveImageInClipboard = false;
         const formData = new FormData();
         for(let i = 0; i < items.length; i++) {
-            if (items[i].type.indexOf("image") !== -1) {
+            if(items[i].type.indexOf("image") !== -1) {
                 const file = items[i].getAsFile();
                 const customName = prompt("파일 이름 (확장자 제외)");
                 
@@ -69,7 +69,8 @@ function pasteListener(e) {
                     return alert("파일 이름 없음");
                 }
                 
-                const customFile = new File([file], customName + ".png", { type: file.type });
+                var file_name = customName + ".png";
+                const customFile = new File([file], file_name, { type: file.type });
                 formData.append("f_data[]", customFile);
                 haveImageInClipboard = true;
                 e.preventDefault();
@@ -77,6 +78,7 @@ function pasteListener(e) {
                 break;
             }
         }
+
         if(!haveImageInClipboard) {
             return;
         }
@@ -90,7 +92,7 @@ function pasteListener(e) {
                 const url = res.url;
                 alert(
                     '업로드 완료 : ' +
-                    '[[' + decodeURIComponent(url.replace(/.*\/w\/file/, "file")) + ']]'
+                    '[[파일:' + file_name + ']]'
                 );
             } else {
                 console.error("[ERROR] PasteUpload Fail :", res.statusText);