<commit_before>"""

Defines tables and their data sources to be rendered in HTML with django-tables2

"""

import django_tables2 as tables
from oppgavegen.models import Template
from oppgavegen.models import ExtendedUser

class TemplateTable(tables.Table):
    """ Generate a html table with all templates marked valid. """

    dropdownhtml = '<div class="btn-group">' \
                   '<a href="#" class="dropdown-toggle" data-toggle="dropdown">View<b class="caret"></b></a>' \
                   '<ul class="dropdown-menu dropdown-menu-right" role="menu">' \
                   '<li><a href="{% url "task_by_extra" record.id %}">Normal</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "blanks" %}">Fill in the Blanks</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "multiple" %}">Multiple Choice</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "multifill" %}">Multiple Fill-Ins</a></li>' \
                   '</ul>' \
                   '</div>'

    view = tables.TemplateColumn(dropdownhtml, orderable=False)
    content = tables.TemplateColumn('<div class="input_field" style="width:400px;padding:-5px;margin:-5px;">'
                                    '<span class="static-math input_mathquill" style="font-size:1.2em;width:parent;">'
                                    '{{record.question_text_latex}}'
                                    '</span></div>')
    multiple_support = tables.BooleanColumn(verbose_name='MC')
    fill_in_support = tables.BooleanColumn(verbose_name='FI')

    class Meta:
        model = Template
        template = ("bstable.html")
        # attrs = {"class": "paleblue"} # add class="paleblue" (table theme) to <table> tag
        # fields to include in table (displayed in this order)
        fields = ("id", "creator", "topic", "multiple_support", "fill_in_support", "rating")
        sequence = ("id", "content", "creator", "topic", "multiple_support", "fill_in_support", "rating", "view")
        order_by = "-id"


class UserTemplatesTable(tables.Table):
    """Generate a html table with the logged in users own templates, and an action menu."""
    dropdownhtml = '<div class="btn-group">' \
                   '<button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown">' \
                   '<span class="caret"></span>' \
                   '<span class="sr-only">Toggle Dropdown</span>' \
                   '</button>' \
                   '<ul class="dropdown-menu dropdown-menu-right" role="menu">' \
                   '<li><a href="{% url "task_by_extra" record.id %}">Normal</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "blanks" %}">Fill in the Blanks</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "multiple" %}">Multiple Choice</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "multifill" %}">Multiple Fill-Ins</a></li>' \
                   '<li role="presentation" class="divider"></li>' \
                   '<li><a href="{% url "edit_template" record.id %}">Edit</a></li>' \
                   '</ul>' \
                   '</div>'

    action = tables.TemplateColumn(dropdownhtml, orderable=False)
    content = tables.TemplateColumn('<div class="input_field" style="width:400px;padding:-5px;margin:-5px;">'
                                    '<span class="static-math input_mathquill" style="font-size:1.2em;width:parent;">'
                                    '{{record.question_text_latex}}'
                                    '</span></div>')
    multiple_support = tables.BooleanColumn(verbose_name='MC')
    fill_in_support = tables.BooleanColumn(verbose_name='FI')

    class Meta:
        model = Template
        template = ("bstable.html")
        # attrs = {"class": "paleblue"} # add class="paleblue" (table theme) to <table> tag
        # fields to include in table (displayed in this order)
        fields = ("id", "topic", "multiple_support", "fill_in_support", "rating")
        sequence = ("id", "content", "topic", "multiple_support", "fill_in_support", "rating", "action")
        order_by = ("-id")

class UserTable(tables.Table):
    """Generate a table of all users and their current rating."""

    class Meta:
        model = ExtendedUser
        template = ("bstable.html")
        fields = ("id", "user", "rating")
<commit_msg>tables now show template name (further rip to topic)<commit_after>"""

Defines tables and their data sources to be rendered in HTML with django-tables2

"""

import django_tables2 as tables
from oppgavegen.models import Template
from oppgavegen.models import ExtendedUser

