<commit_before>from django.db.models import Q
from projects.models import Project, Story, StoryVersion

class ProjectQuerySetMixin(object):
    def get_queryset(self):
        if self.request.user.is_superuser:
            return Project.objects.all()
        else:
            return Project.objects.filter(coordinator=self.request.user)

class StoryQuerySetBaseMixin(object):
    def user_in_story_filter(self, story_objects, user):
        return story_objects.filter(Q(reporters__in=[user]) |
                                       Q(researchers__in=[user]) |
                                    Q(editors__in=[user]) |
                                    Q(copy_editors__in=[user]) |
                                    Q(fact_checkers__in=[user]) |
                                    Q(translators__in=[user]) |
                                    Q(artists__in=[user]) |
                                    Q(project__coordinator=user))

class StoryQuerySetMixin(StoryQuerySetBaseMixin):
    def get_queryset(self):
        if self.request.user.is_superuser:
            stories = Story.objects.all()
        else:
            stories = self.user_in_story_filter(Story.objects.all(), self.request.user)

        return stories

class StoryListQuerySetMixin(StoryQuerySetMixin):
    def get_queryset(self, project_id):
        stories = super(StoryListQuerySetMixin, self).get_queryset()
        return stories.filter(project__id=project_id)

class StoryVersionListQuerySetMixin(StoryQuerySetBaseMixin):
    def get_queryset(self, story_id):
        if self.request.user.is_superuser:
            return StoryVersion.objects.all()

        try:
            story = Story.objects.filter(id=story_id)
        except Story.DoesNotExist:
            return []

        print story
        story = self.user_in_story_filter(story, self.request.user)
        print story
        if story.count() == 0:
            print "0 count, woops!"
            return []<commit_msg>removal of print statements and formatting<commit_after>from django.db.models import Q
from projects.models import Project, Story, StoryVersion

class ProjectQuerySetMixin(object):
    def get_queryset(self):
        if self.request.user.is_superuser:
            return Project.objects.all()
        else:
            return Project.objects.filter(coordinator=self.request.user)

class StoryQuerySetBaseMixin(object):
    def user_in_story_filter(self, story_objects, user):
        return story_objects.filter(Q(reporters__in=[user]) |
                                    Q(researchers__in=[user]) |
                                    Q(editors__in=[user]) |
                                    Q(copy_editors__in=[user]) |
                                    Q(fact_checkers__in=[user]) |
                                    Q(translators__in=[user]) |
                                    Q(artists__in=[user]) |
                                    Q(project__coordinator=user))

class StoryQuerySetMixin(StoryQuerySetBaseMixin):
    def get_queryset(self):
        if self.request.user.is_superuser:
            stories = Story.objects.all()
        else:
            stories = self.user_in_story_filter(Story.objects.all(), self.request.user)

        return stories

class StoryListQuerySetMixin(StoryQuerySetMixin):
    def get_queryset(self, project_id):
        stories = super(StoryListQuerySetMixin, self).get_queryset()
        return stories.filter(project__id=project_id)

class StoryVersionListQuerySetMixin(StoryQuerySetBaseMixin):
    def get_queryset(self, story_id):
        if self.request.user.is_superuser:
            return StoryVersion.objects.all()

        try:
            story = Story.objects.filter(id=story_id)
        except Story.DoesNotExist:
            return []

        story = self.user_in_story_filter(story, self.request.user)

        if story.count() == 0:
            return []
{'fraction_non_alphanumeric': 0.08934531450577664, 'fraction_numerical': 0.0007702182284980744, 'mean_word_length': 2.0628930817610063, '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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3173357', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1058, 'n_words': 177}