Beispiel #1
0
    def after_update(self, raw_post: Dict, values: SQLValuesToWrite, old_records: List[DataRecord], records: List[DataRecord]):
        for old_record, record in zip(old_records, records):
            manage_try_add = lambda column, op: ManageLog.add_by_post_changed(
                self, column, op, POST_TYPES.TOPIC, values, old_record, record
            )
            manage_try_add_with_diff = lambda column, op: ManageLog.add_by_post_changed(
                self, column, op, POST_TYPES.TOPIC, values, old_record, record, diff_func=diff
            )

            title_changed = manage_try_add('title', MOP.POST_TITLE_CHANGE)  # 管理日志:标题编辑
            content_changed = manage_try_add_with_diff('content', MOP.POST_CONTENT_CHANGE)  # 管理日志:正文编辑

            if title_changed or content_changed:
                post_stats_do_edit(record['id'], record['user_id'])
                Topic.update(edit_count=Topic.edit_count + 1).where(Topic.id == record['id']).execute()

            manage_try_add('state', MOP.POST_STATE_CHANGE)  # 管理日志:状态修改
            manage_try_add('visible', MOP.POST_VISIBLE_CHANGE)  # 管理日志:改变可见度
            manage_try_add('awesome', MOP.TOPIC_AWESOME_CHANGE)  # 管理日志:设置精华
            manage_try_add('sticky_weight', MOP.TOPIC_STICKY_WEIGHT_CHANGE)  # 管理日志:置顶权重
            manage_try_add('weight', MOP.TOPIC_WEIGHT_CHANGE)  # 管理日志:修改权重

            # 管理日志:移动板块
            if manage_try_add('board_id', MOP.TOPIC_BOARD_MOVE):
                post_stats_topic_move(old_record['board_id'], record['board_id'], record['id'])
Beispiel #2
0
    def after_update(self, raw_post: Dict, values: SQLValuesToWrite,
                     old_records: List[DataRecord], records: List[DataRecord]):
        for old_record, record in zip(old_records, records):
            if 'content' in values:
                # 管理日志:正文编辑
                ManageLog.new(self.current_user, self.current_role,
                              POST_TYPES.TOPIC, record['id'],
                              record['user_id'], MOP.TOPIC_CONTENT_CHANGE,
                              None)
                Topic.update(edit_count=Topic.edit_count +
                             1).where(Topic.id == record['id']).execute()

            if 'title' in values:
                # 管理日志:标题编辑
                ManageLog.new(self.current_user, self.current_role,
                              POST_TYPES.TOPIC, record['id'],
                              record['user_id'], MOP.TOPIC_TITLE_CHANGE, None)

            # 管理日志:改变状态
            ManageLog.add_by_post_changed(self, 'state', MOP.POST_STATE_CHANGE,
                                          POST_TYPES.TOPIC, values, old_record,
                                          record)

            # 管理日志:改变可见度
            ManageLog.add_by_post_changed(self, 'visible',
                                          MOP.POST_VISIBLE_CHANGE,
                                          POST_TYPES.TOPIC, values, old_record,
                                          record)

            # 管理日志:移动板块
            if ManageLog.add_by_post_changed(self, 'board_id',
                                             MOP.TOPIC_BOARD_MOVE,
                                             POST_TYPES.TOPIC, values,
                                             old_record, record):
                statistic_move_topic(old_record['board_id'],
                                     record['board_id'], record['id'])

            # 管理日志:设置精华
            ManageLog.add_by_post_changed(self, 'awesome',
                                          MOP.TOPIC_AWESOME_CHANGE,
                                          POST_TYPES.TOPIC, values, old_record,
                                          record)

            # 管理日志:置顶权重
            ManageLog.add_by_post_changed(self, 'sticky_weight',
                                          MOP.TOPIC_STICKY_WEIGHT_CHANGE,
                                          POST_TYPES.TOPIC, values, old_record,
                                          record)

            # 管理日志:修改权重
            ManageLog.add_by_post_changed(self, 'weight',
                                          MOP.TOPIC_WEIGHT_CHANGE,
                                          POST_TYPES.TOPIC, values, old_record,
                                          record)