customizing repo from template

main
lza_menace 3 years ago
parent ba660d7239
commit 600c3429c2

@ -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

@ -1,4 +1,4 @@
from myapp.factory import create_app
from xmrbackers.factory import create_app
app = create_app()

@ -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:

@ -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

@ -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

@ -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)

@ -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

@ -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

@ -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)

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Loading…
Cancel
Save