Esempio n. 1
0
def convert_to_guestpost(sender, **kwds):
    """Upon user deletion, convert belonging entries to guest entries"""

    user = kwds['user']
    anon_user = AnonymousUser()
    anon_user.display_name = user.display_name

    touched_topics = set()
    touched_forums = set()
    posts =  Post.query.filter_by(author_id=user.id)

    for post in posts:
        topic = post.topic
        forum = topic.forum
        post.author = anon_user
        touched_forums.add(forum)
        touched_topics.add(topic)

    db.commit()
    for topic in touched_topics:
        topic.refresh()
    db.commit()
    for forum in touched_forums:
        forum.refresh()
    db.commit()
Esempio n. 2
0
 def _get_author(self):
     if self.author_id == None:
         author = AnonymousUser()
         author.display_name = self.author_str
         return author
     else:
         return User.query.get(self.author_id)