JSON notifications

by roundabout, Thursday, 28 December 2023, 09:13:06 (1703754786), pushed by roundabout, Wednesday, 31 July 2024, 06:54:40 (1722408880)

Author identity: vlad <vlad.muntoiu@gmail.com>

1bb93228c56964c0a0484d0e9fb0ad85e81feb1b

models.py

@@ -219,23 +219,12 @@ with app.app_context():

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                class Notification(db.Model):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    id = db.Column(db.BigInteger, primary_key=True, autoincrement=True)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                message = db.Column(db.UnicodeText)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                repoName = db.Column(db.String(98), nullable=True)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                authorName = db.Column(db.String(32), db.ForeignKey("user.username"), nullable=True)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                timestamp = db.Column(db.DateTime, nullable=False, default=datetime.now)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                link = db.Column(db.String(256), nullable=True)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                author = db.relationship("User", back_populates="generatedNotifications")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                data = db.Column(db.dialects.postgresql.JSONB, nullable=False, default={})
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    notifications = db.relationship("UserNotification", back_populates="notification")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                timestamp = db.Column(db.DateTime, nullable=False, default=datetime.now)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                def __init__(self, message, author, repoLink, link):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    self.message = message
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    self.link = link
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if author is not None:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        self.authorName = author.username
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    self.repoLink = repoLink
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                def __init__(self, json):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    self.data = json
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    def sendTo(self, users, level):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        for user in users:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

templates/notifications.html

@@ -11,7 +11,7 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        <x-vbox>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            {% for notification in notifications %}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                <article class="card">
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <section class="caed-main">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <section class="card-main">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                        {{ notification.notification.author.username }}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    </section>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                </article>