<commit_before>from django.conf import settings
from django.db.models import Q
from django.template import RequestContext
from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404, redirect, render_to_response
from decorators import allowed_user_required
from helpers import get_redir_path, get_paginator, check_allow_for_user


@allowed_user_required
def impersonate(request, uid):
    ''' Takes in the UID of the user to impersonate.
        View will fetch the User instance and store it 
        in the request.session under the '_impersonate' key.
        
        The middleware will then pick up on it and adjust the 
        request object as needed.
    '''
    new_user = get_object_or_404(User, pk=uid)
    if check_allow_for_user(request.user, new_user):
        request.session['_impersonate'] = new_user
        request.session.modified = True  # Let's make sure...
    return redirect(get_redir_path())


@allowed_user_required
def stop_impersonate(request):
    ''' Remove the impersonation object from the session
    '''
    if '_impersonate' in request.session:<commit_msg>Removed decorator from stop view<commit_after>from django.conf import settings
from django.db.models import Q
from django.template import RequestContext
from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404, redirect, render_to_response
from decorators import allowed_user_required
from helpers import get_redir_path, get_paginator, check_allow_for_user


@allowed_user_required
def impersonate(request, uid):
    ''' Takes in the UID of the user to impersonate.
        View will fetch the User instance and store it 
        in the request.session under the '_impersonate' key.
        
        The middleware will then pick up on it and adjust the 
        request object as needed.
    '''
    new_user = get_object_or_404(User, pk=uid)
    if check_allow_for_user(request.user, new_user):
        request.session['_impersonate'] = new_user
        request.session.modified = True  # Let's make sure...
    return redirect(get_redir_path())


def stop_impersonate(request):
    ''' Remove the impersonation object from the session
    '''
    if '_impersonate' in request.session:
{'fraction_non_alphanumeric': 0.06544968833481746, 'fraction_numerical': 0.005342831700801425, 'mean_word_length': 3.884782608695652, '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': '6846256', 'n_tokens_mistral': 650, 'n_tokens_neox': 629, 'n_words': 212}