Пример #1
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'story_ids', story_models.StoryModel, [item.story_id]),
         base_model_validators.ExternalModelFetcherDetails(
             'exp_ids', exp_models.ExplorationModel, [item.id])
     ]
Пример #2
0
 def _get_external_id_relationships(cls, item):
     field_name_to_external_model_references = [
         base_model_validators.ExternalModelFetcherDetails(
             'message_ids',
             feedback_models.GeneralFeedbackMessageModel,
             ['%s.%s' % (item.id, i) for i in python_utils.RANGE(
                 item.message_count)])
     ]
     if item.original_author_id:
         field_name_to_external_model_references.append(
             base_model_validators.UserSettingsModelFetcherDetails(
                 'author_ids', [item.original_author_id],
                 may_contain_system_ids=False,
                 may_contain_pseudonymous_ids=True
             ))
     if item.has_suggestion:
         field_name_to_external_model_references.append(
             base_model_validators.ExternalModelFetcherDetails(
                 'suggestion_ids', suggestion_models.GeneralSuggestionModel,
                 [item.id]))
     if item.entity_type in prod_validators.TARGET_TYPE_TO_TARGET_MODEL:
         field_name_to_external_model_references.append(
             base_model_validators.ExternalModelFetcherDetails(
                 '%s_ids' % item.entity_type,
                 prod_validators.TARGET_TYPE_TO_TARGET_MODEL[
                     item.entity_type], [item.entity_id]))
     if item.last_nonempty_message_author_id:
         field_name_to_external_model_references.append(
             base_model_validators.UserSettingsModelFetcherDetails(
                 'last_nonempty_message_author_ids',
                 [item.last_nonempty_message_author_id],
                 may_contain_system_ids=True,
                 may_contain_pseudonymous_ids=True
             ))
     return field_name_to_external_model_references
Пример #3
0
 def _get_external_id_relationships(cls, item):
     field_name_to_external_model_references = []
     if user_services.is_user_id_valid(item.author_id):
         field_name_to_external_model_references.append(
             base_model_validators.ExternalModelFetcherDetails(
                 'author_ids',
                 user_models.UserSettingsModel,
                 [item.author_id]
             )
         )
     if item.target_type in TARGET_TYPE_TO_TARGET_MODEL:
         field_name_to_external_model_references.append(
             base_model_validators.ExternalModelFetcherDetails(
                 '%s_ids' % item.target_type,
                 TARGET_TYPE_TO_TARGET_MODEL[item.target_type],
                 [item.target_id]))
     if (
             item.final_reviewer_id and
             user_services.is_user_id_valid(item.final_reviewer_id)
     ):
         field_name_to_external_model_references.append(
             base_model_validators.ExternalModelFetcherDetails(
                 'final_reviewer_ids', user_models.UserSettingsModel,
                 [item.final_reviewer_id]))
     return field_name_to_external_model_references
Пример #4
0
 def _get_external_id_relationships(cls, item):
     snapshot_model_ids = [
         '%s-%d' % (item.id, version)
         for version in python_utils.RANGE(1, item.version + 1)
     ]
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'exploration_commit_log_entry_ids',
             exp_models.ExplorationCommitLogEntryModel, [
                 'exploration-%s-%s' % (item.id, version)
                 for version in python_utils.RANGE(1, item.version + 1)
             ]),
         base_model_validators.ExternalModelFetcherDetails(
             'exp_summary_ids', exp_models.ExpSummaryModel, [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'exploration_rights_ids', exp_models.ExplorationRightsModel,
             [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_metadata_ids',
             exp_models.ExplorationSnapshotMetadataModel,
             snapshot_model_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_content_ids',
             exp_models.ExplorationSnapshotContentModel, snapshot_model_ids)
     ]
Пример #5
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'topic_ids', topic_models.TopicModel, [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'topic_rights_ids', topic_models.TopicRightsModel, [item.id])
     ]
Пример #6
0
    def _get_external_id_relationships(cls, item):
        exploration_ids = []
        collection_ids = []

        try:
            for reference in item.activity_references:
                if reference['type'] == constants.ACTIVITY_TYPE_EXPLORATION:
                    exploration_ids.append(reference['id'])
                elif reference['type'] == constants.ACTIVITY_TYPE_COLLECTION:
                    collection_ids.append(reference['id'])
        except Exception as e:
            cls._add_error(
                base_model_validators.ERROR_CATEGORY_PROPERTY_FETCH_CHECK,
                'Entity id %s: Entity properties cannot be fetched completely '
                'with the error %s' % (item.id, e))
            return []

        return [
            base_model_validators.ExternalModelFetcherDetails(
                'exploration_ids', exp_models.ExplorationModel,
                exploration_ids),
            base_model_validators.ExternalModelFetcherDetails(
                'collection_ids', collection_models.CollectionModel,
                collection_ids)
        ]
