#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

from utils.site_manager import Manager
import utils.site_template as template

selected_table = Manager.cookie["table_grants"].value
selected_user = Manager.cookie["user_grants"].value

grants_list = Manager.sql_user_table_grants(selected_user, selected_table)

grants_list_form = template.user_table_grants(grants_list)

content = """
<h2>Список привилегий пользователя {0} в таблице {1}</h2>
<a href='users_list_tables.py'>Назад</a>
<p>Назначьте привелегии</p>

<form action='users_list_tables_grants_form.py'>
    {2}
    <input type='submit' value='Назначить'>
</form>""".format(selected_user, selected_table, grants_list_form)

template.build_with_content(content)
Beispiel #2
0
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

from utils.site_manager import Manager
import utils.site_template as template

selected_db = Manager.cookie["database"].value

tables_list = Manager.sql_db_tables_list(selected_db)

options = template.build_option_list(tables_list, one_column=True)

is_su = Manager.sql_is_user_su()
su_links = template.su_postgres_links(is_su)

content = """
<h2>Список таблиц базы данных {1}</h2>
{2}
<p>Доступны только те таблицы, на которые пользователь имеет <br>
привилегию <strong>SELECT</strong>.</p>
<p>Выберете таблицу</p>

<form action='select_db_tables_form.py' method='post'>
    <div>
        <select name='table_list' id='table_list' size='5'>
            {0}
        </select>
    </div>
    
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import cgi
from utils.site_manager import Manager
import utils.site_template as template

form = cgi.FieldStorage()

is_select = form.getfirst('SELECT')
is_insert = form.getfirst('INSERT')
is_update = form.getfirst('UPDATE')
is_delete = form.getfirst('DELETE')

grants_list = (is_select, is_insert, is_update, is_delete)

Manager.sql_set_grants(grants_list)

template.redirect('users_list_tables_grants.py')
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import utils.site_template as template
from utils.site_manager import Manager

options = template.build_option_list(Manager.sql_db_list(), True)

content = """
<h2>Подключение к базе данных</h2>
<p>Выберете базу данных</p>

<form action='select_db_form.py' method='post'>
    <div>
        <select name='db_list' id='db_list' size='5'>
            {0}
        </select>
    </div>
    
    <input type='submit' value='Выбрать'>
</form>

<br>
<a href='index.py'>Назад</a>
""".format(options)

template.build_with_content(content)
#!/home/mrdiz/anaconda3/bin/python

import sys

sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import cgi
import html

from utils.site_manager import Manager
import utils.site_template as template

selected_table = Manager.cookie["table"].value

headers_list = Manager.sql_select(
    'column_name, data_type', 'information_schema.columns',
    "(table_schema='public') AND (table_name='{0}')".format(selected_table))

headers_values = []

form = cgi.FieldStorage()

for item in headers_list:
    value = form.getfirst(item[0])
    type = item[1]
    value = html.escape(value)

    list_item = (value, type)

    headers_values.append(list_item)
Beispiel #6
0
import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import re
import cgi

from utils.site_manager import Manager
import utils.site_template as template

form = cgi.FieldStorage()

selected_table = Manager.cookie["table"].value
selected_row = form.getfirst('row_update')

headers_list = Manager.sql_select(
    'column_name, column_default', 'information_schema.columns',
    "(table_schema='public') AND (table_name='{0}')".format(selected_table))

re_match = r"nextval\('.*'::regclass\)"
pk_column = ''

for item in headers_list:
    res = re.search(re_match, str(item[1]))

    if res:
        pk_column = item[0]
        break

Manager.cookie["pk_column"] = pk_column
Manager.cookie["selected_row"] = selected_row
print(Manager.cookie)
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import utils.site_template as template
from utils.site_manager import Manager

users_list = Manager.sql_select('usename', 'pg_user')

options_list = template.build_option_list(users_list, True)

content = """
<h2>Список пользователей</h2>
<p>Выбирите пользователя, чтобы настроить его права</p>

<form action='users_list_form.py' method='post'>
    <div>
        <select name='users_list' id='users_list' size='5'>
            {0}
        </select>
    </div>
    
    <input type='submit' value='Выбрать'>
</form>

<br>
<a href='select_db_tables.py'>Назад</a>""".format(options_list)

template.build_with_content(content)
Beispiel #8
0
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

from utils.site_manager import Manager
import utils.site_template as template

selected_table = Manager.cookie["table"].value

headers_list = Manager.sql_select(
    'column_name', 'information_schema.columns',
    "(table_schema='public') AND (table_name='{0}')".format(selected_table))

data_list = Manager.sql_select('*', selected_table)

content_table = template.form_table(data_list, headers_list)

grant_list = Manager.sql_table_grant()
alter_buttons = template.table_alter_buttons(grant_list)

content = """
<h2>Список данных в таблице {0}</h2>
<a href='select_db_tables.py'>Назад</a>
<br><br>
{2}
<br>

{1}""".format(selected_table, content_table, alter_buttons)

template.build_with_content(content)
#!/home/mrdiz/anaconda3/bin/python

import sys

sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import cgi
import html
from utils.site_manager import Manager

form = cgi.FieldStorage()
user_login = form.getfirst("login", "")
user_pas = form.getfirst("pas", "")

user_login = html.escape(user_login)
user_pas = html.escape(user_pas)

Manager.sql_login(user_login, user_pas)
Beispiel #10
0
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

from utils.site_manager import Manager
import utils.site_template as template

selected_table = Manager.cookie["table"].value

data_list = Manager.sql_select('*', selected_table)

data_list = template.reformat_list(data_list)
options_list = template.build_option_list(data_list)

content = """
<h2>Обновить данные в таблице {0}</h2>
<p><a href='table.py'>Назад</a></p>
<p>Выберете строку для редактирования</p>

<form action='table_update_row.py' method='post'>
    <select name='row_update' id='row_update' size='10'>
    {1}
    </select>
    <br>
    <input type='submit' value='Изменить'>
</form>
""".format(selected_table, options_list)

template.build_with_content(content)
#!/home/mrdiz/anaconda3/bin/python

import sys

sys.path.append("/home/mrdiz/SQL/Lab5(2)")

from utils.site_manager import Manager
import utils.site_template as template

selected_db = Manager.cookie["database"].value
selected_user = Manager.cookie["user_grants"].value

tables_list = Manager.sql_db_tables_list(selected_db)

options = template.build_option_list(tables_list, one_column=True)

content = """
<h2>Список таблиц базы данных {1}</h2>
<p>Выберете таблицу, чтобы редактировать привилегии <br>
пользователя <strong>{2}</strong>.</p>

<form action='users_list_tables_form.py' method='post'>
    <div>
        <select name='table_list' id='table_list' size='5'>
            {0}
        </select>
    </div>

    <input type='submit' value='Выбрать'>
</form>