<commit_before># django imports
import datetime
from django_cradmin import crapp
from django.utils.translation import ugettext_lazy as _

# devilry imports
from devilry.devilry_group.views import cradmin_feedbackfeed_base
from devilry.devilry_group import models

# crispy forms
from crispy_forms import layout


class ExaminerFeedbackFeedView(cradmin_feedbackfeed_base.FeedbackFeedBaseView):
    """
    TODO: Document!
    """
    def _get_comments_for_group(self, group):
        return models.GroupComment.objects.filter(
            feedback_set__group=group
        )

    def get_context_data(self, **kwargs):
        context = super(ExaminerFeedbackFeedView, self).get_context_data(**kwargs)
        context['devilry_ui_role'] = 'examiner'
        return context

    def get_buttons(self):
        return [layout.Submit('examiner_add_comment_for_examiners',
                           _('Add comment for examiners'),
                           css_class='btn btn-primary'),
                    layout.Submit('examiner_add_public_comment',
                           _('Add public comment'),
                           css_class='btn btn-primary'),
                    layout.Submit('examiner_add_comment_to_feedback_draft',
                           _('Add to feedback'),
                           css_class='btn btn-primary')
                    ]

    def save_object(self, form, commit=True):
        object = super(ExaminerFeedbackFeedView, self).save_object(form)
        object.user_role = 'examiner'

        if form.data.get('examiner_add_comment_for_examiners'):
            object.instant_publish = True
            object.visible_for_students = False
        elif form.data.get('examiner_add_public_comment'):
            object.instant_publish = True
            object.visible_for_students = True
        elif form.data.get('examiner_add_comment_to_feedback_draft'):
            object.instant_publish = False
            object.visible_for_students = False


        if commit:
            if self._convert_temporary_files_to_comment_files(form, object) or len(object.text) > 0:
                object.save()
            # object.save()
            # self._convert_temporary_files_to_comment_files(form, object)


class App(crapp.App):
    appurls = [
        crapp.Url(<commit_msg>devilry_group/views/feedbackfeed_examiner.py: Added visibility set.<commit_after># django imports
import datetime

from django.utils import timezone
from django_cradmin import crapp
from django.utils.translation import ugettext_lazy as _

# devilry imports
from devilry.devilry_group.views import cradmin_feedbackfeed_base
from devilry.devilry_group import models

# crispy forms
from crispy_forms import layout


class ExaminerFeedbackFeedView(cradmin_feedbackfeed_base.FeedbackFeedBaseView):
    """
    TODO: Document!
    """
    def _get_comments_for_group(self, group):
        return models.GroupComment.objects.filter(
            feedback_set__group=group
        )

    def get_context_data(self, **kwargs):
        context = super(ExaminerFeedbackFeedView, self).get_context_data(**kwargs)
        context['devilry_ui_role'] = 'examiner'
        return context

    def get_buttons(self):
        return [layout.Submit('examiner_add_comment_for_examiners',
                           _('Add comment for examiners'),
                           css_class='btn btn-primary'),
                    layout.Submit('examiner_add_public_comment',
                           _('Add public comment'),
                           css_class='btn btn-primary'),
                    layout.Submit('examiner_add_comment_to_feedback_draft',
                           _('Add to feedback'),
                           css_class='btn btn-primary')
                    ]

    def save_object(self, form, commit=True):
        object = super(ExaminerFeedbackFeedView, self).save_object(form)
        object.user_role = 'examiner'

        if form.data.get('examiner_add_comment_for_examiners'):
            object.visibility = models.GroupComment.VISIBILITY_VISIBLE_TO_EXAMINER_AND_ADMINS
            object.published_datetime = timezone.now()
        elif form.data.get('examiner_add_public_comment'):
            object.visibility = models.GroupComment.VISIBILITY_VISIBLE_TO_EVERYONE
            object.published_datetime = timezone.now()
        elif form.data.get('examiner_add_comment_to_feedback_draft'):
            object.visibility = models.GroupComment.VISIBILITY_VISIBLE_TO_EXAMINER_AND_ADMINS


        if commit:
            if self._convert_temporary_files_to_comment_files(form, object) or len(object.text) > 0:
                object.save()
            # object.save()
            # self._convert_temporary_files_to_comment_files(form, object)


class App(crapp.App):
    appurls = [
        crapp.Url(
{'fraction_non_alphanumeric': 0.08101371001246364, 'fraction_numerical': 0.0004154549231408392, 'mean_word_length': 2.530058651026393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2397831', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1348, 'n_words': 234}