Пример #7
0
 def _get_external_id_relationships(cls, item):
     external_id_relationships = [
         base_model_validators.UserSettingsModelFetcherDetails(
             'user_settings_ids', [item.id],
             may_contain_system_ids=False,
             may_contain_pseudonymous_ids=False),
     ]
     if item.parent_user_id is None:
         # Full users (users without a parent) should have a valid auth ID.
         if item.gae_id is not None:
             external_id_relationships.append(
                 base_model_validators.ExternalModelFetcherDetails(
                     'auth_ids', auth_models.UserIdentifiersModel,
                     [item.gae_id]))
         if item.firebase_auth_id is not None:
             external_id_relationships.append(
                 base_model_validators.ExternalModelFetcherDetails(
                     'auth_ids', auth_models.UserIdByFirebaseAuthIdModel,
                     [item.firebase_auth_id]))
     else:
         # Profile users (users with a parent) should have a valid parent ID.
         external_id_relationships.append(
             base_model_validators.UserSettingsModelFetcherDetails(
                 'parent_user_settings_ids', [item.parent_user_id],
                 may_contain_system_ids=False,
                 may_contain_pseudonymous_ids=False))
     return external_id_relationships
Пример #8
0
    def _get_external_id_relationships(cls, item):
        field_name_to_external_model_references = [
            base_model_validators.ExternalModelFetcherDetails(
                'feedback_thread_ids',
                feedback_models.GeneralFeedbackThreadModel, [item.id])
        ]
        if user_services.is_user_id_valid(item.author_id):
            field_name_to_external_model_references.append(
                base_model_validators.ExternalModelFetcherDetails(
                    'author_ids', user_models.UserSettingsModel,
                    [item.author_id]))
        if item.target_type in TARGET_TYPE_TO_TARGET_MODEL:
            field_name_to_external_model_references.append(
                base_model_validators.ExternalModelFetcherDetails(
                    '%s_ids' % item.target_type,
                    TARGET_TYPE_TO_TARGET_MODEL[item.target_type],
                    [item.target_id]))
        if item.final_reviewer_id and user_services.is_user_id_valid(
                item.final_reviewer_id):

            # Bot rejects suggestions when the suggestion's targeted entity gets
            # removed from the topic. The bot doesn't have a UserSettingsModel
            # for their user_id. Exclude external model validation for bot.
            if item.final_reviewer_id != feconf.SUGGESTION_BOT_USER_ID:
                field_name_to_external_model_references.append(
                    base_model_validators.ExternalModelFetcherDetails(
                        'reviewer_ids', user_models.UserSettingsModel,
                        [item.final_reviewer_id]))
        return field_name_to_external_model_references
Пример #9
0
 def _get_external_id_relationships(cls, item):
     snapshot_model_ids = [
         '%s-%d' % (item.id, version)
         for version in python_utils.RANGE(1, item.version + 1)
     ]
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'question_commit_log_entry_ids',
             question_models.QuestionCommitLogEntryModel, [
                 'question-%s-%s' % (item.id, version)
                 for version in python_utils.RANGE(1, item.version + 1)
             ]),
         base_model_validators.ExternalModelFetcherDetails(
             'question_summary_ids', question_models.QuestionSummaryModel,
             [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_metadata_ids',
             question_models.QuestionSnapshotMetadataModel,
             snapshot_model_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_content_ids',
             question_models.QuestionSnapshotContentModel,
             snapshot_model_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'linked_skill_ids', skill_models.SkillModel,
             item.linked_skill_ids)
     ]
Пример #10
0
 def _get_external_id_relationships(cls, item):
     snapshot_model_ids = [
         '%s-%d' % (item.id, version)
         for version in python_utils.RANGE(1, item.version + 1)]
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'collection_ids',
             collection_models.CollectionModel, [item.id]),
         base_model_validators.UserSettingsModelFetcherDetails(
             'owner_user_ids', item.owner_ids,
             may_contain_system_ids=False,
             may_contain_pseudonymous_ids=False),
         base_model_validators.UserSettingsModelFetcherDetails(
             'editor_user_ids', item.editor_ids,
             may_contain_system_ids=False,
             may_contain_pseudonymous_ids=False),
         base_model_validators.UserSettingsModelFetcherDetails(
             'viewer_user_ids', item.viewer_ids,
             may_contain_system_ids=False,
             may_contain_pseudonymous_ids=False),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_metadata_ids',
             collection_models.CollectionRightsSnapshotMetadataModel,
             snapshot_model_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_content_ids',
             collection_models.CollectionRightsSnapshotContentModel,
             snapshot_model_ids)]
