From 600c3429c2c85048882ba62043eb2027a37903c8 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Sun, 27 Jun 2021 00:29:40 -0700 Subject: [PATCH] customizing repo from template --- Makefile | 7 +++- app.py | 2 +- docker-compose.yaml | 4 +- env-example | 6 +-- myapp/models.py | 38 ------------------ {myapp => xmrbackers}/__init__.py | 0 {myapp => xmrbackers}/cli.py | 14 +++---- {myapp => xmrbackers}/config.py | 6 +-- {myapp => xmrbackers}/factory.py | 8 ++-- {myapp => xmrbackers}/filters.py | 0 {myapp => xmrbackers}/forms.py | 0 {myapp => xmrbackers}/library/__init__.py | 0 {myapp => xmrbackers}/library/cache.py | 0 {myapp => xmrbackers}/library/market.py | 0 xmrbackers/models.py | 31 ++++++++++++++ {myapp => xmrbackers}/routes/__init__.py | 0 {myapp => xmrbackers}/routes/api.py | 0 {myapp => xmrbackers}/routes/meta.py | 0 {myapp => xmrbackers}/static/css/main.css | 0 .../static/images/monero-logo.png | Bin {myapp => xmrbackers}/static/js/main.js | 0 .../templates/includes/footer.html | 0 .../templates/includes/head.html | 0 .../templates/includes/header.html | 0 .../templates/includes/scripts.html | 0 {myapp => xmrbackers}/templates/index.html | 0 26 files changed, 56 insertions(+), 60 deletions(-) delete mode 100644 myapp/models.py rename {myapp => xmrbackers}/__init__.py (100%) rename {myapp => xmrbackers}/cli.py (58%) rename {myapp => xmrbackers}/config.py (85%) rename {myapp => xmrbackers}/factory.py (83%) rename {myapp => xmrbackers}/filters.py (100%) rename {myapp => xmrbackers}/forms.py (100%) rename {myapp => xmrbackers}/library/__init__.py (100%) rename {myapp => xmrbackers}/library/cache.py (100%) rename {myapp => xmrbackers}/library/market.py (100%) create mode 100644 xmrbackers/models.py rename {myapp => xmrbackers}/routes/__init__.py (100%) rename {myapp => xmrbackers}/routes/api.py (100%) rename {myapp => xmrbackers}/routes/meta.py (100%) rename {myapp => xmrbackers}/static/css/main.css (100%) rename {myapp => xmrbackers}/static/images/monero-logo.png (100%) rename {myapp => xmrbackers}/static/js/main.js (100%) rename {myapp => xmrbackers}/templates/includes/footer.html (100%) rename {myapp => xmrbackers}/templates/includes/head.html (100%) rename {myapp => xmrbackers}/templates/includes/header.html (100%) rename {myapp => xmrbackers}/templates/includes/scripts.html (100%) rename {myapp => xmrbackers}/templates/index.html (100%) diff --git a/Makefile b/Makefile index 3c403cd..1216a56 100644 --- a/Makefile +++ b/Makefile @@ -13,5 +13,8 @@ setup: ## Establish local environment with dependencies installed up: ## Build and run the required containers by fetching binaries docker-compose -f docker-compose.yaml up -d -shell: ## Start Flask CLI shell - FLASK_APP=app/app.py FLASK_SECRETS=config.py FLASK_DEBUG=0 FLASK_ENV=production .venv/bin/flask shell +shell: ## Start Quart CLI shell + QUART_APP=app.py QUART_SECRETS=config.py QUART_DEBUG=0 QUART_ENV=production .venv/bin/quart shell + +dev: ## Start Quart development web server + QUART_APP=app.py QUART_SECRETS=config.py QUART_DEBUG=0 QUART_ENV=production .venv/bin/quart run diff --git a/app.py b/app.py index 06a21e1..57897b8 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,4 @@ -from myapp.factory import create_app +from xmrbackers.factory import create_app app = create_app() diff --git a/docker-compose.yaml b/docker-compose.yaml index 768e7e3..9f2ff89 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,8 +6,8 @@ services: - 127.0.0.1:5432:5432 environment: POSTGRES_PASSWORD: ${DB_PASS} - POSTGRES_USER: ${DB_USER:-myapp} - POSTGRES_DB: ${DB_NAME:-myapp} + POSTGRES_USER: ${DB_USER:-xmrbackers} + POSTGRES_DB: ${DB_NAME:-xmrbackers} volumes: - ${DATA_DIR:-./data/postgresql}:/var/lib/postgresql/data cache: diff --git a/env-example b/env-example index f8ed753..c90285b 100644 --- a/env-example +++ b/env-example @@ -1,6 +1,6 @@ DB_PASS=xxxxxxxxxxxxxxxxxxx -DB_USER=myapp -DB_NAME=myapp +DB_USER=xmrbackers +DB_NAME=xmrbackers DB_HOST=localhost XMR_WALLET_PATH=/data/xmr-wallet @@ -10,7 +10,7 @@ XMR_WALLET_RPC_PASS=xxxxxxxxxxxxxxxxxxx XMR_WALLET_RPC_ENDPOINT=http://localhost:9090 XMR_DAEMON_URI=http://super.fast.node.xmr.pm:38089 -SITE_NAME=myapp +SITE_NAME=xmrbackers SECRET_KEY=xxxxxxxxxxxxxxxxxxx STATS_TOKEN=xxxxxxxxxxxxxxxxxxxx SERVER_NAME=localhost:5000 diff --git a/myapp/models.py b/myapp/models.py deleted file mode 100644 index f8f5f56..0000000 --- a/myapp/models.py +++ /dev/null @@ -1,38 +0,0 @@ -from datetime import datetime -from uuid import uuid4 - -from sqlalchemy.sql import func - -from myapp.factory import db -from myapp import config - - -def rand_id(): - return uuid4().hex - -class MyThing(db.Model): - __tablename__ = 'swaps' - - # Meta - id = db.Column(db.Integer, primary_key=True) - # id = db.Column(db.String(80), primary_key=True, default=rand_id) # hex based id - date = db.Column(db.DateTime, server_default=func.now()) - my_bool = db.Column(db.Boolean) - my_int = db.Column(db.Integer) - my_str = db.Column(db.String(150)) - completed = db.Column(db.Boolean, default=False) - completed_date = db.Column(db.DateTime, nullable=True) - - def __repr__(self): - return self.id - - def hours_elapsed(self): - now = datetime.utcnow() - if since_completed: - if self.completed_date: - diff = now - self.completed_date - else: - return 0 - else: - diff = now - self.date - return diff.total_seconds() / 60 / 60 diff --git a/myapp/__init__.py b/xmrbackers/__init__.py similarity index 100% rename from myapp/__init__.py rename to xmrbackers/__init__.py diff --git a/myapp/cli.py b/xmrbackers/cli.py similarity index 58% rename from myapp/cli.py rename to xmrbackers/cli.py index 5000486..b088b3b 100644 --- a/myapp/cli.py +++ b/xmrbackers/cli.py @@ -1,11 +1,11 @@ import click from quart import Blueprint, current_app -from myapp.models import MyThing -from myapp.factory import db +from xmrbackers.models import Creator +from xmrbackers.factory import db -bp = Blueprint('filters', 'filters') +bp = Blueprint('cli', 'cli') @bp.cli.command('init') def init(): @@ -15,16 +15,16 @@ def init(): @bp.cli.command('delete') @click.argument('thing_id') def delete(thing_id): - thing = MyThing.query.get(thing_id) + thing = Creator.query.get(thing_id) if thing: db.session.delete(thing) db.session.commit() - click.echo(f'MyThing {thing.id} was deleted') + click.echo(f'Creator {thing.id} was deleted') else: - click.echo('MyThing ID does not exist') + click.echo('Creator ID does not exist') @bp.cli.command('list') def list_things(): - thing = MyThing.query.all() + thing = Creator.query.all() for i in thing: click.echo(i.id) diff --git a/myapp/config.py b/xmrbackers/config.py similarity index 85% rename from myapp/config.py rename to xmrbackers/config.py index 7efc5c0..b2a0c35 100644 --- a/myapp/config.py +++ b/xmrbackers/config.py @@ -6,7 +6,7 @@ from os import getenv load_dotenv() # Site meta -SITE_NAME = getenv('SITE_NAME', 'MyApp') +SITE_NAME = getenv('SITE_NAME', 'xmrbackers') SECRET_KEY = getenv('SECRET_KEY') STATS_TOKEN = getenv('STATS_TOKEN', token_urlsafe(8)) SERVER_NAME = getenv('SERVER_NAME', 'localhost:5000') @@ -21,8 +21,8 @@ XMR_DAEMON_URI = getenv('XMR_DAEMON_URI') # Database DB_HOST = getenv('DB_HOST', 'localhost') DB_PORT = getenv('DB_PORT', 5432) -DB_NAME = getenv('DB_NAME', 'myapp') -DB_USER = getenv('DB_USER', 'myapp') +DB_NAME = getenv('DB_NAME', 'xmrbackers') +DB_USER = getenv('DB_USER', 'xmrbackers') DB_PASS = getenv('DB_PASS') # Redis diff --git a/myapp/factory.py b/xmrbackers/factory.py similarity index 83% rename from myapp/factory.py rename to xmrbackers/factory.py index a7c5a53..df9a439 100644 --- a/myapp/factory.py +++ b/xmrbackers/factory.py @@ -2,7 +2,7 @@ import quart.flask_patch from quart import Quart from flask_sqlalchemy import SQLAlchemy -from myapp import config +from xmrbackers import config db = SQLAlchemy() @@ -26,12 +26,12 @@ def create_app(): @app.before_serving async def startup(): - from myapp.routes import meta, api - from myapp import filters + from xmrbackers.routes import meta, api + from xmrbackers import filters, cli await _setup_db(app) app.register_blueprint(meta.bp) app.register_blueprint(api.bp) app.register_blueprint(filters.bp) - # app.register_blueprint(cli.bp) + app.register_blueprint(cli.bp) return app diff --git a/myapp/filters.py b/xmrbackers/filters.py similarity index 100% rename from myapp/filters.py rename to xmrbackers/filters.py diff --git a/myapp/forms.py b/xmrbackers/forms.py similarity index 100% rename from myapp/forms.py rename to xmrbackers/forms.py diff --git a/myapp/library/__init__.py b/xmrbackers/library/__init__.py similarity index 100% rename from myapp/library/__init__.py rename to xmrbackers/library/__init__.py diff --git a/myapp/library/cache.py b/xmrbackers/library/cache.py similarity index 100% rename from myapp/library/cache.py rename to xmrbackers/library/cache.py diff --git a/myapp/library/market.py b/xmrbackers/library/market.py similarity index 100% rename from myapp/library/market.py rename to xmrbackers/library/market.py diff --git a/xmrbackers/models.py b/xmrbackers/models.py new file mode 100644 index 0000000..4a07113 --- /dev/null +++ b/xmrbackers/models.py @@ -0,0 +1,31 @@ +from datetime import datetime +from uuid import uuid4 + +from sqlalchemy.sql import func + +from xmrbackers.factory import db +from xmrbackers import config + + +def rand_id(): + return uuid4().hex + +class Creator(db.Model): + __tablename__ = 'creators' + + id = db.Column(db.Integer, primary_key=True) + # id = db.Column(db.String(80), primary_key=True, default=rand_id) # hex based id + register_date = db.Column(db.DateTime, server_default=func.now()) + last_login_date = db.Column(db.DateTime, nullable=True) + wallet_address = db.Column(db.String(150)) + password = db.Column(db.String(150)) + email = db.Column(db.String(150)) + handle = db.Column(db.String(150)) + + def __repr__(self): + return self.id + +class Backer(db.Model): + __tablename__ = 'backers' + + id = db.Column(db.Integer, primary_key=True) diff --git a/myapp/routes/__init__.py b/xmrbackers/routes/__init__.py similarity index 100% rename from myapp/routes/__init__.py rename to xmrbackers/routes/__init__.py diff --git a/myapp/routes/api.py b/xmrbackers/routes/api.py similarity index 100% rename from myapp/routes/api.py rename to xmrbackers/routes/api.py diff --git a/myapp/routes/meta.py b/xmrbackers/routes/meta.py similarity index 100% rename from myapp/routes/meta.py rename to xmrbackers/routes/meta.py diff --git a/myapp/static/css/main.css b/xmrbackers/static/css/main.css similarity index 100% rename from myapp/static/css/main.css rename to xmrbackers/static/css/main.css diff --git a/myapp/static/images/monero-logo.png b/xmrbackers/static/images/monero-logo.png similarity index 100% rename from myapp/static/images/monero-logo.png rename to xmrbackers/static/images/monero-logo.png diff --git a/myapp/static/js/main.js b/xmrbackers/static/js/main.js similarity index 100% rename from myapp/static/js/main.js rename to xmrbackers/static/js/main.js diff --git a/myapp/templates/includes/footer.html b/xmrbackers/templates/includes/footer.html similarity index 100% rename from myapp/templates/includes/footer.html rename to xmrbackers/templates/includes/footer.html diff --git a/myapp/templates/includes/head.html b/xmrbackers/templates/includes/head.html similarity index 100% rename from myapp/templates/includes/head.html rename to xmrbackers/templates/includes/head.html diff --git a/myapp/templates/includes/header.html b/xmrbackers/templates/includes/header.html similarity index 100% rename from myapp/templates/includes/header.html rename to xmrbackers/templates/includes/header.html diff --git a/myapp/templates/includes/scripts.html b/xmrbackers/templates/includes/scripts.html similarity index 100% rename from myapp/templates/includes/scripts.html rename to xmrbackers/templates/includes/scripts.html diff --git a/myapp/templates/index.html b/xmrbackers/templates/index.html similarity index 100% rename from myapp/templates/index.html rename to xmrbackers/templates/index.html