<commit_before>from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied, ValidationError
from django.core.urlresolvers import reverse, reverse_lazy
from django.forms import forms
from django.http import JsonResponse
from django.shortcuts import render, get_object_or_404
from django.utils.translation import ugettext as _

# Create your views here.
from django.utils.decorators import method_decorator
from django.views.generic import View, TemplateView, FormView, ListView, DetailView
from Portal.models import CharacterAttribute, TypeValue, Game
from PortalRaid.forms import CharacterForm, CharactersRaidForm
from PortalRaid.models import Realm, CharacterModel, OutRaid, Raid


class RaidListView(ListView):
    model = OutRaid

    @method_decorator(login_required)
    def dispatch(self, request, *args, **kwargs):
        return super(RaidListView, self).dispatch(request, *args, **kwargs)

    def get_raids(self):
        game_choices = {}
        for game in Game.objects.all():
            choices = {}
            for raid in Raid.objects.all().distinct('name'):
                choices[raid.name] = [i for i in Raid.objects.filter(name=raid.name)]
            game_choices[game.name] =  choices
        print game_choices
        return game_choices

    def get_queryset(self):
        import datetime
        queryset = self.model.objects.filter(start_date__gte=datetime.datetime.today() - datetime.timedelta(minutes=30))
        return queryset


class RaidDetailView(DetailView):
    model = OutRaid
    context_object_name = 'raid'<commit_msg>remove distinct for mysql<commit_after>from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied, ValidationError
from django.core.urlresolvers import reverse, reverse_lazy
from django.forms import forms
from django.http import JsonResponse
from django.shortcuts import render, get_object_or_404
from django.utils.translation import ugettext as _

# Create your views here.
from django.utils.decorators import method_decorator
from django.views.generic import View, TemplateView, FormView, ListView, DetailView
from Portal.models import CharacterAttribute, TypeValue, Game
from PortalRaid.forms import CharacterForm, CharactersRaidForm
from PortalRaid.models import Realm, CharacterModel, OutRaid, Raid


class RaidListView(ListView):
    model = OutRaid

    @method_decorator(login_required)
    def dispatch(self, request, *args, **kwargs):
        return super(RaidListView, self).dispatch(request, *args, **kwargs)

    def get_raids(self):
        game_choices = {}
        for game in Game.objects.all():
            choices = {}
            for raid in Raid.objects.all():
                if raid.name not in choices:
                    choices[raid.name] = [i for i in Raid.objects.filter(name=raid.name)]
            game_choices[game.name] =  choices
        print game_choices
        return game_choices

    def get_queryset(self):
        import datetime
        queryset = self.model.objects.filter(start_date__gte=datetime.datetime.today() - datetime.timedelta(minutes=30))
        return queryset


class RaidDetailView(DetailView):
    model = OutRaid
    context_object_name = 'raid'
{'fraction_non_alphanumeric': 0.07864137086903304, 'fraction_numerical': 0.0030599755201958386, 'mean_word_length': 3.842962962962963, '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': '3993742', 'n_tokens_mistral': 932, 'n_tokens_neox': 902, 'n_words': 247}