<commit_before>"""Simple user views."""

from django.shortcuts import render
from django.utils import translation
from django.utils.translation import ugettext as _

from django.contrib.auth.decorators import login_required, user_passes_test

from rest_framework.authtoken.models import Token

from modoboa.lib import events
from modoboa.lib.cryptutils import encrypt
from modoboa.lib.web_utils import (
    _render_to_string, render_to_json_response
)
from modoboa.parameters import tools as param_tools

from ..forms import ProfileForm, APIAccessForm
from .. import signals


@login_required
def index(request, tplname="core/user_index.html"):
    """Render user index page."""
    # FIXME: replace ExtraUprefsJS in autoreply
    return render(request, tplname, {"selection": "user"})


@login_required
def profile(request, tplname='core/user_profile.html'):
    """Profile detail/update view."""
    update_password = True
    results = signals.allow_password_change.send(
        sender="profile", user=request.user)
    if True in [result[1] for result in results]:
        update_password = False<commit_msg>Remove useless import.<commit_after>"""Simple user views."""

from django.shortcuts import render
from django.utils import translation
from django.utils.translation import ugettext as _

from django.contrib.auth.decorators import login_required, user_passes_test

from rest_framework.authtoken.models import Token

from modoboa.lib.cryptutils import encrypt
from modoboa.lib.web_utils import (
    _render_to_string, render_to_json_response
)
from modoboa.parameters import tools as param_tools

from ..forms import ProfileForm, APIAccessForm
from .. import signals


@login_required
def index(request, tplname="core/user_index.html"):
    """Render user index page."""
    return render(request, tplname, {"selection": "user"})


@login_required
def profile(request, tplname='core/user_profile.html'):
    """Profile detail/update view."""
    update_password = True
    results = signals.allow_password_change.send(
        sender="profile", user=request.user)
    if True in [result[1] for result in results]:
        update_password = False
{'fraction_non_alphanumeric': 0.0917516218721038, 'fraction_numerical': 0.0009267840593141798, 'mean_word_length': 4.9476584022038566, 'pattern_counts': {'":': 2, '<': 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': '4409566', 'n_tokens_mistral': 617, 'n_tokens_neox': 607, 'n_words': 178}