<commit_before>from django.conf import settings
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.db import transaction
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView
from formtools.wizard.views import SessionWizardView

from pretix.base.models import Event, EventPermission, OrganizerPermission
from pretix.control.forms.event import (
    EventWizardBasicsForm, EventWizardCopyForm, EventWizardFoundationForm,
)


class EventList(ListView):
    model = Event
    context_object_name = 'events'
    paginate_by = 30
    template_name = 'pretixcontrol/events/index.html'

    def get_queryset(self):
        return Event.objects.filter(
            permitted__id__exact=self.request.user.pk
        ).select_related("organizer").prefetch_related(
            "setting_objects", "organizer__setting_objects"
        )


def condition_copy(wizard):
    return EventPermission.objects.filter(
        user=wizard.request.user, can_change_settings=True, can_change_items=True
    ).exists()


class EventWizard(SessionWizardView):
    form_list = [
        ('foundation', EventWizardFoundationForm),
        ('basics', EventWizardBasicsForm),
        ('copy', EventWizardCopyForm),
    ]
    templates = {
        'foundation': 'pretixcontrol/events/create_foundation.html',
        'basics': 'pretixcontrol/events/create_basics.html',
        'copy': 'pretixcontrol/events/create_copy.html',
    }
    condition_dict = {<commit_msg>Show all events to superuser<commit_after>from django.conf import settings
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.db import transaction
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView
from formtools.wizard.views import SessionWizardView

from pretix.base.models import Event, EventPermission, OrganizerPermission
from pretix.control.forms.event import (
    EventWizardBasicsForm, EventWizardCopyForm, EventWizardFoundationForm,
)


class EventList(ListView):
    model = Event
    context_object_name = 'events'
    paginate_by = 30
    template_name = 'pretixcontrol/events/index.html'

    def get_queryset(self):
        if self.request.user.is_superuser:
            return Event.objects.all().select_related("organizer").prefetch_related(
                "setting_objects", "organizer__setting_objects"
            )
        else:
            return Event.objects.filter(
                permitted__id__exact=self.request.user.pk
            ).select_related("organizer").prefetch_related(
                "setting_objects", "organizer__setting_objects"
            )


def condition_copy(wizard):
    return EventPermission.objects.filter(
        user=wizard.request.user, can_change_settings=True, can_change_items=True
    ).exists()


class EventWizard(SessionWizardView):
    form_list = [
        ('foundation', EventWizardFoundationForm),
        ('basics', EventWizardBasicsForm),
        ('copy', EventWizardCopyForm),
    ]
    templates = {
        'foundation': 'pretixcontrol/events/create_foundation.html',
        'basics': 'pretixcontrol/events/create_basics.html',
        'copy': 'pretixcontrol/events/create_copy.html',
    }
    condition_dict = {
{'fraction_non_alphanumeric': 0.0882440035534498, 'fraction_numerical': 0.0011844832691738228, 'mean_word_length': 3.74438202247191, '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': '3607150', 'n_tokens_mistral': 962, 'n_tokens_neox': 942, 'n_words': 187}