<commit_before># Imports {{{
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseServerError
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
import django.contrib.auth 
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.contrib.auth.views import redirect_to_login
from django_authopenid.forms import OpenidSigninForm
from django.core.urlresolvers import reverse

from invitation.forms import InvitationKeyForm
from invitation.models import InvitationKey

import urllib
import mock
import logging

from mysite.account.forms import InvitationRequestForm
import mysite.base.views
import mysite.base.controllers
from mysite.base.controllers import get_notification_from_request
from mysite.profile.models import Person, ProjectExp, Tag, TagType, Link_ProjectExp_Tag, Link_Project_Tag, Link_SF_Proj_Dude_FM, Link_Person_Tag, DataImportAttempt

# FIXME: We did this because this decorator used to live here
# and lots of other modules refer to it as mysite.account.views.view.
# Let's fix this soon.
from mysite.base.decorators import view
# }}}

applog = logging.getLogger('applog')

def signup_do(request):
    # {{{
    post = {}
    post.update(dict(request.POST.items()))
    post['password2'] = post['<PASSWORD>'] 
    signup_form = mysite.account.forms.UserCreationFormWithEmail(post)
    if signup_form.is_valid():

        user = signup_form.save()


        username = request.POST['username']
        password = request.POST['<PASSWORD>']

        # authenticate and login
        user = django.contrib.auth.authenticate(
                username=username,
                password=password)
        django.contrib.auth.login(request, user)

        # redirect to profile
        return HttpResponseRedirect(
                '/people/%s/' % urllib.quote(username))

    else:
        return mysite.account.views.signup(request, signup_form=signup_form)
    # }}}

def signup(request, signup_form=None, invite_code=''):
    # {{{
    if signup_form is None:
        signup_form = mysite.account.forms.UserCreationFormWithEmail(
            initial={'invite_code': invite_code})

    return render_to_response('account/signup.html',
                              {'form': signup_form})
    # }}}

def logout(request):
    # {{{
    django.contrib.auth.logout(request)
    return HttpResponseRedirect("/?msg=ciao#tab=login")
    # }}}

@login_required
@view
def edit_photo(request, form = None):
    if form is None:
        form = mysite.account.forms.EditPhotoForm()
    data = mysite.profile.views.get_personal_data(request.user.get_profile())
    data['edit_photo_form'] = form
    return (request, 'account/edit_photo.html', data)

@login_required
def edit_photo_do(request, mock=None):
    person = request.user.get_profile()
    data = mysite.profile.views.get_personal_data(person)
    form = mysite.account.forms.EditPhotoForm(request.POST,
                                       request.FILES,
                                       instance=person)
    if form.is_valid():
        person = form.save()
        person.generate_thumbnail_from_photo()

        return HttpResponseRedirect(reverse(mysite.profile.views.display_person_web, kwargs={
            'user_to_display__username': request.user.username
            }))
    else:
        return edit_photo(request, form)

def catch_me(request):
    import pdb
    pdb.set_trace()

@login_required
@view
def settings(request):
    # {{{
    data = {}
    return (request, 'account/settings.html', data)
    # }}}

@login_required
@view
def edit_contact_info(request, edit_email_form = None, show_email_form = None):
    # {{{

    data = {}
    # Store edit_email_form in data[], even if we weren't passed one
    if edit_email_form is None:
        edit_email_form = mysite.account.forms.EditEmailForm(
            instance=request.user, prefix='edit_email')
    data['edit_email_form'] = edit_email_form
    <commit_msg>Don't use pdb in the catch_me view.<commit_after># Imports {{{
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseServerError
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
import django.contrib.auth 
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.contrib.auth.views import redirect_to_login
from django_authopenid.forms import OpenidSigninForm
from django.core.urlresolvers import reverse

from invitation.forms import InvitationKeyForm
from invitation.models import InvitationKey

import urllib
import mock
import logging

from mysite.account.forms import InvitationRequestForm
import mysite.base.views
import mysite.base.controllers
from mysite.base.controllers import get_notification_from_request
from mysite.profile.models import Person, ProjectExp, Tag, TagType, Link_ProjectExp_Tag, Link_Project_Tag, Link_SF_Proj_Dude_FM, Link_Person_Tag, DataImportAttempt

# FIXME: We did this because this decorator used to live here
# and lots of other modules refer to it as mysite.account.views.view.
# Let's fix this soon.
from mysite.base.decorators import view
# }}}

applog = logging.getLogger('applog')

def signup_do(request):
    # {{{
    post = {}
    post.update(dict(request.POST.items()))
    post['password2'] = post['password1'] 
    signup_form = mysite.account.forms.UserCreationFormWithEmail(post)
    if signup_form.is_valid():

        user = signup_form.save()


        username = request.POST['username']
        password = request.POST['<PASSWORD>']

        # authenticate and login
        user = django.contrib.auth.authenticate(
                username=username,
                password=password)
        django.contrib.auth.login(request, user)

        # redirect to profile
        return HttpResponseRedirect(
                '/people/%s/' % urllib.quote(username))

    else:
        return mysite.account.views.signup(request, signup_form=signup_form)
    # }}}

def signup(request, signup_form=None, invite_code=''):
    # {{{
    if signup_form is None:
        signup_form = mysite.account.forms.UserCreationFormWithEmail(
            initial={'invite_code': invite_code})

    return render_to_response('account/signup.html',
                              {'form': signup_form})
    # }}}

def logout(request):
    # {{{
    django.contrib.auth.logout(request)
    return HttpResponseRedirect("/?msg=ciao#tab=login")
    # }}}

@login_required
@view
def edit_photo(request, form = None):
    if form is None:
        form = mysite.account.forms.EditPhotoForm()
    data = mysite.profile.views.get_personal_data(request.user.get_profile())
    data['edit_photo_form'] = form
    return (request, 'account/edit_photo.html', data)

@login_required
def edit_photo_do(request, mock=None):
    person = request.user.get_profile()
    data = mysite.profile.views.get_personal_data(person)
    form = mysite.account.forms.EditPhotoForm(request.POST,
                                       request.FILES,
                                       instance=person)
    if form.is_valid():
        person = form.save()
        person.generate_thumbnail_from_photo()

        return HttpResponseRedirect(reverse(mysite.profile.views.display_person_web, kwargs={
            'user_to_display__username': request.user.username
            }))
    else:
        return edit_photo(request, form)

def catch_me(request):
    failboat # NameError

@login_required
@view
def settings(request):
    # {{{
    data = {}
    return (request, 'account/settings.html', data)
    # }}}

@login_required
@view
def edit_contact_info(request, edit_email_form = None, show_email_form = None):
    # {{{

    data = {}
    # Store edit_email_form in data[], even if we weren't passed one
    if edit_email_form is None:
        edit_email_form = mysite.account.forms.EditEmailForm(
            instance=request.user, prefix='edit_email')
    data['edit_email_form'] = edit_email_form
    
{'fraction_non_alphanumeric': 0.09946404088246293, 'fraction_numerical': 0.001869624828617724, 'mean_word_length': 3.3870967741935485, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '4404568', 'n_tokens_mistral': 2411, 'n_tokens_neox': 2359, 'n_words': 507}