コード例 #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.WIKI, values, old_record, record)
            manage_try_add_with_diff = lambda column, op: ManageLog.add_by_post_changed(
                self,
                column,
                op,
                POST_TYPES.WIKI,
                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'])

            manage_try_add('ref', MOP.WIKI_REF_CHANGE)  # 管理日志:链接编辑
            manage_try_add('state', MOP.POST_STATE_CHANGE)  # 管理日志:改变状态
            manage_try_add('visible', MOP.POST_VISIBLE_CHANGE)  # 管理日志:改变可见度

            if config.SEARCH_ENABLE:
                run_in_thread(esdb.es_update_wiki, record['id'])
コード例 #2
0
ファイル: topic.py プロジェクト: feitianyiren/Icarus
    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'])