added lead field to shout, new table event (#71)

* added lead field to shout, new table event

* repurposed unused notifications table
This commit is contained in:
Igor Lobanov
2023-08-06 22:01:40 +02:00
committed by GitHub
parent 1fc6178b97
commit b4e14cce93
8 changed files with 13 additions and 40 deletions

View File

@@ -1,13 +1,13 @@
from sqlalchemy import Column, String, JSON as JSONType
from datetime import datetime
from sqlalchemy import Column, String, JSON, ForeignKey, DateTime, Boolean
from base.orm import Base
class Notification(Base):
__tablename__ = "notification"
kind = Column(String, unique=True, primary_key=True)
template = Column(String, nullable=False)
variables = Column(JSONType, nullable=True) # [ <var1>, .. ]
# looks like frontend code
user = Column(ForeignKey("user.id"), index=True)
createdAt = Column(DateTime, nullable=False, default=datetime.now, index=True)
seen = Column(Boolean, nullable=False, default=False, index=True)
type = Column(String, nullable=False)
data = Column(JSON, nullable=True)

View File

@@ -53,6 +53,7 @@ class Shout(Base):
slug = Column(String, unique=True)
cover = Column(String, nullable=True, comment="Cover image url")
lead = Column(String, nullable=True)
body = Column(String, nullable=False, comment="Body")
title = Column(String, nullable=True)
subtitle = Column(String, nullable=True)

View File

@@ -3,19 +3,10 @@ from datetime import datetime
from sqlalchemy import JSON as JSONType
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
from base.orm import Base, local_session
from orm.rbac import Role
class UserNotifications(Base):
__tablename__ = "user_notifications"
# id auto
user = Column(Integer, ForeignKey("user.id"))
kind = Column(String, ForeignKey("notification.kind"))
values = Column(JSONType, nullable=True) # [ <var1>, .. ]
class UserRating(Base):
__tablename__ = "user_rating"
@@ -72,7 +63,6 @@ class User(Base):
deletedAt = Column(DateTime, nullable=True, comment="Deleted at")
links = Column(JSONType, nullable=True, comment="Links")
oauth = Column(String, nullable=True)
notifications = relationship(lambda: UserNotifications)
ratings = relationship(UserRating, foreign_keys=UserRating.user)
roles = relationship(lambda: Role, secondary=UserRole.__tablename__)
oid = Column(String, nullable=True)