up
This commit is contained in:
commit
8e24ffd81a
9 changed files with 217 additions and 0 deletions
61
.gitignore
vendored
Normal file
61
.gitignore
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
settings.ini
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### Python template
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
6
app.py
Normal file
6
app.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
from app import app
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run()
|
23
cli-admin-add.py
Normal file
23
cli-admin-add.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import argparse
|
||||||
|
from uuid import uuid4
|
||||||
|
from hashlib import md5
|
||||||
|
from app import models
|
||||||
|
|
||||||
|
__author__ = 'vanzhiganov'
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='')
|
||||||
|
parser.add_argument('--email', dest="email")
|
||||||
|
parser.add_argument('--password', dest="password")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
admin_id = uuid4()
|
||||||
|
# todo: validate admin email
|
||||||
|
admin_email = args.email
|
||||||
|
admin_password = md5(args.password).hexdigest()
|
||||||
|
|
||||||
|
if models.Admins.select().where(models.Admins.email == args.email).count() == 0:
|
||||||
|
models.Admins.create(id=admin_id, email=admin_email, password=admin_password, status=1)
|
||||||
|
else:
|
||||||
|
print "Admin account with email '%s' already exists." % admin_email
|
20
cli-admin-ls.py
Normal file
20
cli-admin-ls.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
|
||||||
|
__author__ = 'vanzhiganov'
|
||||||
|
|
||||||
|
|
||||||
|
admins_total = models.Admins.select().count()
|
||||||
|
admins_items = models.Admins.select()
|
||||||
|
|
||||||
|
print "Total admins: %i" % admins_total
|
||||||
|
|
||||||
|
if admins_total == 0:
|
||||||
|
print ''
|
||||||
|
else:
|
||||||
|
print 'List:'
|
||||||
|
for item in admins_items:
|
||||||
|
print '%s\t%s\t%s' % (item.id, item.email, item.status)
|
||||||
|
print '---'
|
||||||
|
print 'For create a new admin account use command "procdn-admin-add --email <email> --password <password>"'
|
29
cli-admin-passwd.py
Normal file
29
cli-admin-passwd.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from uuid import uuid4
|
||||||
|
from hashlib import md5
|
||||||
|
from app import models
|
||||||
|
|
||||||
|
__author__ = 'vanzhiganov'
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='')
|
||||||
|
parser.add_argument('--email', dest="email")
|
||||||
|
parser.add_argument('--password', dest="password")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
admin_id = uuid4()
|
||||||
|
# todo: validate admin email
|
||||||
|
admin_email = args.email
|
||||||
|
admin_password = md5(args.password).hexdigest()
|
||||||
|
|
||||||
|
if models.Admins.select().where(models.Admins.email == args.email).count() == 0:
|
||||||
|
print "Admin account with email '%s' not exists." % admin_email
|
||||||
|
print '---'
|
||||||
|
print 'For create a new admin account use command "procdn-admin-add --email <email> --password <password>"'
|
||||||
|
else:
|
||||||
|
query = models.Admins.update(password=admin_password).where(models.Admins.email == admin_email)
|
||||||
|
query.execute()
|
||||||
|
print 'Password updated.'
|
17
cli-database-init.py
Normal file
17
cli-database-init.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
from app import models
|
||||||
|
|
||||||
|
models.database.create_tables({
|
||||||
|
models.Admins,
|
||||||
|
models.DataCenters,
|
||||||
|
models.Servers,
|
||||||
|
models.ServersSettings,
|
||||||
|
models.Ips,
|
||||||
|
models.Settings,
|
||||||
|
models.Users,
|
||||||
|
models.UsersBalance,
|
||||||
|
models.UsersBalanceTransactions,
|
||||||
|
models.UsersDetails,
|
||||||
|
models.UsersRecoveryCodes,
|
||||||
|
models.UsersSecrets,
|
||||||
|
models.Containers
|
||||||
|
}, safe=True)
|
45
cli-settings-init.py
Normal file
45
cli-settings-init.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import argparse
|
||||||
|
from uuid import uuid4
|
||||||
|
from hashlib import md5
|
||||||
|
from app import models
|
||||||
|
|
||||||
|
__author__ = 'vanzhiganov'
|
||||||
|
|
||||||
|
|
||||||
|
def create_key(key, val=''):
|
||||||
|
if models.Settings.select().where(models.Settings.key == key).count() == 0:
|
||||||
|
models.Settings.create(key=key, val=val)
|
||||||
|
else:
|
||||||
|
print 'key %s already exists' % key
|
||||||
|
|
||||||
|
|
||||||
|
create_key('bonus', '300')
|
||||||
|
create_key('PAY_ROBOKASSA_LOGING', '')
|
||||||
|
create_key('PAY_ROBOKASSA_PASSWORD1', '')
|
||||||
|
create_key('PAY_ROBOKASSA_PASSWORD2', '')
|
||||||
|
create_key('PAY_ROBOKASSA_ENABLED', '')
|
||||||
|
create_key('SMTP_PORT', '')
|
||||||
|
create_key('SMTP_USERNAME', '')
|
||||||
|
create_key('SMTP_PASSWORD', '')
|
||||||
|
create_key('SMTP_TIMEOUT', '')
|
||||||
|
create_key('SMTP_FROM', '')
|
||||||
|
create_key('SMTP_SENDER', '')
|
||||||
|
create_key('SMTP_SSL', '1')
|
||||||
|
create_key('SMTP_SERVER', 'smtp.yandex.ru')
|
||||||
|
create_key('CLOUDNS_EMAIL', '')
|
||||||
|
create_key('CLOUDNS_SECRET', '')
|
||||||
|
create_key('CLOUDNS_DOMAIN', '')
|
||||||
|
create_key('CLOUDNS_HOST_BALANCE', 'servers.gocloud.ru.')
|
||||||
|
create_key('CLOUDNS_HOST_BALANCE', 'lb.gocloud.ru')
|
||||||
|
create_key('footer_code', '')
|
||||||
|
|
||||||
|
create_key("mail.template_name", "simple")
|
||||||
|
create_key('mail.logotype', "https://procdn.ru/static/images/logo/procdn-logo-48.png")
|
||||||
|
create_key("mail.company_name", "ProCDN.ru")
|
||||||
|
|
||||||
|
create_key("contacts.email", "support@procdn.ru")
|
||||||
|
create_key("contacts.phone", "+7 499 7020 236")
|
||||||
|
|
||||||
|
create_key("social.googleplus", "http://plus.google.com/#efef")
|
||||||
|
create_key("social.facebook", "")
|
||||||
|
create_key("social.twitter", "")
|
6
requirements.txt
Normal file
6
requirements.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Flask==0.10.1
|
||||||
|
psycopg2==2.6.1
|
||||||
|
requests==2.7.0
|
||||||
|
uWSGI==2.0.11.1
|
||||||
|
wsgiref==0.1.2
|
||||||
|
validators
|
10
settings.origin.ini
Normal file
10
settings.origin.ini
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[Database]
|
||||||
|
host = localhost
|
||||||
|
user = postgres
|
||||||
|
password = postgres
|
||||||
|
port = 5432
|
||||||
|
name = gocloud
|
||||||
|
|
||||||
|
[Application]
|
||||||
|
DEBUG = true
|
||||||
|
secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
|
Loading…
Add table
Reference in a new issue