commit c8d4d9a660203d7716c87e9b9cbe3afb46cd2fd2 Author: root Date: Mon Oct 5 17:49:46 2020 +0100 first go about diff --git a/app.db b/app.db new file mode 100644 index 0000000..e7cfd28 Binary files /dev/null and b/app.db differ diff --git a/app.py b/app.py new file mode 100644 index 0000000..e52ca72 --- /dev/null +++ b/app.py @@ -0,0 +1,136 @@ +from flask import Flask, \ +render_template as Render,\ +redirect as Redirect, \ +url_for as MethodUri, \ +abort as Abort + +from flask_sqlalchemy import SQLAlchemy as DBM +from enum import Enum +from time import sleep + +# Init +app=Flask(__name__) +app.config['SQLALCHEMY_DATABASE_URI']="sqlite:///app.db" +DB=DBM(app) + +#Enums +class WorkState(Enum): + OTHER = 0 + IDEA = 1 + CONFIRMED = 2 + PAID = 3 + INPROGRESS = 4 + FINISHED = 5 +class TxProcessor(Enum): + OTHER = 0 + PAYPAL = 1 +class TxType(Enum): + OTHER = 0 + NORMAL = 1 + YCH = 2 + YCHAUCTION = 3 +class Currency(Enum): + OTHER = 0 + GBP = 1 + USD = 2 + EUR = 3 + CAD = 4 +class LinkType(Enum): + OTHER = 0 + WIPSKETCH = 1 + WIPLINES = 2 + WIPCOLOUR = 3 + WIPSHADING = 4 + WIPOTHER = 5 + DELIVERABLE = 6 + FINAL = 7 + +#Database stuff +class Artist(DB.Model): + artist_id = DB.Column(DB.Integer, primary_key=True, nullable=False, unique=True) + name = DB.Column(DB.String, nullable=False) + social_twitter = DB.Column(DB.String) + social_telegram = DB.Column(DB.String) + social_mastodon = DB.Column(DB.String) + social_furaffinity = DB.Column(DB.String) + social_weasyl = DB.Column(DB.String) + social_inkbunny = DB.Column(DB.String) + social_sofurry = DB.Column(DB.String) + social_furrynetwork = DB.Column(DB.String) +class Work(DB.Model): + work_id = DB.Column(DB.Integer, primary_key=True, nullable=False, unique=True) + artist_id = DB.Column(DB.Integer, DB.ForeignKey('artist.artist_id'), nullable=False) + state = DB.Column(DB.Enum(WorkState), nullable=False) + purchase_type = DB.Column(DB.Enum(TxType),nullable=False) + work_desc = DB.Column(DB.String) + date_proposed = DB.Column(DB.DateTime) + date_accepted = DB.Column(DB.DateTime) + date_paid = DB.Column(DB.DateTime) + date_inprogress = DB.Column(DB.DateTime) + date_completed = DB.Column(DB.DateTime) +class WorkLink(DB.Model): + link_id = DB.Column(DB.Integer, primary_key=True, nullable=False, unique=True) + work_id = DB.Column(DB.Integer, DB.ForeignKey('work.work_id'), nullable=False) + linktype = DB.Column(DB.Enum(LinkType), nullable=False) + descr = DB.Column(DB.String, nullable=False) + uri = DB.Column(DB.String, nullable=False) + datetime = DB.Column(DB.DateTime, nullable=False) +class Transaction(DB.Model): + transaction_id = DB.Column(DB.Integer, primary_key=True, nullable=False, unique=True) + artist_id = DB.Column(DB.Integer, DB.ForeignKey('artist.artist_id'), nullable=False) + work_id = DB.Column(DB.Integer, DB.ForeignKey('work.work_id'), nullable=False) + processor = DB.Column(DB.Enum(TxProcessor), nullable=False) + processor_txid = DB.Column(DB.String, unique=True, nullable=False) + currency = DB.Column(DB.Enum(Currency), nullable=False) + amount = DB.Column(DB.Float, nullable=False) + datetime = DB.Column(DB.DateTime, nullable=False) + + +#Debugging stuff +def RecreateDB(): + DB.drop_all() + DB.create_all() +def PopulateTestData(): + RecreateDB() + tArtist=Artist(name="test artist 1") + DB.session.add(tArtist) + DB.session.commit() + tWork=Work(artist_id=tArtist.artist_id, + state=WorkState.FINISHED, purchase_type=TxType.NORMAL) + tWorkTwo=Work(artist_id=tArtist.artist_id, + state=WorkState.INPROGRESS, purchase_type=TxType.YCHAUCTION) + DB.session.add_all((tWork, tWorkTwo)) + DB.session.commit() + +#Routes +@app.route('/') +def index(): + _idea=Work.query.filter_by(state=WorkState.IDEA).join(Artist) + _conf=Work.query.filter( + (Work.state==WorkState.CONFIRMED) | + (Work.state==WorkState.PAID)).join(Artist) + _inp=Work.query.filter_by(state=WorkState.INPROGRESS).join(Artist) + _cmp=Work.query.filter_by(state=WorkState.FINISHED).join(Artist) + + return Render("index.html.j2", ideas=_idea, cnfpaid=_conf, inprog=_inp, done=_cmp) + +@app.route('/list/') +def list(listname=None): + _p=Work.query.filter_by(state=WorkState.FINISHED) + return Render("list.html.j2", workslist=listname, works=_p.all()) + +@app.route('/add') +def add(): return Render("add.html.j2") + +@app.route('/update', methods=['POST']) +def update(): return Redirect(MethodUri('index')) + +@app.route('/work/') +def view_work(id=None): return True + +@app.route('/artist/') +def view_artist(id=None): + _a=Artist.query.filter_by(artist_id=id).first() + _w=Work.query.filter_by(artist_id=id).all() + _t=Transaction.query.filter_by(artist_id=id).all() + return Render("artist.html.j2", ainfo=_a, works=_w, txes=_t) diff --git a/plan b/plan new file mode 100644 index 0000000..a2a5d6a --- /dev/null +++ b/plan @@ -0,0 +1,4 @@ +pup.cloud Commissions +components +- web frontend (Flask) +- storage (SQLite, PG, Maria) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b0896c7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +Flask~=1.1.2 +Flask-SQLAlchemy~=2.4.4 +Jinja2~=2.11.2 \ No newline at end of file diff --git a/templates/base.html.j2 b/templates/base.html.j2 new file mode 100644 index 0000000..932e9a9 --- /dev/null +++ b/templates/base.html.j2 @@ -0,0 +1,87 @@ + + + + + + + + + + + + p.c Commissions :: {% block title %}{% endblock %} + + {% block head_more %}{% endblock %} + + + {% include "navigation-bar.html.j2" %} + {% block page_body %}{% endblock %} + + \ No newline at end of file diff --git a/templates/index.html.j2 b/templates/index.html.j2 new file mode 100644 index 0000000..4d1d94e --- /dev/null +++ b/templates/index.html.j2 @@ -0,0 +1,48 @@ +{% extends 'base.html.j2' %} + +{% block title %}Home{% endblock %} +{% block head_more %} +{% endblock %} +{% block page_body %} +
+
+
+
+
Ideas
+ {% for work in ideas %} +
+
{{ work.work_desc }}
+
status {{ work.state.name|title }} and artist {{ work.artist.name }}
+
+ {% endfor %} +
+
+
Confirmed/Paid
+ {% for work in cnfpaid %} +
+
{{ work.work_desc }}
+
status {{ work.state.name|title }} and artist {{ work.artist.name }}
+
+ {% endfor %} +
+
+
In-Progress
+ {% for work in inprog %} +
+
{{ work.work_desc }}
+
status {{ work.state.name|title }} and artist {{ work.artist.name }}
+
+ {% endfor %} +
+
+
Completed
+ {% for work in done %} +
+
{{ work.work_desc }}
+
status {{ work.state.name|title }} and artist {{ work.artist.name }}
+
+ {% endfor %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/navigation-bar.html.j2 b/templates/navigation-bar.html.j2 new file mode 100644 index 0000000..ab18270 --- /dev/null +++ b/templates/navigation-bar.html.j2 @@ -0,0 +1,15 @@ +{% block nav %} + +{% endblock %} \ No newline at end of file