def clean(self, *args, **kwargs):
super(InitialPeriodLimitingForm, self).clean(*args, **kwargs)
post_count = self._author.post_set.count()
if post_count < utils.get_config('initial_account_period_total'):
window_start = timezone.now() - utils.get_config(
'initial_account_period_width')
posts_in_window = (self._author
.post_set
.order_by('-created')
.filter(created__gte=window_start)
.count())
if posts_in_window >= utils.get_config(
'initial_account_period_limit'):
raise ValidationError(
('You\'ve made too many posts on a new account. This '
'control will be removed once your account is better '
'established.'),
code='FLOOD_CONTROL')
评论列表
文章目录