示例#1
0
    def requires_update(self):
        """
        Check if update should be recomputed.
        """
        conversation = self.conversation
        if self.cluster_status == ClusterStatus.PENDING_DATA:
            rule = rules.get_rule('ej_clusters.conversation_has_sufficient_data')
            if not rule.test(conversation):
                log.info(f'[clusters] {conversation}: not enough data to start clusterization')
                return False
        elif self.cluster_status == ClusterStatus.DISABLED:
            return False

        rule = rules.get_rule('ej_clusters.must_update_clusters')
        return rule.test(conversation)
示例#2
0
def board_list(request):
    user = request.user
    rule = rules.get_rule('ej_boards.can_create_board')
    return {
        'boards': user.boards.all(),
        'can_create_board': rule.test(user),
    }
示例#3
0
def requires_update(self):
    """
    Check if update should be recomputed.
    """
    conversation = self.conversation
    if self.cluster_status == ClusterStatus.PENDING_DATA:
        rule = rules.get_rule("ej.conversation_can_start_clusterization")
        if not rule.test(self):
            log.info(
                f"[clusters] {conversation}: not enough data to start clusterization"
            )
            return False
    elif self.cluster_status == ClusterStatus.DISABLED:
        return False

    rule = rules.get_rule("ej.conversation_must_update_clusters")
    return rule.test(conversation)
示例#4
0
 def normalize_username(self, username):
     if not username:
         msg = _('username is empty')
         raise ValidationError({'username': msg})
     if '@' in username:
         msg = _('username cannot have the "@: character')
         raise ValidationError({'username': msg})
     rule = rules.get_rule('auth.valid_username')
     if not rule.test(username):
         msg = _('invalid username: {username}').format(username=username)
         raise ValidationError({'username': msg})
     return username
示例#5
0
def create(request):
    user = request.user
    rule = rules.get_rule('ej_boards.can_create_board')
    if rule.test(user):
        raise Http404

    form_class = BoardForm
    if request.method == 'POST':
        form = form_class(request.POST)
        if form.is_valid():
            board = form.save(commit=False)
            board.owner = user
            board.save()

            return redirect(board.get_absolute_url())
    else:
        form = form_class()

    return {
        'content_title': _('Create board'),
        'form': form,
    }