<commit_before>from django.core.urlresolvers import reverse, reverse_lazy
from django.http import HttpResponse, JsonResponse, HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.contrib.auth.models import User
from django.utils.decorators import method_decorator
from django.views.generic import ListView, DetailView, FormView, UpdateView
from braces.views import LoginRequiredMixin, SuperuserRequiredMixin, StaffuserRequiredMixin, SelectRelatedMixin
from django.views.generic.base import View, ContextMixin, TemplateView
from Portal.models import Game, Userprofile, Portal
from django.views.generic import ListView, DetailView, FormView, UpdateView, View, CreateView
from braces.views import LoginRequiredMixin, SuperuserRequiredMixin, StaffuserRequiredMixin, SelectRelatedMixin
from django.views.generic.base import TemplateView
from Forum.models import Post
from Portal.models import Game, Userprofile, CommentNews, CharacterAttribute
from PortalAdmin.forms import UserForm
from SuperPortal.models import GuildSettings


class MenuView(object):

    def get_context_data(self, **kwargs):
        context = super(MenuView, self).get_context_data(**kwargs)
        context['games'] = Game.objects.all()
        return context

# def test_context(template_name):
#     def decorator(function):
#         def additionnal_context(function):
#
#             def wrapper(**kwargs):
#                 TemplateView.template_name = template_name
#                 context = {}
#                 context['games'] = ['toto', 'titi']
#                 return context
#
#             return wrapper
#
#         View.get_context_data = method_decorator(additionnal_context)(View.get_context_data)
#         return View
#
#     return decorator


# @test_context('Administration/index.html')
class AdminIndexView(LoginRequiredMixin, StaffuserRequiredMixin, MenuView, TemplateView):
    template_name = 'Administration/index.html'

    def get(self, request, *args, **kwargs):
        try:
            GuildSettings.objects.first()
        except:
            return HttpResponseRedirect(reverse('admin_guild_setting'))


class AdminGuildSetting(LoginRequiredMixin, StaffuserRequiredMixin, MenuView, CreateView):
    template_name = 'Administration/guild_settings.html'
# DEBUT MEMBRES

class AdminMembersView(LoginRequiredMixin, StaffuserRequiredMixin, MenuView, ListView):
    model = User
    template_name = 'Administration/users/user_list.html'

    def dispatch(self, request, *args, **kwargs):
        return super(AdminMembersView, self).dispatch(request, *args, **kwargs)


class AdminUserDetailView(LoginRequiredMixin, StaffuserRequiredMixin, SelectRelatedMixin, MenuView, DetailView):
    template_name = 'Administration/users/user_detail.html'
    model = User<commit_msg>no message<commit_after>from django.core.urlresolvers import reverse, reverse_lazy
from django.http import HttpResponse, JsonResponse, HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.contrib.auth.models import User
from django.utils.decorators import method_decorator
from django.views.generic import ListView, DetailView, FormView, UpdateView
from braces.views import LoginRequiredMixin, SuperuserRequiredMixin, StaffuserRequiredMixin, SelectRelatedMixin
from django.views.generic.base import View, ContextMixin, TemplateView
from Portal.models import Game, Userprofile, Portal
from django.views.generic import ListView, DetailView, FormView, UpdateView, View, CreateView
from braces.views import LoginRequiredMixin, SuperuserRequiredMixin, StaffuserRequiredMixin, SelectRelatedMixin
from django.views.generic.base import TemplateView
from Forum.models import Post
from Portal.models import Game, Userprofile, CommentNews, CharacterAttribute
from PortalAdmin.forms import UserForm
from SuperPortal.models import GuildSettings


class MenuView(object):

    def get_context_data(self, **kwargs):
        context = super(MenuView, self).get_context_data(**kwargs)
        context['games'] = Game.objects.all()
        return context

# def test_context(template_name):
#     def decorator(function):
#         def additionnal_context(function):
#
#             def wrapper(**kwargs):
#                 TemplateView.template_name = template_name
#                 context = {}
#                 context['games'] = ['toto', 'titi']
#                 return context
#
#             return wrapper
#
#         View.get_context_data = method_decorator(additionnal_context)(View.get_context_data)
#         return View
#
#     return decorator


# @test_context('Administration/index.html')
class AdminIndexView(LoginRequiredMixin, StaffuserRequiredMixin, MenuView, TemplateView):
    template_name = 'Administration/index.html'

    def get(self, request, *args, **kwargs):
        try:
            GuildSettings.objects.first()
        except:
            return HttpResponseRedirect(reverse('admin_guild_setting'))


class AdminGuildSetting(LoginRequiredMixin, StaffuserRequiredMixin, MenuView, CreateView):
    template_name = 'Administration/guild_settings.html'
    model = GuildSettings
# DEBUT MEMBRES

class AdminMembersView(LoginRequiredMixin, StaffuserRequiredMixin, MenuView, ListView):
    model = User
    template_name = 'Administration/users/user_list.html'

    def dispatch(self, request, *args, **kwargs):
        return super(AdminMembersView, self).dispatch(request, *args, **kwargs)


class AdminUserDetailView(LoginRequiredMixin, StaffuserRequiredMixin, SelectRelatedMixin, MenuView, DetailView):
    template_name = 'Administration/users/user_detail.html'
    model = User
{'fraction_non_alphanumeric': 0.08322981366459627, 'fraction_numerical': 0.001064773735581189, 'mean_word_length': 4.59682224428997, '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': '5962047', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1491, 'n_words': 364}