<commit_before>from django.utils.translation import ugettext as _
from achilles import blocks, tables

import nazs

register = blocks.Library('core')


@register.block(template_name='web/core/welcome.html')
def home():
    return {'version': nazs.__version__}


@register.block(template_name='web/core/apply_button.html')
def apply_button():
    return {'active': nazs.changed()}


@register.block('modules')
class Modules(tables.Table):

    id_field = 'name'

    # Module name
    name = tables.Column(verbose_name=_('Module'))

    # Module status
    status = tables.MergeColumn(
        verbose_name=_('Status'),
        columns=(
            ('install', tables.ActionColumn(verbose_name=_('Install'),
                                            action='core:install_module',
                                            visible=lambda m: not m.installed)),

            ('enable', tables.ActionColumn(verbose_name=_('Enable'),
                                           action='core:enable_module',
                                           visible=lambda m: m.installed and
                                           not m.enabled)),

            ('disable', tables.ActionColumn(verbose_name=_('Disable'),
                                            action='core:disable_module',
                                            visible=lambda m: m.installed and
                                            m.enabled)),
        )
    )

    def objects(self):
        return nazs.modules()

    def get_object(self, name):
        for module in nazs.modules():
            if module.name == name:
                return module

        raise KeyError('Module %s not found' % name)<commit_msg>Add proper css classes to action buttons<commit_after>from django.utils.translation import ugettext as _
from achilles import blocks, tables

import nazs

register = blocks.Library('core')


@register.block(template_name='web/core/welcome.html')
def home():
    return {'version': nazs.__version__}


@register.block(template_name='web/core/apply_button.html')
def apply_button():
    return {'active': nazs.changed()}


@register.block('modules')
class Modules(tables.Table):

    id_field = 'name'

    # Module name
    name = tables.Column(verbose_name=_('Module'))

    # Module status
    status = tables.MergeColumn(
        verbose_name=_('Status'),
        columns=(
            ('install', tables.ActionColumn(verbose_name=_('Install'),
                                            action='core:install_module',
                                            classes='btn btn-sm btn-primary',
                                            visible=lambda m: not m.installed)),

            ('enable', tables.ActionColumn(verbose_name=_('Enable'),
                                           action='core:enable_module',
                                           classes='btn btn-sm btn-success',
                                           visible=lambda m: m.installed and
                                           not m.enabled)),

            ('disable', tables.ActionColumn(verbose_name=_('Disable'),
                                            action='core:disable_module',
                                            classes='btn btn-sm btn-danger',
                                            visible=lambda m: m.installed and
                                            m.enabled)),
        )
    )

    def objects(self):
        return nazs.modules()

    def get_object(self, name):
        for module in nazs.modules():
            if module.name == name:
                return module

        raise KeyError('Module %s not found' % name)
{'fraction_non_alphanumeric': 0.10578240613866813, 'fraction_numerical': 0.0, 'mean_word_length': 1.5400139178844816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5251079', 'n_tokens_mistral': 837, 'n_tokens_neox': 824, 'n_words': 188}