# Path: src/contrib/debug_toolbar_user_panel/forms.py
# class UserForm(forms.Form):
#     val = forms.CharField(label='User.{id,username,email}')
# 
#     def get_lookup(self):
#         val = self.cleaned_data['val']
# 
#         if '@' in val:
#             return {'email': val}
# 
#         try:
#             return {'pk': int(val)}
#         except:
#             return {'username': val}
# 
# Path: src/contrib/debug_toolbar_user_panel/decorators.py
# def debug_required(fn):
#     @functools.wraps(fn)
#     def wrapper(*args, **kwargs):
#         if not getattr(settings, 'DEBUG_TOOLBAR_USER_DEBUG', settings.DEBUG):
#             return HttpResponseForbidden()
#         return fn(*args, **kwargs)
#     return wrapper


from django.http import HttpResponseRedirect, HttpResponseBadRequest
from django.conf import settings
from django.contrib import auth
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.auth.models import User
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from .forms import UserForm
from .decorators import debug_required


@debug_required
def content(request):
    current = []

    if request.user.is_authenticated():
        for field in User._meta.fields:
            if field.name == 'password':
                continue
            current.append(
                (field.attname, getattr(request.user, field.attname))
            )

    return render_to_response('debug_toolbar_user_panel/content.html', {

# Path: src/contrib/debug_toolbar_user_panel/forms.py
# class UserForm(forms.Form):
#     val = forms.CharField(label='User.{id,username,email}')
# 
#     def get_lookup(self):
#         val = self.cleaned_data['val']
# 
#         if '@' in val:
#             return {'email': val}
# 
#         try:
#             return {'pk': int(val)}
#         except:
#             return {'username': val}
# 
# Path: src/contrib/debug_toolbar_user_panel/decorators.py
# def debug_required(fn):
#     @functools.wraps(fn)
#     def wrapper(*args, **kwargs):
#         if not getattr(settings, 'DEBUG_TOOLBAR_USER_DEBUG', settings.DEBUG):
#             return HttpResponseForbidden()
#         return fn(*args, **kwargs)
#     return wrapper


# Path: src/contrib/debug_toolbar_user_panel/views.py
from django.http import HttpResponseRedirect, HttpResponseBadRequest
from django.conf import settings
from django.contrib import auth
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.auth.models import User
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from .forms import UserForm
from .decorators import debug_required



@debug_required
def content(request):
    current = []

    if request.user.is_authenticated():
        for field in User._meta.fields:
            if field.name == 'password':
                continue
            current.append(
                (field.attname, getattr(request.user, field.attname))
            )

    return render_to_response('debug_toolbar_user_panel/content.html', {

        'form': UserForm(),