Version 0.1
This commit is contained in:
parent
5593a86d2e
commit
6441f0431d
3
.gitignore
vendored
3
.gitignore
vendored
@ -66,3 +66,6 @@ target/
|
|||||||
|
|
||||||
# ---> Migrations
|
# ---> Migrations
|
||||||
migrations/*
|
migrations/*
|
||||||
|
|
||||||
|
.env
|
||||||
|
.idea/*
|
||||||
|
@ -9,7 +9,7 @@ from flask_uploads import patch_request_class
|
|||||||
|
|
||||||
from PDMI.blueprints.admin import admin
|
from PDMI.blueprints.admin import admin
|
||||||
from PDMI.blueprints.api import api, api_0_0_1
|
from PDMI.blueprints.api import api, api_0_0_1
|
||||||
from PDMI.models import db, User, Role
|
from PDMI.models import db, Users, Roles
|
||||||
from PDMI.views import main_bp
|
from PDMI.views import main_bp
|
||||||
|
|
||||||
# Config mimetype
|
# Config mimetype
|
||||||
@ -27,7 +27,7 @@ with server.app_context():
|
|||||||
db.create_all(app=server)
|
db.create_all(app=server)
|
||||||
|
|
||||||
# Setup Flask-security
|
# Setup Flask-security
|
||||||
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
|
user_datastore = SQLAlchemyUserDatastore(db, Users, Roles)
|
||||||
security = Security(server, user_datastore)
|
security = Security(server, user_datastore)
|
||||||
|
|
||||||
patch_request_class(server, 16 * 1024 * 1024)
|
patch_request_class(server, 16 * 1024 * 1024)
|
||||||
|
@ -80,7 +80,7 @@ class RolesView(ConfigurableView):
|
|||||||
class ModuleView(ConfigurableView):
|
class ModuleView(ConfigurableView):
|
||||||
inline_models = (
|
inline_models = (
|
||||||
(
|
(
|
||||||
ModuleVersion,
|
ModuleVersions,
|
||||||
{
|
{
|
||||||
'form_label': "Versions",
|
'form_label': "Versions",
|
||||||
'form_columns': ('id', 'version',)
|
'form_columns': ('id', 'version',)
|
||||||
@ -102,7 +102,7 @@ admin = Admin( # server,
|
|||||||
name='PDMI',
|
name='PDMI',
|
||||||
template_mode='bootstrap4-left',
|
template_mode='bootstrap4-left',
|
||||||
category_icon_classes={
|
category_icon_classes={
|
||||||
'Administration': 'fa fa-tools',
|
'Administration': 'fa fa-cogs',
|
||||||
},
|
},
|
||||||
endpoint='administration',
|
endpoint='administration',
|
||||||
disconnect_route="security.logout",
|
disconnect_route="security.logout",
|
||||||
|
@ -4,7 +4,7 @@ import shutil
|
|||||||
from flask import send_from_directory
|
from flask import send_from_directory
|
||||||
from flask_restful import Resource, abort
|
from flask_restful import Resource, abort
|
||||||
|
|
||||||
from PDMI.models import Module
|
from PDMI.models import Modules
|
||||||
|
|
||||||
|
|
||||||
class ApiIndex(Resource):
|
class ApiIndex(Resource):
|
||||||
|
29
Pipfile
29
Pipfile
@ -1,22 +1,31 @@
|
|||||||
[[source]]
|
[[source]]
|
||||||
|
|
||||||
url = "https://pypi.org/simple"
|
url = "https://pypi.org/simple"
|
||||||
verify_ssl = true
|
verify_ssl = true
|
||||||
name = "pypi"
|
name = "pypi"
|
||||||
|
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
flask = "*"
|
|
||||||
flask-admin = {git = "https://github.com/Fomys/flask-admin"}
|
flask-admin = {git = "https://github.com/Fomys/flask-admin"}
|
||||||
flask-babelex = "*"
|
Flask = "*"
|
||||||
flask-security = "*"
|
Flask-BabelEx = "*"
|
||||||
flask-migrate = "*"
|
Flask-Security = "*"
|
||||||
flask-script = "*"
|
Flask-Migrate = "*"
|
||||||
flask-uploads = "*"
|
Flask-Script = "*"
|
||||||
sqlalchemy = "*"
|
Flask-Uploads = "*"
|
||||||
flask-sqlalchemy = "*"
|
SQLAlchemy = "*"
|
||||||
flask-restful = "*"
|
Flask-SQLAlchemy = "*"
|
||||||
pymysql = "*"
|
Flask-RESTful = "*"
|
||||||
|
PyMySQL = "*"
|
||||||
|
mysqlclient = "*"
|
||||||
|
gunicorn = "*"
|
||||||
|
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
|
|
||||||
python_version = "3.7"
|
python_version = "3.7"
|
||||||
|
211
Pipfile.lock
generated
211
Pipfile.lock
generated
@ -1,7 +1,20 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "571c6a0f1756f8d3293e6024f4625d4c118cf6847b8133d2a60b7b7faade4190"
|
"sha256": "0c2d1d15089362ca266cf49ebcdd8ec88aec4ea44b0f26d917c7aa38c64d88c3"
|
||||||
|
},
|
||||||
|
"host-environment-markers": {
|
||||||
|
"implementation_name": "cpython",
|
||||||
|
"implementation_version": "3.7.3",
|
||||||
|
"os_name": "posix",
|
||||||
|
"platform_machine": "x86_64",
|
||||||
|
"platform_python_implementation": "CPython",
|
||||||
|
"platform_release": "4.19.27-gentoo-r1",
|
||||||
|
"platform_system": "Linux",
|
||||||
|
"platform_version": "#1 SMP Tue Apr 23 17:00:37 -00 2019",
|
||||||
|
"python_full_version": "3.7.3",
|
||||||
|
"python_version": "3.7",
|
||||||
|
"sys_platform": "linux"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -17,250 +30,138 @@
|
|||||||
},
|
},
|
||||||
"default": {
|
"default": {
|
||||||
"alembic": {
|
"alembic": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:40b9a619aa5f25ea1e1508adcda88b33704ef28e02c9cfa6471e5c772ecf0829"
|
"version": "==1.0.10"
|
||||||
],
|
|
||||||
"version": "==1.0.9"
|
|
||||||
},
|
},
|
||||||
"aniso8601": {
|
"aniso8601": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:b8a6a9b24611fc50cf2d9b45d371bfdc4fd0581d1cc52254f5502130a776d4af",
|
|
||||||
"sha256:bb167645c79f7a438f9dfab6161af9bed75508c645b1f07d1158240841d22673"
|
|
||||||
],
|
|
||||||
"version": "==6.0.0"
|
"version": "==6.0.0"
|
||||||
},
|
},
|
||||||
"babel": {
|
"babel": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:6778d85147d5d85345c14a26aada5e478ab04e39b078b0745ee6870c2b5cf669",
|
|
||||||
"sha256:8cba50f48c529ca3fa18cf81fa9403be176d374ac4d60738b839122dfaaa3d23"
|
|
||||||
],
|
|
||||||
"version": "==2.6.0"
|
"version": "==2.6.0"
|
||||||
},
|
},
|
||||||
"blinker": {
|
"blinker": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:471aee25f3992bd325afa3772f1063dbdbbca947a041b8b89466dc00d606f8b6"
|
|
||||||
],
|
|
||||||
"version": "==1.4"
|
"version": "==1.4"
|
||||||
},
|
},
|
||||||
"click": {
|
"click": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
|
|
||||||
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
|
|
||||||
],
|
|
||||||
"version": "==7.0"
|
"version": "==7.0"
|
||||||
},
|
},
|
||||||
"flask": {
|
"flask": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:2271c0070dbcb5275fad4a82e29f23ab92682dc45f9dfbc22c02ba9b9322ce48",
|
|
||||||
"sha256:a080b744b7e345ccfcbc77954861cb05b3c63786e93f2b3875e0913d44b43f05"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==1.0.2"
|
"version": "==1.0.2"
|
||||||
},
|
},
|
||||||
"flask-admin": {
|
"flask-admin": {
|
||||||
"git": "https://github.com/Fomys/flask-admin",
|
"git": "https://github.com/Fomys/flask-admin"
|
||||||
"ref": "16328db4f504f97b7d5accd8fc1fe292e31d2292"
|
|
||||||
},
|
},
|
||||||
"flask-babelex": {
|
"flask-babelex": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:cf79cdedb5ce860166120136b0e059e9d97b8df07a3bc2411f6243de04b754b4"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==0.9.3"
|
"version": "==0.9.3"
|
||||||
},
|
},
|
||||||
"flask-login": {
|
"flask-login": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:c815c1ac7b3e35e2081685e389a665f2c74d7e077cb93cecabaea352da4752ec"
|
|
||||||
],
|
|
||||||
"version": "==0.4.1"
|
"version": "==0.4.1"
|
||||||
},
|
},
|
||||||
"flask-mail": {
|
"flask-mail": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:22e5eb9a940bf407bcf30410ecc3708f3c56cc44b29c34e1726fe85006935f41"
|
|
||||||
],
|
|
||||||
"version": "==0.9.1"
|
"version": "==0.9.1"
|
||||||
},
|
},
|
||||||
"flask-migrate": {
|
"flask-migrate": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:a361578cb829681f860e4de5ed2c48886264512f0c16144e404c36ddc95ab49c",
|
|
||||||
"sha256:c24d105c5d6cc670de20f8cbfb909e04f4e04b8784d0df070005944de1f21549"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==2.4.0"
|
"version": "==2.4.0"
|
||||||
},
|
},
|
||||||
"flask-principal": {
|
"flask-principal": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:f5d6134b5caebfdbb86f32d56d18ee44b080876a27269560a96ea35f75c99453"
|
|
||||||
],
|
|
||||||
"version": "==0.4.0"
|
"version": "==0.4.0"
|
||||||
},
|
},
|
||||||
"flask-restful": {
|
"flask-restful": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:ecd620c5cc29f663627f99e04f17d1f16d095c83dc1d618426e2ad68b03092f8",
|
|
||||||
"sha256:f8240ec12349afe8df1db168ea7c336c4e5b0271a36982bff7394f93275f2ca9"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==0.3.7"
|
"version": "==0.3.7"
|
||||||
},
|
},
|
||||||
"flask-script": {
|
"flask-script": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:6425963d91054cfcc185807141c7314a9c5ad46325911bd24dcb489bd0161c65"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==2.0.6"
|
"version": "==2.0.6"
|
||||||
},
|
},
|
||||||
"flask-security": {
|
"flask-security": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:d61daa5f5a48f89f30f50555872bdf581b2c65804668b0313345cd7beff26432",
|
|
||||||
"sha256:ef837c03558db41335c8dabd16ae4977af0a5ef0c2cdecf738e33ef5202ce489"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==3.0.0"
|
"version": "==3.0.0"
|
||||||
},
|
},
|
||||||
"flask-sqlalchemy": {
|
"flask-sqlalchemy": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:3bc0fac969dd8c0ace01b32060f0c729565293302f0c4269beed154b46bec50b",
|
"version": "==2.4.0"
|
||||||
"sha256:5971b9852b5888655f11db634e87725a9031e170f37c0ce7851cf83497f56e53"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==2.3.2"
|
|
||||||
},
|
},
|
||||||
"flask-uploads": {
|
"flask-uploads": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:53ecbd6033667d50ae02b63adebbaa33c7fc56c09e5293025810cf9d841ecb02"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==0.2.1"
|
"version": "==0.2.1"
|
||||||
},
|
},
|
||||||
"flask-wtf": {
|
"flask-wtf": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:5d14d55cfd35f613d99ee7cba0fc3fbbe63ba02f544d349158c14ca15561cc36",
|
|
||||||
"sha256:d9a9e366b32dcbb98ef17228e76be15702cd2600675668bca23f63a7947fd5ac"
|
|
||||||
],
|
|
||||||
"version": "==0.14.2"
|
"version": "==0.14.2"
|
||||||
},
|
},
|
||||||
|
"gunicorn": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==19.9.0"
|
||||||
|
},
|
||||||
"itsdangerous": {
|
"itsdangerous": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19",
|
|
||||||
"sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"
|
|
||||||
],
|
|
||||||
"version": "==1.1.0"
|
"version": "==1.1.0"
|
||||||
},
|
},
|
||||||
"jinja2": {
|
"jinja2": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013",
|
|
||||||
"sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b"
|
|
||||||
],
|
|
||||||
"version": "==2.10.1"
|
"version": "==2.10.1"
|
||||||
},
|
},
|
||||||
"mako": {
|
"mako": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:0728c404877cd4ca72c409c0ea372dc5f3b53fa1ad2bb434e1d216c0444ff1fd"
|
|
||||||
],
|
|
||||||
"version": "==1.0.9"
|
"version": "==1.0.9"
|
||||||
},
|
},
|
||||||
"markupsafe": {
|
"markupsafe": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
|
|
||||||
"sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
|
|
||||||
"sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
|
|
||||||
"sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
|
|
||||||
"sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
|
|
||||||
"sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
|
|
||||||
"sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
|
|
||||||
"sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
|
|
||||||
"sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
|
|
||||||
"sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
|
|
||||||
"sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
|
|
||||||
"sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
|
|
||||||
"sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
|
|
||||||
"sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
|
|
||||||
"sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
|
|
||||||
"sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
|
|
||||||
"sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
|
|
||||||
"sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
|
|
||||||
"sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
|
|
||||||
"sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
|
|
||||||
"sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
|
|
||||||
"sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
|
|
||||||
"sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
|
|
||||||
"sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
|
|
||||||
"sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
|
|
||||||
"sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
|
|
||||||
"sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
|
|
||||||
"sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"
|
|
||||||
],
|
|
||||||
"version": "==1.1.1"
|
"version": "==1.1.1"
|
||||||
},
|
},
|
||||||
|
"mysqlclient": {
|
||||||
|
"hashes": [],
|
||||||
|
"version": "==1.4.2.post1"
|
||||||
|
},
|
||||||
"passlib": {
|
"passlib": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:3d948f64138c25633613f303bcc471126eae67c04d5e3f6b7b8ce6242f8653e0",
|
|
||||||
"sha256:43526aea08fa32c6b6dbbbe9963c4c767285b78147b7437597f992812f69d280"
|
|
||||||
],
|
|
||||||
"version": "==1.7.1"
|
"version": "==1.7.1"
|
||||||
},
|
},
|
||||||
"pymysql": {
|
"pymysql": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:3943fbbbc1e902f41daf7f9165519f140c4451c179380677e6a848587042561a",
|
|
||||||
"sha256:d8c059dcd81dedb85a9f034d5e22dcb4442c0b201908bede99e306d65ea7c8e7"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==0.9.3"
|
"version": "==0.9.3"
|
||||||
},
|
},
|
||||||
"python-dateutil": {
|
"python-dateutil": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb",
|
|
||||||
"sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e"
|
|
||||||
],
|
|
||||||
"version": "==2.8.0"
|
"version": "==2.8.0"
|
||||||
},
|
},
|
||||||
"python-editor": {
|
"python-editor": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:1bf6e860a8ad52a14c3ee1252d5dc25b2030618ed80c022598f00176adc8367d",
|
|
||||||
"sha256:51fda6bcc5ddbbb7063b2af7509e43bd84bfc32a4ff71349ec7847713882327b",
|
|
||||||
"sha256:5f98b069316ea1c2ed3f67e7f5df6c0d8f10b689964a4a811ff64f0106819ec8"
|
|
||||||
],
|
|
||||||
"version": "==1.0.4"
|
"version": "==1.0.4"
|
||||||
},
|
},
|
||||||
"pytz": {
|
"pytz": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda",
|
|
||||||
"sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141"
|
|
||||||
],
|
|
||||||
"version": "==2019.1"
|
"version": "==2019.1"
|
||||||
},
|
},
|
||||||
"six": {
|
"six": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
|
|
||||||
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
|
|
||||||
],
|
|
||||||
"version": "==1.12.0"
|
"version": "==1.12.0"
|
||||||
},
|
},
|
||||||
"speaklater": {
|
"speaklater": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:59fea336d0eed38c1f0bf3181ee1222d0ef45f3a9dd34ebe65e6bfffdd6a65a9"
|
|
||||||
],
|
|
||||||
"version": "==1.3"
|
"version": "==1.3"
|
||||||
},
|
},
|
||||||
"sqlalchemy": {
|
"sqlalchemy": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:91c54ca8345008fceaec987e10924bf07dcab36c442925357e5a467b36a38319"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==1.3.3"
|
"version": "==1.3.3"
|
||||||
},
|
},
|
||||||
"werkzeug": {
|
"werkzeug": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:0a73e8bb2ff2feecfc5d56e6f458f5b99290ef34f565ffb2665801ff7de6af7a",
|
|
||||||
"sha256:7fad9770a8778f9576693f0cc29c7dcc36964df916b83734f4431c0e612a7fbc"
|
|
||||||
],
|
|
||||||
"version": "==0.15.2"
|
"version": "==0.15.2"
|
||||||
},
|
},
|
||||||
"wtforms": {
|
"wtforms": {
|
||||||
"hashes": [
|
"hashes": [],
|
||||||
"sha256:0cdbac3e7f6878086c334aa25dc5a33869a3954e9d1e015130d65a69309b3b61",
|
|
||||||
"sha256:e3ee092c827582c50877cdbd49e9ce6d2c5c1f6561f849b3b068c1b8029626f1"
|
|
||||||
],
|
|
||||||
"version": "==2.2.1"
|
"version": "==2.2.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
155
conf.sh
Normal file
155
conf.sh
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
: ${DIALOG_OK=0}
|
||||||
|
: ${DIALOG_CANCEL=1}
|
||||||
|
: ${DIALOG_HELP=2}
|
||||||
|
: ${DIALOG_EXTRA=3}
|
||||||
|
: ${DIALOG_ITEM_HELP=4}
|
||||||
|
: ${DIALOG_ESC=255}
|
||||||
|
|
||||||
|
DIALOG=dialog
|
||||||
|
|
||||||
|
CONFIG_VARS="DATABASE_URI"
|
||||||
|
|
||||||
|
set_env_var () {
|
||||||
|
exec 3>&1
|
||||||
|
source .env
|
||||||
|
load_config
|
||||||
|
local value=$($DIALOG \
|
||||||
|
--backtitle "Configuration" \
|
||||||
|
--title $1 \
|
||||||
|
--inputbox "Veuillez insérez la nouvelle valeur de la variable ${1}:" \
|
||||||
|
0 0 \
|
||||||
|
${!1} \
|
||||||
|
2>&1 1>&3)
|
||||||
|
local exit_status=$?
|
||||||
|
exec 3>&-
|
||||||
|
close $exit_status
|
||||||
|
export $1=$value
|
||||||
|
save_config
|
||||||
|
}
|
||||||
|
|
||||||
|
close () {
|
||||||
|
case $1 in
|
||||||
|
$DIALOG_CANCEL)
|
||||||
|
exit;;
|
||||||
|
$DIALOG_ESC)
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
load_config () {
|
||||||
|
source .env
|
||||||
|
}
|
||||||
|
|
||||||
|
save_config () {
|
||||||
|
export -p | grep -E "(${CONFIG_VARS})=" > .env
|
||||||
|
}
|
||||||
|
|
||||||
|
bdd_config () {
|
||||||
|
exec 3>&1
|
||||||
|
local selection=$($DIALOG \
|
||||||
|
--backtitle "Base de donnée" \
|
||||||
|
--menu "Que souhaitez vous faire?" \
|
||||||
|
0 0 0 \
|
||||||
|
"1" "manage db init" \
|
||||||
|
"2" "manage db migrate" \
|
||||||
|
"3" "manage db upgrade" \
|
||||||
|
2>&1 1>&3)
|
||||||
|
local exit_status=$?
|
||||||
|
exec 3>&-
|
||||||
|
close $exit_status
|
||||||
|
source .env
|
||||||
|
case $selection in
|
||||||
|
1)
|
||||||
|
pipenv run python manage.py db init;;
|
||||||
|
2)
|
||||||
|
pipenv run python manage.py db migrate;;
|
||||||
|
3)
|
||||||
|
pipenv run python manage.py db upgrade;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
add_super_admin () {
|
||||||
|
exec 3>&1
|
||||||
|
local utilisateur=$($DIALOG \
|
||||||
|
--backtitle "Utilitaires" \
|
||||||
|
--title "Administrateurs" \
|
||||||
|
--inputbox "Entrez le mail de l'utilisateur que vous voulez passer en superadministrateur" \
|
||||||
|
0 0 \
|
||||||
|
"" \
|
||||||
|
2>&1 1>&3)
|
||||||
|
local exit_status=$?
|
||||||
|
exec 3>&-
|
||||||
|
close $exit_status
|
||||||
|
source .env
|
||||||
|
pipenv run python manage.py set_superadmin -m "${utilisateur}"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
configuration () {
|
||||||
|
exec 3>&1
|
||||||
|
local selection=$($DIALOG \
|
||||||
|
--backtitle "Configuration" \
|
||||||
|
--menu "Quelle variable modifier?" \
|
||||||
|
0 0 0 \
|
||||||
|
"1" "DATABASE_URI" \
|
||||||
|
2>&1 1>&3)
|
||||||
|
exit_status=$?
|
||||||
|
exec 3>&-
|
||||||
|
close $exit_status
|
||||||
|
case $selection in
|
||||||
|
1)
|
||||||
|
set_env_var "DATABASE_URI";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
utilitaires () {
|
||||||
|
exec 3>&1
|
||||||
|
selection=$($DIALOG \
|
||||||
|
--backtitle "Utilitaires" \
|
||||||
|
--menu "Que voulez vous faire?" \
|
||||||
|
0 0 0 \
|
||||||
|
"1" "Ajouter un superadministrateur" \
|
||||||
|
"2" "Installation de pipenv" \
|
||||||
|
2>&1 1>&3)
|
||||||
|
exit_status=$?
|
||||||
|
exec 3>&-
|
||||||
|
close $exit_status
|
||||||
|
case $selection in
|
||||||
|
1)
|
||||||
|
add_super_admin;;
|
||||||
|
2)
|
||||||
|
pipenv install;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
exec 3>&1
|
||||||
|
selection=$($DIALOG \
|
||||||
|
--backtitle "Configuration" \
|
||||||
|
--menu "Que souhaitez vous faire?" \
|
||||||
|
0 0 0 \
|
||||||
|
"1" "Gestion de la base de donnée" \
|
||||||
|
"2" "Configuration" \
|
||||||
|
"3" "Utilitaires" \
|
||||||
|
"4" "Démarre le serveur" \
|
||||||
|
"5" "Quitter" \
|
||||||
|
2>&1 1>&3)
|
||||||
|
exit_status=$?
|
||||||
|
exec 3>&-
|
||||||
|
close $exit_status
|
||||||
|
case $selection in
|
||||||
|
1)
|
||||||
|
bdd_config;;
|
||||||
|
2)
|
||||||
|
configuration;;
|
||||||
|
3)
|
||||||
|
utilitaires;;
|
||||||
|
4)
|
||||||
|
source .env
|
||||||
|
pipenv run gunicorn --bind 0.0.0.0:5000 wsgy;;
|
||||||
|
5)
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
done
|
20
manage.py
20
manage.py
@ -2,15 +2,31 @@ from flask import url_for
|
|||||||
from flask_migrate import Migrate, MigrateCommand
|
from flask_migrate import Migrate, MigrateCommand
|
||||||
from flask_script import Manager
|
from flask_script import Manager
|
||||||
|
|
||||||
from PDMI import server, db
|
from PDMI import server, db, Roles, Users
|
||||||
|
|
||||||
server.config.from_object('LBI_PiPy.config')
|
server.config.from_object('PDMI.config')
|
||||||
|
|
||||||
migrate = Migrate(server, db)
|
migrate = Migrate(server, db)
|
||||||
manager = Manager(server)
|
manager = Manager(server)
|
||||||
|
|
||||||
manager.add_command('db', MigrateCommand)
|
manager.add_command('db', MigrateCommand)
|
||||||
|
|
||||||
|
@manager.option('-m', '--mail', help="Mail de l'utilisateur à mettre en admin")
|
||||||
|
def set_superadmin(mail):
|
||||||
|
roles = Roles.query.filter(Roles.name == "superadmin").all()
|
||||||
|
if len(roles) == 0:
|
||||||
|
superAdminRole = Roles(name="superadmin", description="Role pour les super administrateurs")
|
||||||
|
db.session.add(superAdminRole)
|
||||||
|
db.session.commit()
|
||||||
|
role = Roles.query.filter(Roles.name == "superadmin").first()
|
||||||
|
users = Users.query.filter(Users.email == mail).all()
|
||||||
|
if len(users) == 0:
|
||||||
|
print("Aucun compte avec le mail {mail} existe, annulation".format(mail=mail))
|
||||||
|
return
|
||||||
|
user = Users.query.filter(Users.email == mail).first()
|
||||||
|
user.roles.append(role)
|
||||||
|
db.session.commit()
|
||||||
|
print("Role ajouté")
|
||||||
|
|
||||||
@manager.command
|
@manager.command
|
||||||
def list_routes():
|
def list_routes():
|
||||||
|
Loading…
Reference in New Issue
Block a user