update bootstrap
This commit is contained in:
parent
9559d029bf
commit
e02f002f7e
13
oshipka.sh
13
oshipka.sh
@ -8,11 +8,13 @@ echo "oshipka is at: $OSHIPKA_PATH"
|
|||||||
|
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
HELP="
|
HELP="
|
||||||
Usage $0 [ bootstrap | worker | web ]
|
Usage $0 [ bootstrap | worker | web | venv | install ]
|
||||||
|
|
||||||
bootstrap [PROJECT_PATH] Create a new project in PROJECT_PATH
|
bootstrap [PROJECT_PATH] Create a new project in PROJECT_PATH
|
||||||
worker Start worker
|
worker Start worker
|
||||||
web Start webapp
|
web Start webapp
|
||||||
|
venv Init venv
|
||||||
|
install Install requirements
|
||||||
"
|
"
|
||||||
|
|
||||||
worker () {
|
worker () {
|
||||||
@ -64,7 +66,10 @@ bootstrap() {
|
|||||||
mkdir -p ${PROJECT_PATH}
|
mkdir -p ${PROJECT_PATH}
|
||||||
cp -r ${OSHIPKA_PATH}/bootstrap/* ${PROJECT_PATH}/
|
cp -r ${OSHIPKA_PATH}/bootstrap/* ${PROJECT_PATH}/
|
||||||
cp ${OSHIPKA_PATH}/bootstrap/.gitignore ${PROJECT_PATH}/.gitignore
|
cp ${OSHIPKA_PATH}/bootstrap/.gitignore ${PROJECT_PATH}/.gitignore
|
||||||
|
cd ${PROJECT_PATH}
|
||||||
init_venv
|
init_venv
|
||||||
|
source venv/bin/activate
|
||||||
|
pip install -e ${OSHIPKA_PATH}
|
||||||
}
|
}
|
||||||
|
|
||||||
command_main() {
|
command_main() {
|
||||||
@ -76,6 +81,12 @@ command_main() {
|
|||||||
;;
|
;;
|
||||||
web) web "$@"
|
web) web "$@"
|
||||||
;;
|
;;
|
||||||
|
venv) init_venv "$@"
|
||||||
|
;;
|
||||||
|
install) install_reqs "$@"
|
||||||
|
;;
|
||||||
|
link) install_reqs "$@"
|
||||||
|
;;
|
||||||
*) >&2 echo -e "${HELP}"
|
*) >&2 echo -e "${HELP}"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
import inflect
|
import inflect
|
||||||
from flask import flash, render_template, redirect, request, url_for
|
from flask import flash, render_template, redirect, request, url_for
|
||||||
|
|
||||||
@ -50,6 +52,24 @@ def update_view(model_view, template):
|
|||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
|
def create_view(model_view, template):
|
||||||
|
def inner():
|
||||||
|
if request.method == "GET":
|
||||||
|
return render_template(template)
|
||||||
|
serialized_form = serialize_form()
|
||||||
|
|
||||||
|
_next = serialized_form.pop('_next') if '_next' in serialized_form else None
|
||||||
|
|
||||||
|
serialized_form['uuid'] = str(uuid4())
|
||||||
|
instance = model_view.model(**serialized_form)
|
||||||
|
db.session.add(instance)
|
||||||
|
db.session.commit()
|
||||||
|
flash("Created {}".format(model_view.model_name))
|
||||||
|
return redirect(_next or request.referrer or url_for('home'))
|
||||||
|
|
||||||
|
return inner
|
||||||
|
|
||||||
|
|
||||||
def delete_view(model_view):
|
def delete_view(model_view):
|
||||||
def inner(uuid):
|
def inner(uuid):
|
||||||
model = model_view.model
|
model = model_view.model
|
||||||
@ -81,6 +101,12 @@ class ModelView(object):
|
|||||||
self.model_name = model.__name__.lower()
|
self.model_name = model.__name__.lower()
|
||||||
self.model_name_pl = p.plural(self.model_name)
|
self.model_name_pl = p.plural(self.model_name)
|
||||||
|
|
||||||
|
def register_create(self, list_template):
|
||||||
|
url = '/{}/create'.format(self.model_name_pl)
|
||||||
|
self.app.add_url_rule(url, methods=["GET", "POST"],
|
||||||
|
endpoint='create_{}'.format(self.model_name),
|
||||||
|
view_func=create_view(self, list_template))
|
||||||
|
|
||||||
def register_list(self, list_template):
|
def register_list(self, list_template):
|
||||||
url = '/{}'.format(self.model_name_pl)
|
url = '/{}'.format(self.model_name_pl)
|
||||||
self.app.add_url_rule(url,
|
self.app.add_url_rule(url,
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
|
Babel==2.8.0
|
||||||
click==7.1.1
|
click==7.1.1
|
||||||
filelock==3.0.12
|
filelock==3.0.12
|
||||||
Flask==1.1.1
|
Flask==1.1.1
|
||||||
|
Flask-Babel==1.0.0
|
||||||
Flask-SQLAlchemy==2.4.1
|
Flask-SQLAlchemy==2.4.1
|
||||||
Flask-Table==0.5.0
|
Flask-Table==0.5.0
|
||||||
|
importlib-metadata==1.5.2
|
||||||
inflect==4.1.0
|
inflect==4.1.0
|
||||||
itsdangerous==1.1.0
|
itsdangerous==1.1.0
|
||||||
Jinja2==2.11.1
|
Jinja2==2.11.1
|
||||||
MarkupSafe==1.1.1
|
MarkupSafe==1.1.1
|
||||||
pathtools==0.1.2
|
pathtools==0.1.2
|
||||||
pkg-resources==0.0.0
|
pytz==2019.3
|
||||||
|
six==1.14.0
|
||||||
SQLAlchemy==1.3.15
|
SQLAlchemy==1.3.15
|
||||||
|
SQLAlchemy-Utils==0.36.3
|
||||||
watchdog==0.10.2
|
watchdog==0.10.2
|
||||||
Werkzeug==1.0.0
|
Werkzeug==1.0.0
|
||||||
|
zipp==3.1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user