Toloka documentation

RestrictionV2

toloka.client.actions.RestrictionV2 | Source code

RestrictionV2(
    self,
    *,
    scope: Union[UserRestriction.Scope, str, None] = None,
    duration: Optional[int] = None,
    duration_unit: Union[DurationUnit, str, None] = None,
    private_comment: Optional[str] = None
)

Restricts Toloker's access to projects or pools.

Parameters Description

Parameters Type Description
scope Union[UserRestriction.Scope, str, None]
  • POOL — A Toloker can't access the pool if the action is applied.
  • PROJECT — A Toloker can't access the entire project containing the pool.
  • ALL_PROJECTS — A Toloker can't access any requester's project.
duration Optional[int]

The duration of the blocking period measured in duration_unit.

duration_unit Union[DurationUnit, str, None]
  • MINUTES;
  • HOURS;
  • DAYS;
  • PERMANENT — blocking is permanent. In this case the duration is ignored and may be omitted.
private_comment Optional[str]

A private comment. It is visible only to the requester.

Examples:

The following quality control rule blocks access to the project for 10 days, if a Toloker answers too fast.

new_pool = toloka.pool.Pool(....)
new_pool.quality_control.add_action(
    collector=toloka.collectors.AssignmentSubmitTime(history_size=5, fast_submit_threshold_seconds=20),
    conditions=[toloka.conditions.FastSubmittedCount > 1],
    action=toloka.actions.RestrictionV2(
        scope='PROJECT',
        duration=10,
        duration_unit='DAYS',
        private_comment='Fast responses',
    )
)