Exemple #1
0
def chain_class(context, chain):
    num_important, num_important_my = parse_chain_comments_cache(
            chain, context['user'])
    if num_important_my > 0:
        return 'cchain-important-my-ctasks'
    elif num_important > 0:
        return 'cchain-important'
    elif chain.t_is_verified:
        return 'cchain-verified'
    return ''
Exemple #2
0
def chain_ctask_comments_info(context, chain):
    num_important, num_important_my = parse_chain_comments_cache(
            chain, context['user'])
    if num_important:
        first = ungettext("%d important", "%d important", num_important) \
                % num_important
        if num_important_my:
            second = ungettext("%d my task", "%d my tasks", num_important_my) \
                    % num_important_my
            return mark_safe(u"{} <b>({})</b>".format(first, second))
        return first
    return ""
Exemple #3
0
    def test_update_chain_comments_cache(self):
        ctasks = []
        ctasks.append(create_ctask(self.admin, self.competition, self.chain,
                "42", 1, "nothing important here"))
        ctasks.append(create_ctask(self.admin, self.competition, self.chain,
                "42", 1,
                "first nothing important\n"
                "IMPORTANT: but then something important"))
        ctasks.append(create_ctask(self.admin, self.competition, self.chain,
                "42", 1,
                "again first nothing important\n"
                "IMPORTANT: bla bla\n"
                "bla bla"))
        ctasks.append(create_ctask(self.alice, self.competition, self.chain,
                "42", 1,
                "nothing important"))
        ctasks.append(create_ctask(self.alice, self.competition, self.chain,
                "42", 1,
                "nothing important\n"
                "IMPORTANT: bla bla\n"
                "bla bla"))
        update_chain_comments_cache(self.chain, ctasks)
        num_important, num_important_my = parse_chain_comments_cache(
            self.chain, self.admin)
        self.assertEqual(num_important, 3)
        self.assertEqual(num_important_my, 2)

        num_important, num_important_my = parse_chain_comments_cache(
            self.chain, self.alice)
        self.assertEqual(num_important, 3)
        self.assertEqual(num_important_my, 1)

        num_important, num_important_my = parse_chain_comments_cache(
            self.chain, self.bob)
        self.assertEqual(num_important, 3)
        self.assertEqual(num_important_my, 0)