コード例 #1
0
ファイル: models.py プロジェクト: minamorl/everything
 def __init__(self, body="", voted_users=[], created_at=None, modified_at=None, author=None, parent_thread=None, id=None):
     self.body = body
     self.created_at = created_at or DatetimeProxy(datetime.now())
     self.modified_at = modified_at
     self.voted_users = voted_users
     self.author = PersistentProxy(author)
     self.parent_thread = PersistentProxy(parent_thread)
     self.id = id
コード例 #2
0
ファイル: models.py プロジェクト: minamorl/everything
class Comment(PersistentData):

    body = Column()
    created_at = Column()
    modified_at = Column()
    voted_users = Column()
    author = Column()
    parent_thread = Column()
    id = Column()

    def __init__(self, body="", voted_users=[], created_at=None, modified_at=None, author=None, parent_thread=None, id=None):
        self.body = body
        self.created_at = created_at or DatetimeProxy(datetime.now())
        self.modified_at = modified_at
        self.voted_users = voted_users
        self.author = PersistentProxy(author)
        self.parent_thread = PersistentProxy(parent_thread)
        self.id = id

    def modify_body(self, body):
        self.body = body
        self.modified_at = DatetimeProxy(datetime.now())

    def vote_count(self):
        return len(self.voted_users)

    def receive_vote_from(self, user):
        self.voted_users.append(user)
        return self.voted_users

    def get_parent_thread(self):
        return self.parent_thread.retrive(Thread, persistent)

    def get_author(self):
        author_id = self.author
        author = None
        if self.author is not None:
            author = persistent.load(User, author_id)
        return author