<commit_before>import datetime
import json
import logging
import random
import string
import sys
import uuid

from django.conf import settings
from django.contrib.auth import logout, authenticate, login
from django.contrib.auth.forms import PasswordResetForm
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf
from django.core.mail import send_mail
from django.core.validators import validate_email, validate_slug, ValidationError
from django.db import IntegrityError
from django.http import HttpResponse, Http404
from django.shortcuts import redirect
from mitxmako.shortcuts import render_to_response, render_to_string

from django_future.csrf import ensure_csrf_cookie

from models import Registration, UserProfile, PendingNameChange, PendingEmailChange

log = logging.getLogger("mitx.student")

def csrf_token(context):
    ''' A csrf token that can be included in a form.
    '''
    csrf_token = context.get('csrf_token', '')
    if csrf_token == 'NOTPROVIDED':
        return ''
    return u'<div style="display:none"><input type="hidden" name="csrfmiddlewaretoken" value="%s" /></div>' % (csrf_token)

@ensure_csrf_cookie
def index(request):
    ''' Redirects to main page -- info page if user authenticated, or marketing if not
    '''
    if settings.COURSEWARE_ENABLED and request.user.is_authenticated():
        return redirect('/info')
    else:
        csrf_token = csrf(request)['csrf_token']
        # TODO: Clean up how 'error' is done.
        return render_to_response('index.html', {'courses' : settings.COURSES,
                                                 'csrf': csrf_token })

@ensure_csrf_cookie
def dashboard(request):
  csrf_token = csrf(request)['csrf_token']
  return render_to_response('dashboard.html', {'csrf': csrf_token})

# Need different levels of logging
@ensure_csrf_cookie
def login_user(request, error=""):
    ''' AJAX request to log in the user. '''<commit_msg>Redirect to /courses instead of /info<commit_after>import datetime
import json
import logging
import random
import string
import sys
import uuid

from django.conf import settings
from django.contrib.auth import logout, authenticate, login
from django.contrib.auth.forms import PasswordResetForm
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf
from django.core.mail import send_mail
from django.core.validators import validate_email, validate_slug, ValidationError
from django.db import IntegrityError
from django.http import HttpResponse, Http404
from django.shortcuts import redirect
from mitxmako.shortcuts import render_to_response, render_to_string

from django_future.csrf import ensure_csrf_cookie

from models import Registration, UserProfile, PendingNameChange, PendingEmailChange

log = logging.getLogger("mitx.student")

def csrf_token(context):
    ''' A csrf token that can be included in a form.
    '''
    csrf_token = context.get('csrf_token', '')
    if csrf_token == 'NOTPROVIDED':
        return ''
    return u'<div style="display:none"><input type="hidden" name="csrfmiddlewaretoken" value="%s" /></div>' % (csrf_token)

@ensure_csrf_cookie
def index(request):
    ''' Redirects to main page -- info page if user authenticated, or marketing if not
    '''
    if settings.COURSEWARE_ENABLED and request.user.is_authenticated():
        return redirect('/courses')
    else:
        csrf_token = csrf(request)['csrf_token']
        # TODO: Clean up how 'error' is done.
        return render_to_response('index.html', {'courses' : settings.COURSES,
                                                 'csrf': csrf_token })

@ensure_csrf_cookie
def dashboard(request):
  csrf_token = csrf(request)['csrf_token']
  return render_to_response('dashboard.html', {'csrf': csrf_token})

# Need different levels of logging
@ensure_csrf_cookie
def login_user(request, error=""):
    ''' AJAX request to log in the user. '''
{'fraction_non_alphanumeric': 0.09259717751918792, 'fraction_numerical': 0.0014855162168853676, 'mean_word_length': 4.415549597855228, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6864432', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1169, 'n_words': 345}