Add email template table
This commit is contained in:
19
models.py
19
models.py
@@ -295,4 +295,21 @@ class Notif(db.Model):
|
||||
sender = db.relationship('User', foreign_keys=[sender_id], backref='sent_notifications')
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Notif {self.notif_type} for User {self.user_id} at {self.timestamp}>'
|
||||
return f'<Notif {self.notif_type} for User {self.user_id} at {self.timestamp}>'
|
||||
|
||||
class EmailTemplate(db.Model):
|
||||
__tablename__ = 'email_templates'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(100), nullable=False)
|
||||
subject = db.Column(db.String(200), nullable=False)
|
||||
body = db.Column(db.Text, nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
created_by = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
|
||||
is_active = db.Column(db.Boolean, default=True)
|
||||
|
||||
# Relationships
|
||||
creator = db.relationship('User', backref='created_email_templates', foreign_keys=[created_by])
|
||||
|
||||
def __repr__(self):
|
||||
return f'<EmailTemplate {self.name}>'
|
||||
Reference in New Issue
Block a user