suchwow/suchwow/models.py

51 lines
1.2 KiB
Python
Raw Normal View History

2020-07-15 09:18:13 +01:00
from peewee import *
from datetime import datetime
from suchwow import config
2020-07-15 09:18:13 +01:00
2020-08-10 07:59:45 +01:00
db = SqliteDatabase(f"{config.DATA_FOLDER}/db/sqlite.db")
2020-07-15 09:18:13 +01:00
2020-07-28 21:31:07 +01:00
class Post(Model):
2020-07-15 09:18:13 +01:00
id = AutoField()
title = CharField()
text = CharField()
2020-07-28 21:31:07 +01:00
# submitter = ForeignKeyField(Profile, field=Profile.username)
2020-07-15 09:18:13 +01:00
submitter = CharField()
image_name = CharField()
2020-07-28 21:31:07 +01:00
readonly = BooleanField(default=False)
hidden = BooleanField(default=False)
account_index = IntegerField()
address_index = IntegerField()
timestamp = DateTimeField(default=datetime.now)
class Meta:
database = db
class Profile(Model):
id = AutoField()
username = CharField()
address = CharField()
2020-08-10 07:59:45 +01:00
notifications = IntegerField(default=0)
2020-07-28 21:31:07 +01:00
class Meta:
database = db
class Comment(Model):
id = AutoField()
comment = TextField()
2020-08-10 07:59:45 +01:00
commenter = ForeignKeyField(Profile)
post = ForeignKeyField(Post)
2020-07-28 21:31:07 +01:00
timestamp = DateTimeField(default=datetime.now)
class Meta:
database = db
class Notification(Model):
type = CharField()
message = TextField()
2020-08-10 07:59:45 +01:00
username = ForeignKeyField(Profile)
2020-07-15 09:18:13 +01:00
timestamp = DateTimeField(default=datetime.now)
class Meta:
database = db