<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

# Django imports
from django.http import HttpResponseRedirect

# Devilry imports
from devilry.devilry_qualifiesforexam.views import plugin_mixin
from devilry.devilry_qualifiesforexam.views.plugin_base_views import base_multiselect_view
from devilry.apps.core import models as core_models
from devilry.devilry_qualifiesforexam_plugin_approved import resultscollector


class PluginForm(base_multiselect_view.SelectedQualificationForm):
    qualification_modelclass = core_models.Assignment
    invalid_qualification_item_message = 'Invalid qualification items was selected.'

    def __init__(self, *args, **kwargs):
        selectable_qualification_items_queryset = kwargs.pop('selectable_items_queryset')
        super(PluginForm, self).__init__(*args, **kwargs)
        self.fields['selected_items'].queryset = selectable_qualification_items_queryset


class PluginSelectAssignmentsView(base_multiselect_view.QualificationItemListView, plugin_mixin.PluginMixin):
    model = core_models.Assignment
    plugintypeid = 'devilry_qualifiesforexam_plugin_approved.plugin_select_assignments'

    def get(self, request, *args, **kwargs):
        return super(PluginSelectAssignmentsView, self).get(request, *args, **kwargs)

    def get_queryset_for_role(self, role):
        queryset = super(PluginSelectAssignmentsView, self).get_queryset_for_role(role)
        queryset = queryset.filter(parentnode__id=role.id)
        return queryset

    def get_form_class(self):
        return PluginForm

    def get_initially_selected_queryset(self):
        """
        Select all assignments that must be approved by default.
        The user can then deselect desired assignments.

        Returns:
            QuerySet: Assignments for the role.
        """
        return self.get_queryset_for_role(self.request.cradmin_role)

    def form_valid(self, form):
        # Collect qualifying Assignment IDs
        qualifying_assignmentids = [item.id for item in form.cleaned_data['selected_items']]<commit_msg>devilry_qualifiesforexam_plugin_approved: Added approved plugin.<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

# Django imports
from django.http import HttpResponseRedirect

# Devilry imports
from devilry.devilry_qualifiesforexam.views.plugin_base_views import base_multiselect_view
from devilry.apps.core import models as core_models
from devilry.devilry_qualifiesforexam_plugin_approved import resultscollector


class PluginForm(base_multiselect_view.SelectedQualificationForm):
    qualification_modelclass = core_models.Assignment
    invalid_qualification_item_message = 'Invalid qualification items was selected.'

    def __init__(self, *args, **kwargs):
        selectable_qualification_items_queryset = kwargs.pop('selectable_items_queryset')
        super(PluginForm, self).__init__(*args, **kwargs)
        self.fields['selected_items'].queryset = selectable_qualification_items_queryset


class PluginSelectAssignmentsView(base_multiselect_view.QualificationItemListView):
    model = core_models.Assignment
    plugintypeid = 'devilry_qualifiesforexam_plugin_approved.plugin_select_assignments'

    def get(self, request, *args, **kwargs):
        return super(PluginSelectAssignmentsView, self).get(request, *args, **kwargs)

    def get_queryset_for_role(self, role):
        queryset = super(PluginSelectAssignmentsView, self).get_queryset_for_role(role)
        queryset = queryset.filter(parentnode__id=role.id)
        return queryset

    def get_form_class(self):
        return PluginForm

    def get_initially_selected_queryset(self):
        """
        Select all assignments that must be approved by default.
        The user can then deselect desired assignments.

        Returns:
            QuerySet: Assignments for the role.
        """
        return self.get_queryset_for_role(self.request.cradmin_role)

    def form_valid(self, form):
        # Collect qualifying Assignment IDs
        qualifying_assignmentids = [item.id for item in form.cleaned_data['selected_items']]
{'fraction_non_alphanumeric': 0.07179238418627214, 'fraction_numerical': 0.00048508367693427115, 'mean_word_length': 4.610884353741497, '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': '1892965', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1159, 'n_words': 245}