|
@@ -1,14 +1,16 @@
|
|
|
# Dispatches data to hasher and adds to database tables
|
|
# Dispatches data to hasher and adds to database tables
|
|
|
|
|
|
|
|
import sqlalchemy
|
|
import sqlalchemy
|
|
|
|
|
+import os
|
|
|
|
|
+
|
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
|
from flask_login import current_user
|
|
from flask_login import current_user
|
|
|
|
|
|
|
|
from .models import Hashchain, Art, List, TX
|
|
from .models import Hashchain, Art, List, TX
|
|
|
from . import db
|
|
from . import db
|
|
|
|
|
|
|
|
-from . import clean_file as cf
|
|
|
|
|
-from . import hasher as hsh
|
|
|
|
|
|
|
+from app.lib import clean_file as cf
|
|
|
|
|
+from app.lib import hasher as hsh
|
|
|
|
|
|
|
|
def mint(designated_fn, art_name, art_desc, min_price, buyout_price, close_date):
|
|
def mint(designated_fn, art_name, art_desc, min_price, buyout_price, close_date):
|
|
|
# gen filehash
|
|
# gen filehash
|
|
@@ -29,7 +31,8 @@ def mint(designated_fn, art_name, art_desc, min_price, buyout_price, close_date)
|
|
|
new_bhash = hsh.append_tx(txhash, prev_bhash)
|
|
new_bhash = hsh.append_tx(txhash, prev_bhash)
|
|
|
new_block = Hashchain(blockhash = new_bhash)
|
|
new_block = Hashchain(blockhash = new_bhash)
|
|
|
db.session.add(new_block)
|
|
db.session.add(new_block)
|
|
|
- # move the file into external secure storage + another local dir (NOT DONE)
|
|
|
|
|
|
|
+ # move the file into external secure storage (NOT DONE)
|
|
|
|
|
+ os.rename(f'{cf.UPLOAD_FOLDER}/{designated_fn}', f'{cf.REPO_FOLDER}/{designated_fn}')
|
|
|
# add to TX table (mint)
|
|
# add to TX table (mint)
|
|
|
new_tx = TX(
|
|
new_tx = TX(
|
|
|
filehash = filehash,
|
|
filehash = filehash,
|
|
@@ -41,7 +44,14 @@ def mint(designated_fn, art_name, art_desc, min_price, buyout_price, close_date)
|
|
|
)
|
|
)
|
|
|
db.session.add(new_tx)
|
|
db.session.add(new_tx)
|
|
|
# add to Art table
|
|
# add to Art table
|
|
|
- new_art = Art(name = art_name, description = art_desc, filehash = filehash)
|
|
|
|
|
|
|
+ new_art = Art(
|
|
|
|
|
+ name = art_name,
|
|
|
|
|
+ description = art_desc,
|
|
|
|
|
+ filehash = filehash,
|
|
|
|
|
+ owner = current_user.id,
|
|
|
|
|
+ creator = current_user.id,
|
|
|
|
|
+ dname = designated_fn
|
|
|
|
|
+ )
|
|
|
db.session.add(new_art)
|
|
db.session.add(new_art)
|
|
|
# add to List table
|
|
# add to List table
|
|
|
new_listing = List(
|
|
new_listing = List(
|