示例#1
0
def _get_user_query_from_model(
    user_query_model: user_models.UserQueryModel
) -> user_query_domain.UserQuery:
    """Transform user query model to domain object.

    Args:
        user_query_model: UserQueryModel. The model to be converted.

    Returns:
        UserQuery. User query domain object.
    """
    attributes = {
        predicate['backend_attr']: getattr(user_query_model,
                                           predicate['backend_attr'])
        for predicate in constants.EMAIL_DASHBOARD_PREDICATE_DEFINITION
    }
    user_query_params = user_query_domain.UserQueryParams(**attributes)

    return user_query_domain.UserQuery(
        user_query_model.id,
        user_query_params,
        user_query_model.submitter_id,
        user_query_model.query_status,
        user_query_model.user_ids,
        user_query_model.sent_email_model_id,
        user_query_model.created_on,
        user_query_model.deleted,
    )
def _get_user_query_from_model(user_query_model):
    """Transform user query model to domain object.

    Args:
        user_query_model: UserQueryModel. The model to be converted.

    Returns:
        UserQuery. User query domain object.
    """
    user_query_params = user_query_domain.UserQueryParams(
        user_query_model.inactive_in_last_n_days,
        user_query_model.has_not_logged_in_for_n_days,
        user_query_model.created_at_least_n_exps,
        user_query_model.created_fewer_than_n_exps,
        user_query_model.edited_at_least_n_exps,
        user_query_model.edited_fewer_than_n_exps)
    return user_query_domain.UserQuery(
        user_query_model.id,
        user_query_params,
        user_query_model.submitter_id,
        user_query_model.query_status,
        user_query_model.user_ids,
        user_query_model.sent_email_model_id,
        user_query_model.created_on,
        user_query_model.deleted,
    )
示例#3
0
 def setUp(self):
     super(UserQueryTests, self).setUp()
     self.signup(self.ADMIN_EMAIL, self.ADMIN_USERNAME)
     self.user_id = self.get_user_id_from_email(self.ADMIN_EMAIL)
     self.user_query_params = user_query_domain.UserQueryParams(
         inactive_in_last_n_days=20),
     self.user_query = user_query_domain.UserQuery(
         query_id='user_query_id',
         query_params=self.user_query_params,
         submitter_id=self.user_id,
         query_status=feconf.USER_QUERY_STATUS_PROCESSING,
         user_ids=[],
         sent_email_model_id=None,
         created_on=datetime.datetime.utcnow(),
     )
     self.user_query.validate()