Пример #11
0
 def _get_external_id_relationships(cls, item):
     snapshot_model_ids = [
         '%s-%d' % (item.id, version)
         for version in python_utils.RANGE(1, item.version + 1)
     ]
     superseding_skill_ids = []
     if item.superseding_skill_id:
         superseding_skill_ids = [item.superseding_skill_id]
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'skill_commit_log_entry_ids',
             skill_models.SkillCommitLogEntryModel, [
                 'skill-%s-%s' % (item.id, version)
                 for version in python_utils.RANGE(1, item.version + 1)
             ]),
         base_model_validators.ExternalModelFetcherDetails(
             'skill_summary_ids', skill_models.SkillSummaryModel,
             [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'superseding_skill_ids', skill_models.SkillModel,
             superseding_skill_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_metadata_ids',
             skill_models.SkillSnapshotMetadataModel, snapshot_model_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_content_ids', skill_models.SkillSnapshotContentModel,
             snapshot_model_ids)
     ]
Пример #12
0
 def _get_external_id_relationships(cls, item):
     snapshot_model_ids = [
         '%s-%d' % (item.id, version)
         for version in python_utils.RANGE(1, item.version + 1)
     ]
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'story_commit_log_entry_ids',
             story_models.StoryCommitLogEntryModel, [
                 'story-%s-%s' % (item.id, version)
                 for version in python_utils.RANGE(1, item.version + 1)
             ]),
         base_model_validators.ExternalModelFetcherDetails(
             'story_summary_ids', story_models.StorySummaryModel,
             [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_metadata_ids',
             story_models.StorySnapshotMetadataModel, snapshot_model_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_content_ids', story_models.StorySnapshotContentModel,
             snapshot_model_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'exploration_ids', exp_models.ExplorationModel, [
                 node['exploration_id']
                 for node in (item.story_contents['nodes'])
             ])
     ]
Пример #13
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'exploration_ids', exp_models.ExplorationModel, [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'exploration_rights_ids', exp_models.ExplorationRightsModel,
             [item.id]),
         base_model_validators.UserSettingsModelFetcherDetails(
             'owner_user_ids',
             item.owner_ids,
             may_contain_system_ids=False,
             may_contain_pseudonymous_ids=False),
         base_model_validators.UserSettingsModelFetcherDetails(
             'editor_user_ids',
             item.editor_ids,
             may_contain_system_ids=False,
             may_contain_pseudonymous_ids=False),
         base_model_validators.UserSettingsModelFetcherDetails(
             'viewer_user_ids',
             item.viewer_ids,
             may_contain_system_ids=False,
             may_contain_pseudonymous_ids=False),
         base_model_validators.UserSettingsModelFetcherDetails(
             'contributor_user_ids',
             item.contributor_ids,
             may_contain_system_ids=False,
             may_contain_pseudonymous_ids=False)
     ]
Пример #14
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'question_ids', question_models.QuestionModel,
             [item.question_id]),
         base_model_validators.ExternalModelFetcherDetails(
             'skill_ids', skill_models.SkillModel, [item.skill_id])
     ]
Пример #15
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'collection_ids', collection_models.CollectionModel,
             [item.id[:item.id.rfind(base_models.VERSION_DELIMITER)]]),
         base_model_validators.ExternalModelFetcherDetails(
             'committer_ids', user_models.UserSettingsModel,
             [item.committer_id])]
Пример #16
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'user_settings_ids', user_models.UserSettingsModel, [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'sent_email_model_ids', email_models.BulkEmailModel,
             item.sent_email_model_ids)
     ]
Пример #17
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'resolver_ids', user_models.UserSettingsModel,
             [item.resolver_id] if item.resolver_id is not None else []),
         base_model_validators.ExternalModelFetcherDetails(
             'entity_ids', exp_models.ExplorationModel, [item.entity_id])
     ]
Пример #18
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'recipient_id', user_models.UserSettingsModel,
             [item.recipient_id]),
         base_model_validators.ExternalModelFetcherDetails(
             'sender_id', user_models.UserSettingsModel, [item.sender_id])
     ]
Пример #19
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'platform_parameter_ids', config_models.PlatformParameterModel,
             [item.id[:item.id.find('-')]]),
         base_model_validators.ExternalModelFetcherDetails(
             'committer_ids', user_models.UserSettingsModel,
             [item.committer_id])
     ]
Пример #20
0
 def _get_external_id_relationships(cls, item):
     field_name_to_external_model_references = [
         base_model_validators.ExternalModelFetcherDetails(
             'blog_post_summary_model_ids',
             blog_models.BlogPostSummaryModel, [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'blog_post_model_ids', blog_models.BlogPostModel, [item.id])
     ]
     return field_name_to_external_model_references
Пример #21
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'user_settings_ids', user_models.UserSettingsModel,
             [item.user_id]),
         base_model_validators.ExternalModelFetcherDetails(
             'user_auth_details_ids', user_models.UserAuthDetailsModel,
             [item.user_id]),
     ]
