From c8d4d9a660203d7716c87e9b9cbe3afb46cd2fd2 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 5 Oct 2020 17:49:46 +0100 Subject: [PATCH] first go about --- app.db | Bin 0 -> 57344 bytes app.py | 136 +++++++++++++++++++++++++++++++ plan | 4 + requirements.txt | 3 + templates/base.html.j2 | 87 ++++++++++++++++++++ templates/index.html.j2 | 48 +++++++++++ templates/navigation-bar.html.j2 | 15 ++++ 7 files changed, 293 insertions(+) create mode 100644 app.db create mode 100644 app.py create mode 100644 plan create mode 100644 requirements.txt create mode 100644 templates/base.html.j2 create mode 100644 templates/index.html.j2 create mode 100644 templates/navigation-bar.html.j2 diff --git a/app.db b/app.db new file mode 100644 index 0000000000000000000000000000000000000000..e7cfd28bdeef95b7046bd3fbb6fc0127f1413780 GIT binary patch literal 57344 zcmeI)Z*SU090zclG*ClR`Xpj`F!jw7JAdtP(>FX_W^Pa=_`VCN{MX zC3!Y&>!v>2qdx1qnKVs(xc9JEFim@~2fOpX_==Nu+LM-jNe<&X-J8o0bmg3ETBU)ogF8;;u(i-?!b-X>NV%$eX&9Y<9XTd$O4)JhrG! zog#3c3Q|L#!aTt|hQKt1Y zAmgUfb+P5Gdp*8`-Tnq&XuIL=+Uf?|SGl>a6l?lTS#sR5eG)u9Wbd+u)|7hT`Y=m; zH?vY%zx=kdX6+V$)550Asx57iDG_euJoB*cB1%_j%G-Fe4$%%6K?@_O`i zVkgIRqty~)acl=8KPeT$ZR$I@`7_6~P)i8X_*o01n$7!9;gxnR4uEuB41h;^uYX?~ zw72>Avz3l+X#MzcyW8nT5y7|GRyTBGD=tbyb3^Os4>gm|*}P~|H^M+IH(SMGO}l+oy7=wz48W`#g-s2qU^L2oaeuz3B~zYq3}Qyf+Vl zH*&1QAw6~|wbR*#$3aqJAKH(7>nN$6DLS$O>Ww`&r|4knTL%Y@>(JAj(qr2SP7iYm z*p#?Gb=|x=fydhP^Gd>e*QPuovTX_x89}jmT8PQB+;a0)p;-H3<-Ea(w`@gAem;Mh zzolMcNv{4bv47kk009U<00Izz00bZa0SG_<0uXqw1wN1~Qa$MbwF8=bCf|xP`89ri zt)G7!aD}A`OJ$Z6miXrcC6q<2f1Ll%)sUhy5P$##AOHafKmY;|fB*y_0D&0+T>qaTK?VdM z009U<00Izz00bZa0SG`~?gViDKX*fl4nY6{5P$##AOHafKmY;|fB*z$1n~X;84_eb z00Izz00bZa0SG_<0uX=z1m;cv*Z=2kNYNn(KmY;|fB*y_009U<00Izzz>EOS|7S>$ a0Rad=00Izz00bZa0SG_<0uY!xfqww;p;Ej6 literal 0 HcmV?d00001 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