<commit_before>from django.shortcuts import render, get_object_or_404
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404
from django.contrib import auth
from django.contrib import messages
from django.utils.translation import ugettext as _
from django.views.decorators.http import require_POST
from django.contrib.auth.views import password_reset_confirm as django_password_reset_confirm
from django.utils.http import base36_to_int

from account.forms import UserLoginForm, NewUserForm, UserChangeAddressForm
from account.models import AccountManager
from foirequest.models import FoiRequest
from froide.helper.auth import login_user
from froide.helper.utils import render_403


def confirm(request, user_id, secret, request_id=None):
    if request.user.is_authenticated():
        messages.add_message(request, messages.ERROR,
                _('You are logged in and cannot use a confirmation link.'))
        return HttpResponseRedirect(reverse('account-show'))
    user = get_object_or_404(auth.models.User, pk=int(user_id))
    if user.is_active:
        raise Http404
    account_manager = AccountManager(user)
    if account_manager.confirm_account(secret, request_id):
        messages.add_message(request, messages.WARNING,
                _('Your email address is now confirmed and you are logged in. You should change your password now by filling out the form below.'))
        login_user(request, user)
        if request_id is not None:
            foirequest = FoiRequest.confirmed_request(user, request_id)
            if foirequest:
                messages.add_message(request, messages.SUCCESS,
                    _('Your request "%s" has now been sent') % foirequest.title)
        return HttpResponseRedirect(reverse('account-show') + "?new#change-password-now")
    else:
        messages.add_message(request, messages.ERROR,
                _('You can only use the confirmation link once, please login with your password.'))
    return HttpResponseRedirect(reverse('account-login'))

def go(request, user_id, secret, url):
    if request.user.is_authenticated():
        if request.user.id != user_id:
            messages.add_message(request, messages.NOTICE,
                _('You are logged in with a different user account. Please logout first before using this link.'))
    else:
        user = get_object_or_404(auth.models.User, pk=int(user_id))
        if not user.is_active:
            messages.add_message(request, messages.ERROR,
                _('Your account is not active.'))
            raise Http404
        account_manager = AccountManager(user)
        if account_manager.check_autologin_secret(secret):
            login_user(request, user)
    return HttpResponseRedirect(url)

def show(request, context=None, status=200):
    if not request.user.is_authenticated():
        return render_403(request)
    my_requests = FoiRequest.objects.filter(user=request.user)<commit_msg>There is not NOTICE in messages, just INFO<commit_after>from django.shortcuts import render, get_object_or_404
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404
from django.contrib import auth
from django.contrib import messages
from django.utils.translation import ugettext as _
from django.views.decorators.http import require_POST
from django.contrib.auth.views import password_reset_confirm as django_password_reset_confirm
from django.utils.http import base36_to_int

from account.forms import UserLoginForm, NewUserForm, UserChangeAddressForm
from account.models import AccountManager
from foirequest.models import FoiRequest
from froide.helper.auth import login_user
from froide.helper.utils import render_403


def confirm(request, user_id, secret, request_id=None):
    if request.user.is_authenticated():
        messages.add_message(request, messages.ERROR,
                _('You are logged in and cannot use a confirmation link.'))
        return HttpResponseRedirect(reverse('account-show'))
    user = get_object_or_404(auth.models.User, pk=int(user_id))
    if user.is_active:
        raise Http404
    account_manager = AccountManager(user)
    if account_manager.confirm_account(secret, request_id):
        messages.add_message(request, messages.WARNING,
                _('Your email address is now confirmed and you are logged in. You should change your password now by filling out the form below.'))
        login_user(request, user)
        if request_id is not None:
            foirequest = FoiRequest.confirmed_request(user, request_id)
            if foirequest:
                messages.add_message(request, messages.SUCCESS,
                    _('Your request "%s" has now been sent') % foirequest.title)
        return HttpResponseRedirect(reverse('account-show') + "?new#change-password-now")
    else:
        messages.add_message(request, messages.ERROR,
                _('You can only use the confirmation link once, please login with your password.'))
    return HttpResponseRedirect(reverse('account-login'))

def go(request, user_id, secret, url):
    if request.user.is_authenticated():
        if request.user.id != user_id:
            messages.add_message(request, messages.INFO,
                _('You are logged in with a different user account. Please logout first before using this link.'))
    else:
        user = get_object_or_404(auth.models.User, pk=int(user_id))
        if not user.is_active:
            messages.add_message(request, messages.ERROR,
                _('Your account is not active.'))
            raise Http404
        account_manager = AccountManager(user)
        if account_manager.check_autologin_secret(secret):
            login_user(request, user)
    return HttpResponseRedirect(url)

def show(request, context=None, status=200):
    if not request.user.is_authenticated():
        return render_403(request)
    my_requests = FoiRequest.objects.filter(user=request.user)
{'fraction_non_alphanumeric': 0.07857262523035684, 'fraction_numerical': 0.009716870497570782, 'mean_word_length': 3.5158850226928897, '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': '3792162', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1576, 'n_words': 462}