Пример #22
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'user_settings_ids', user_models.UserSettingsModel,
             [item.user_id]),
         base_model_validators.ExternalModelFetcherDetails(
             'exploration_ids', exp_models.ExplorationModel,
             [item.exploration_id])
     ]
Пример #23
0
 def _get_external_id_relationships(cls, item):
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'item.id.user_id', user_models.UserSettingsModel,
             [item.id[:item.id.find('.')]]),
         base_model_validators.ExternalModelFetcherDetails(
             'item.id.thread_id',
             feedback_models.GeneralFeedbackThreadModel,
             [item.id[item.id.find('.') + 1:]])
     ]
Пример #24
0
 def _get_external_id_relationships(cls, item):
     external_id_relationships = [
         base_model_validators.ExternalModelFetcherDetails(
             'exploration_ids',
             exp_models.ExplorationModel, [item.exploration_id])]
     if item.id.startswith('rights'):
         external_id_relationships.append(
             base_model_validators.ExternalModelFetcherDetails(
                 'exploration_rights_ids', exp_models.ExplorationRightsModel,
                 [item.exploration_id]))
     return external_id_relationships
Пример #25
0
 def _get_external_id_relationships(cls, item):
     field_name_to_external_model_references = [
         base_model_validators.ExternalModelFetcherDetails(
             'feedback_thread_ids',
             feedback_models.GeneralFeedbackThreadModel, [item.thread_id])
     ]
     if (item.author_id and user_services.is_user_id_valid(item.author_id)):
         field_name_to_external_model_references.append(
             base_model_validators.ExternalModelFetcherDetails(
                 'author_ids', user_models.UserSettingsModel,
                 [item.author_id]))
     return field_name_to_external_model_references
Пример #26
0
    def _get_external_id_relationships(cls, item):
        exp_id = item.exp_id
        exp_version = item.exp_version
        exp_issues_id = (stats_models.ExplorationIssuesModel.get_entity_id(
            exp_id, exp_version))

        return [
            base_model_validators.ExternalModelFetcherDetails(
                'exp_ids', exp_models.ExplorationModel, [item.exp_id]),
            base_model_validators.ExternalModelFetcherDetails(
                'exp_issues_ids', stats_models.ExplorationIssuesModel,
                [exp_issues_id])
        ]
Пример #27
0
 def _get_external_id_relationships(cls, item):
     snapshot_model_ids = [
         '%s-%d' % (item.id, version)
         for version in python_utils.RANGE(1, item.version + 1)]
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_metadata_ids',
             config_models.ConfigPropertySnapshotMetadataModel,
             snapshot_model_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'snapshot_content_ids',
             config_models.ConfigPropertySnapshotContentModel,
             snapshot_model_ids)]
Пример #28
0
 def _get_external_id_relationships(cls, item):
     field_name_to_external_model_references = [
         base_model_validators.ExternalModelFetcherDetails(
             'blog_post_rights_model_ids', blog_models.BlogPostRightsModel,
             [item.id]),
         base_model_validators.ExternalModelFetcherDetails(
             'blog_post_model_ids', blog_models.BlogPostModel, [item.id])
     ]
     field_name_to_external_model_references.append(
         base_model_validators.UserSettingsModelFetcherDetails(
             'author_ids', [item.author_id],
             may_contain_system_ids=True,
             may_contain_pseudonymous_ids=True))
     return field_name_to_external_model_references
Пример #29
0
 def _get_external_id_relationships(cls, item):
     message_ids = []
     user_ids = []
     if '.' in item.id:
         index = item.id.find('.')
         user_ids = [item.id[:index]]
         message_ids = ['%s.%s' % (
             item.id[index + 1:], message_id) for message_id in (
                 item.message_ids_read_by_user)]
     return [
         base_model_validators.ExternalModelFetcherDetails(
             'message_ids',
             feedback_models.GeneralFeedbackMessageModel, message_ids),
         base_model_validators.ExternalModelFetcherDetails(
             'user_ids', user_models.UserSettingsModel, user_ids)]
Пример #30
0
 def _get_external_id_relationships(cls, item):
     external_id_relationships = [
         base_model_validators.ExternalModelFetcherDetails(
             'topic_ids', topic_models.TopicModel, [item.topic_id]),
         base_model_validators.UserSettingsModelFetcherDetails(
             'user_id', [item.user_id],
             may_contain_system_ids=True,
             may_contain_pseudonymous_ids=True)
     ]
     if item.id.startswith('rights'):
         external_id_relationships.append(
             base_model_validators.ExternalModelFetcherDetails(
                 'topic_rights_ids', topic_models.TopicRightsModel,
                 [item.topic_id]))
     return external_id_relationships