| 3 | |
| 4 | |
| 5 | class DiscussionComment(Base): |
| 6 | """ |
| 7 | |
| 8 | |
| 9 | """ |
| 10 | __tablename__ = 'discussion_comment' |
| 11 | |
| 12 | id = Column(Integer, primary_key = True) |
| 13 | |
| 14 | user_id = Column(Integer, ForeignKey('userbase.id')) |
| 15 | user = relationship("User") |
| 16 | |
| 17 | project_id = Column(Integer, ForeignKey('project.id')) |
| 18 | project = relationship("Project", foreign_keys = [project_id]) |
| 19 | |
| 20 | discussion_id = Column(Integer, ForeignKey('discussion.id')) |
| 21 | discussion = relationship("Discussion", foreign_keys = [discussion_id]) |
| 22 | |
| 23 | # Markdown format? |
| 24 | content = Column(String()) |
| 25 | |
| 26 | member_created_id = Column(Integer, ForeignKey('member.id')) |
| 27 | member_created = relationship("Member", foreign_keys = [member_created_id]) |
| 28 | |
| 29 | member_updated_id = Column(Integer, ForeignKey('member.id')) |
| 30 | member_updated = relationship("Member", foreign_keys = [member_updated_id]) |
| 31 | |
| 32 | time_created = Column(DateTime, default = datetime.datetime.utcnow) |
| 33 | time_updated = Column(DateTime, onupdate = datetime.datetime.utcnow) |
| 34 | |
| 35 | # Add reaction? |
| 36 | @staticmethod |
| 37 | def update( |
| 38 | session: object, |
| 39 | comment_id: int = None, |
| 40 | member: object = None, |
| 41 | content: str = None, |
| 42 | ): |
| 43 | comment = DiscussionComment.get_by_id(session, id = comment_id) |
| 44 | comment.content = content |
| 45 | comment.member_updated = member |
| 46 | comment.time_updated = datetime.datetime.utcnow() |
| 47 | session.add(comment) |
| 48 | return comment |
| 49 | |
| 50 | @staticmethod |
| 51 | def list( |
| 52 | session: object, |
| 53 | project_id: int = None, |
| 54 | discussion_id: int = None, |
| 55 | ordering: str = 'asc', |
| 56 | ): |
| 57 | """ |
| 58 | List the comments based on the given dicussion and project_id. |
| 59 | :param session: |
| 60 | :param project_id: |
| 61 | :param discussion_id: |
| 62 | :param ordering: Can be any of ['asc', 'desc']. Sets the ordering of the result by the created time. |
no outgoing calls
no test coverage detected