class TemplateTable(tables.Table):
    """ Generate a html table with all templates marked valid. """

    dropdownhtml = '<div class="btn-group">' \
                   '<a href="#" class="dropdown-toggle" data-toggle="dropdown">View<b class="caret"></b></a>' \
                   '<ul class="dropdown-menu dropdown-menu-right" role="menu">' \
                   '<li><a href="{% url "task_by_extra" record.id %}">Normal</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "blanks" %}">Fill in the Blanks</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "multiple" %}">Multiple Choice</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "multifill" %}">Multiple Fill-Ins</a></li>' \
                   '</ul>' \
                   '</div>'

    view = tables.TemplateColumn(dropdownhtml, orderable=False)
    content = tables.TemplateColumn('<div class="input_field" style="width:400px;padding:-5px;margin:-5px;">'
                                    '<span class="static-math input_mathquill" style="font-size:1.2em;width:parent;">'
                                    '{{record.question_text_latex}}'
                                    '</span></div>')
    multiple_support = tables.BooleanColumn(verbose_name='MC')
    fill_in_support = tables.BooleanColumn(verbose_name='FI')

    class Meta:
        model = Template
        template = ("bstable.html")
        # attrs = {"class": "paleblue"} # add class="paleblue" (table theme) to <table> tag
        # fields to include in table (displayed in this order)
        fields = ("id", "creator", "name", "multiple_support", "fill_in_support", "rating")
        sequence = ("id", "content", "creator", "name", "multiple_support", "fill_in_support", "rating", "view")
        order_by = "-id"


class UserTemplatesTable(tables.Table):
    """Generate a html table with the logged in users own templates, and an action menu."""
    dropdownhtml = '<div class="btn-group">' \
                   '<button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown">' \
                   '<span class="caret"></span>' \
                   '<span class="sr-only">Toggle Dropdown</span>' \
                   '</button>' \
                   '<ul class="dropdown-menu dropdown-menu-right" role="menu">' \
                   '<li><a href="{% url "task_by_extra" record.id %}">Normal</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "blanks" %}">Fill in the Blanks</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "multiple" %}">Multiple Choice</a></li>' \
                   '<li><a href="{% url "task_by_id_and_type" record.id "multifill" %}">Multiple Fill-Ins</a></li>' \
                   '<li role="presentation" class="divider"></li>' \
                   '<li><a href="{% url "edit_template" record.id %}">Edit</a></li>' \
                   '</ul>' \
                   '</div>'

    action = tables.TemplateColumn(dropdownhtml, orderable=False)
    content = tables.TemplateColumn('<div class="input_field" style="width:400px;padding:-5px;margin:-5px;">'
                                    '<span class="static-math input_mathquill" style="font-size:1.2em;width:parent;">'
                                    '{{record.question_text_latex}}'
                                    '</span></div>')
    multiple_support = tables.BooleanColumn(verbose_name='MC')
    fill_in_support = tables.BooleanColumn(verbose_name='FI')

    class Meta:
        model = Template
        template = ("bstable.html")
        # attrs = {"class": "paleblue"} # add class="paleblue" (table theme) to <table> tag
        # fields to include in table (displayed in this order)
        fields = ("id", "name", "multiple_support", "fill_in_support", "rating")
        sequence = ("id", "content", "name", "multiple_support", "fill_in_support", "rating", "action")
        order_by = ("-id")

class UserTable(tables.Table):
    """Generate a table of all users and their current rating."""

    class Meta:
        model = ExtendedUser
        template = ("bstable.html")
        fields = ("id", "user", "rating")

{'fraction_non_alphanumeric': 0.16612849348624875, 'fraction_numerical': 0.0035630776082841552, 'mean_word_length': 2.4453394706559264, 'pattern_counts': {'":': 4, '<': 135, '<?xml version=': 0, '>': 135, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5355080', 'n_tokens_mistral': 2668, 'n_tokens_neox': 2579, 'n_words': 614}