<commit_before>from django.template.loader import render_to_string
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _

from devilry.core.models import Node, Subject, Period, Assignment


def list_nodes_generic(request, nodecls, headings, deletemessage,
        help_text=None):
    clsname = nodecls.__name__.lower()
    return render_to_string('devilry/admin/dashboard/list_nodes.django.html', {
            'jsonurl': reverse('admin-autocomplete-%sname' % clsname),
            'createurl': reverse('devilry-admin-create_%s' % clsname),
            'deleteurl': reverse('devilry-admin-delete_many%ss' % clsname),
            'headings': headings,
            'deletemessage': deletemessage,
            'clsname': clsname,
            'help': help_text
        }, context_instance=RequestContext(request))

def list_nodes(request, *args, **kwargs):
    return list_nodes_generic(request, Node,
            headings = ["Node", "Administrators"],
            deletemessage = \
                _('This will delete all selected nodes and all subjects, periods, '\
                'assignments, assignment groups, deliveries and feedbacks within '\
                'them.'),
            help_text = \
                _('A node at the top of the navigation tree. It is a '\
                'generic element used to organize administrators. A '\
                'Node can be organized below another Node, and it can '\
                'only have one parent.'))

def list_subjects(request, *args, **kwargs):
    return list_nodes_generic(request, Subject,
            headings = ["Subject", "Administrators"],
            deletemessage = \
                _('This will delete all selected subjects and all periods, '\
                'assignments, assignment groups, deliveries and feedbacks within '\
                'them.'),
            help_text = \
                _('A subject is a course, seminar, class or something '\
                'else being given regularly. A subject is further '\
                'divided into periods.'))

def list_periods(request, *args, **kwargs):
    return list_nodes_generic(request, Period,
            headings = ["Subject", "Period", "Start time", "Administrators"],
            deletemessage = \
                _('This will delete all selected periods and all '\
                'assignments, assignment groups, deliveries and feedbacks within '\
                'them.'),
            help_text = \
                _('A Period is a limited period of time within a subject, '
                'like "spring 2009", "week 34 2010" or even a single day.'))

def list_assignments(request, *args, **kwargs):
    return list_nodes_generic(request, Assignment,
            headings = ["Assignment",
                    "Publishing time", "Administrators"],
            deletemessage = \
                _('This will delete all selected assignments and all '\
                'assignment groups, deliveries and feedbacks within '\
                'them.'),
            help_text = \
                 _('A assignment within a period.'))<commit_msg>Fixed typo<commit_after>from django.template.loader import render_to_string
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _

from devilry.core.models import Node, Subject, Period, Assignment


def list_nodes_generic(request, nodecls, headings, deletemessage,
        help_text=None):
    clsname = nodecls.__name__.lower()
    return render_to_string('devilry/admin/dashboard/list_nodes.django.html', {
            'jsonurl': reverse('admin-autocomplete-%sname' % clsname),
            'createurl': reverse('devilry-admin-create_%s' % clsname),
            'deleteurl': reverse('devilry-admin-delete_many%ss' % clsname),
            'headings': headings,
            'deletemessage': deletemessage,
            'clsname': clsname,
            'help': help_text
        }, context_instance=RequestContext(request))

def list_nodes(request, *args, **kwargs):
    return list_nodes_generic(request, Node,
            headings = ["Node", "Administrators"],
            deletemessage = \
                _('This will delete all selected nodes and all subjects, periods, '\
                'assignments, assignment groups, deliveries and feedbacks within '\
                'them.'),
            help_text = \
                _('A node at the top of the navigation tree. It is a '\
                'generic element used to organize administrators. A '\
                'Node can be organized below another Node, and it can '\
                'only have one parent.'))

def list_subjects(request, *args, **kwargs):
    return list_nodes_generic(request, Subject,
            headings = ["Subject", "Administrators"],
            deletemessage = \
                _('This will delete all selected subjects and all periods, '\
                'assignments, assignment groups, deliveries and feedbacks within '\
                'them.'),
            help_text = \
                _('A subject is a course, seminar, class or something '\
                'else being given regularly. A subject is further '\
                'divided into periods.'))

def list_periods(request, *args, **kwargs):
    return list_nodes_generic(request, Period,
            headings = ["Subject", "Period", "Start time", "Administrators"],
            deletemessage = \
                _('This will delete all selected periods and all '\
                'assignments, assignment groups, deliveries and feedbacks within '\
                'them.'),
            help_text = \
                _('A Period is a limited period of time within a subject, '
                'like "spring 2009", "week 34 2010" or even a single day.'))

def list_assignments(request, *args, **kwargs):
    return list_nodes_generic(request, Assignment,
            headings = ["Assignment",
                    "Publishing time", "Administrators"],
            deletemessage = \
                _('This will delete all selected assignments and all '\
                'assignment groups, deliveries and feedbacks within '\
                'them.'),
            help_text = \
                 _('An assignment within a period.'))
{'fraction_non_alphanumeric': 0.09838658652325213, 'fraction_numerical': 0.0031635558367605187, 'mean_word_length': 2.180583501006036, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3854146', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1562, 'n_words': 502}