This commit is contained in:
RemiZOffAlex
2019-04-26 15:38:41 +03:00
parent 48ebf82a1f
commit 60802cec8e
21 changed files with 48 additions and 75 deletions

3
.pylintrc Normal file
View File

@@ -0,0 +1,3 @@
[MESSAGES CONTROL]
disable=C0111, C0103, C0301

View File

@@ -1,9 +1,7 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
CONFIG = 'config.demo' CONFIG = 'config.demo'

View File

@@ -1,10 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
import os import os
import sys import sys

View File

@@ -1,11 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
import config import config
import logging import logging
@@ -19,9 +16,11 @@ app.config.from_object(config.CONFIG)
app.config.from_envvar('FLASKR_SETTINGS', silent=True) app.config.from_envvar('FLASKR_SETTINGS', silent=True)
# Логирование # Логирование
handler = RotatingFileHandler(app.config['LOG_FILE'], handler = RotatingFileHandler(
app.config['LOG_FILE'],
maxBytes=app.config['LOG_FILE_SIZE']*1024*1024, maxBytes=app.config['LOG_FILE_SIZE']*1024*1024,
backupCount=1) backupCount=1
)
handler.setLevel(logging.INFO) handler.setLevel(logging.INFO)
formatter = logging.Formatter(app.config['LONG_LOG_FORMAT']) formatter = logging.Formatter(app.config['LONG_LOG_FORMAT'])
handler.setFormatter(formatter) handler.setFormatter(formatter)

View File

@@ -1,10 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
from .users import LoginForm from .users import LoginForm
from .page import PageEdit from .page import PageEdit

View File

@@ -1,17 +1,12 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
from wtforms import ( from wtforms import (
Form, Form,
BooleanField,
TextField, TextField,
PasswordField,
TextAreaField TextAreaField
) )

View File

@@ -1,13 +1,11 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
from wtforms import Form, TextField, PasswordField
from wtforms import Form, BooleanField, TextField, PasswordField
class LoginForm(Form): class LoginForm(Form):
username = TextField('Имя пользователя') username = TextField('Имя пользователя')

View File

@@ -1,10 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
from .pagination import Pagination, getpage from .pagination import Pagination, getpage
from .passwd import pwgen, get_hash_password from .passwd import pwgen, get_hash_password

View File

@@ -1,17 +1,16 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
from flask import session, request from flask import session, request
from .. import app, models from .. import app, models
def get_user(): def get_user():
"""Получить текущего пользователя""" """
Получить текущего пользователя
"""
result = None result = None
if 'user_id' in session: if 'user_id' in session:
result = models.db_session.query( result = models.db_session.query(

View File

@@ -1,10 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
from math import ceil from math import ceil

View File

@@ -1,10 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
def gettree(number, count=3): def gettree(number, count=3):
""" """

View File

@@ -1,11 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy.orm import scoped_session, sessionmaker

View File

@@ -1,11 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
import datetime import datetime
from sqlalchemy import ( from sqlalchemy import (
@@ -23,6 +20,9 @@ from . import Base
class User(Base): class User(Base):
"""
Пользователи
"""
__tablename__ = "user" __tablename__ = "user"
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)

View File

@@ -1,11 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
from flask_jsonrpc import JSONRPC from flask_jsonrpc import JSONRPC

View File

@@ -1,11 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
from flask import abort, escape from flask import abort, escape

View File

@@ -1,11 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
import os import os
import jinja2 import jinja2

View File

@@ -1,11 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
from flask import render_template from flask import render_template

View File

@@ -1,10 +1,8 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
from myapp import app from myapp import app
from flask import Flask, render_template, request from flask import Flask, render_template, request
@@ -45,6 +43,9 @@ def edit():
@app.route('/login', methods=['GET', 'POST']) @app.route('/login', methods=['GET', 'POST'])
def login(): def login():
"""
Логин
"""
pagedata = {} pagedata = {}
pagedata['form'] = forms.LoginForm(request.form) pagedata['form'] = forms.LoginForm(request.form)
body = render_template('login.html', pagedata=pagedata) body = render_template('login.html', pagedata=pagedata)

7
run.py
View File

@@ -1,5 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
from myapp import app as application from myapp import app as application

View File

@@ -1,11 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
import os import os
import sys import sys
@@ -18,8 +17,10 @@ from myapp import app, lib, models
def main(): def main():
parser = argparse.ArgumentParser(description='Скрипт добавления пользователя', parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter) description='Скрипт добавления пользователя',
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser._optionals.title = "Необязательные аргументы" parser._optionals.title = "Необязательные аргументы"
parser.add_argument("--user", dest="user", required=True, help="Новый пользователь") parser.add_argument("--user", dest="user", required=True, help="Новый пользователь")

View File

@@ -1,10 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex' __author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex' __copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT' __license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru' __email__ = 'remizoffalex@mail.ru'
__url__ = 'http://remizoffalex.ru' __url__ = 'https://remizoffalex.ru'
from myapp import app as application from myapp import app as application