|
|
@ -1,22 +1,17 @@
|
|
|
|
from datetime import datetime
|
|
|
|
from datetime import datetime
|
|
|
|
from uuid import uuid4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import peewee as pw
|
|
|
|
import peewee as pw
|
|
|
|
from peewee import PostgresqlDatabase, SQL, ForeignKeyField
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from xmrbackers import config
|
|
|
|
from xmrbackers import config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db = PostgresqlDatabase(
|
|
|
|
db = pw.PostgresqlDatabase(
|
|
|
|
config.DB_NAME,
|
|
|
|
config.DB_NAME,
|
|
|
|
user=config.DB_USER,
|
|
|
|
user=config.DB_USER,
|
|
|
|
password=config.DB_PASS,
|
|
|
|
password=config.DB_PASS,
|
|
|
|
host=config.DB_HOST,
|
|
|
|
host=config.DB_HOST,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def rand_id():
|
|
|
|
|
|
|
|
return uuid4().hex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Creator(pw.Model):
|
|
|
|
class Creator(pw.Model):
|
|
|
|
id = pw.AutoField()
|
|
|
|
id = pw.AutoField()
|
|
|
@ -43,3 +38,45 @@ class Backer(pw.Model):
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
class Meta:
|
|
|
|
database = db
|
|
|
|
database = db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SubscriptionMeta(pw.Model):
|
|
|
|
|
|
|
|
id = pw.AutoField()
|
|
|
|
|
|
|
|
create_date = pw.DateTimeField(default=datetime.now)
|
|
|
|
|
|
|
|
creator = pw.ForeignKeyField(Creator)
|
|
|
|
|
|
|
|
atomic_xmr = pw.BigIntegerField()
|
|
|
|
|
|
|
|
number_hours = pw.IntegerField()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_end_date(self) -> datetime:
|
|
|
|
|
|
|
|
# some timedelta shiz
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
database = db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Subscription(pw.Model):
|
|
|
|
|
|
|
|
id = pw.AutoField()
|
|
|
|
|
|
|
|
subscribe_date = pw.DateTimeField(default=datetime.now)
|
|
|
|
|
|
|
|
active = pw.BooleanField(default=True)
|
|
|
|
|
|
|
|
creator = pw.ForeignKeyField(Creator)
|
|
|
|
|
|
|
|
backer = pw.ForeignKeyField(Backer)
|
|
|
|
|
|
|
|
meta = pw.ForeignKeyField(SubscriptionMeta)
|
|
|
|
|
|
|
|
xmr_address = pw.CharField(unique=True)
|
|
|
|
|
|
|
|
xmr_acct_idx = pw.BigIntegerField(unique=True) # in case it gets many subscribers
|
|
|
|
|
|
|
|
xmr_addr_idx = pw.BigIntegerField(unique=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
database = db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TextPost(pw.Model):
|
|
|
|
|
|
|
|
id = pw.AutoField()
|
|
|
|
|
|
|
|
post_date = pw.DateTimeField(default=datetime.now)
|
|
|
|
|
|
|
|
hidden = pw.BooleanField(default=False)
|
|
|
|
|
|
|
|
content = pw.TextField()
|
|
|
|
|
|
|
|
title = pw.CharField()
|
|
|
|
|
|
|
|
last_edit_date = pw.DateTimeField(default=datetime.now)
|
|
|
|
|
|
|
|
creator = pw.ForeignKeyField(Creator)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
database = db
|
|
|
|