forked from lza_menace/suchwow
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.0 KiB
79 lines
2.0 KiB
from peewee import *
|
|
from datetime import datetime
|
|
from suchwow import config
|
|
|
|
|
|
db = SqliteDatabase(f"{config.DATA_FOLDER}/db/sqlite.db")
|
|
|
|
class Post(Model):
|
|
id = AutoField()
|
|
title = CharField()
|
|
text = CharField()
|
|
submitter = CharField()
|
|
image_name = CharField()
|
|
readonly = BooleanField(default=False)
|
|
hidden = BooleanField(default=False)
|
|
account_index = IntegerField()
|
|
address_index = IntegerField()
|
|
timestamp = DateTimeField(default=datetime.now)
|
|
reddit_url = CharField(null=True)
|
|
to_reddit = BooleanField(default=False)
|
|
to_discord = BooleanField(default=False)
|
|
approved = BooleanField(default=False)
|
|
|
|
def show(self):
|
|
return {
|
|
'id': self.id,
|
|
'title': self.title,
|
|
'text': self.text,
|
|
'submitter': self.submitter,
|
|
'image_name': self.image_name,
|
|
'readonly': self.readonly,
|
|
'hidden': self.hidden,
|
|
'account_index': self.account_index,
|
|
'address_index': self.address_index,
|
|
'timestamp': self.timestamp,
|
|
'reddit_url': self.reddit_url,
|
|
'to_reddit': self.to_reddit,
|
|
'to_discord': self.to_discord,
|
|
'approved': self.approved,
|
|
}
|
|
|
|
class Meta:
|
|
database = db
|
|
|
|
class Moderator(Model):
|
|
id = AutoField()
|
|
username = CharField(unique=True)
|
|
|
|
class Meta:
|
|
database = db
|
|
|
|
class Profile(Model):
|
|
id = AutoField()
|
|
username = CharField()
|
|
address = CharField()
|
|
notifications = IntegerField(default=0)
|
|
|
|
class Meta:
|
|
database = db
|
|
|
|
class Comment(Model):
|
|
id = AutoField()
|
|
comment = TextField()
|
|
commenter = ForeignKeyField(Profile)
|
|
post = ForeignKeyField(Post)
|
|
timestamp = DateTimeField(default=datetime.now)
|
|
|
|
class Meta:
|
|
database = db
|
|
|
|
class Notification(Model):
|
|
type = CharField()
|
|
message = TextField()
|
|
username = ForeignKeyField(Profile)
|
|
timestamp = DateTimeField(default=datetime.now)
|
|
|
|
class Meta:
|
|
database = db
|