<commit_before>from django.contrib.auth.models import User
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import redirect, get_object_or_404
from django.http import HttpResponseForbidden, Http404, HttpResponseRedirect
from django.utils.translation import ugettext as _
from django.views.generic import TemplateView

from guardian.decorators import permission_required_or_403
from userena.utils import signin_redirect, get_profile_model, get_user_model
from userena import settings as userena_settings
from userena.views import ExtraContextTemplateView
from userena.views import profile_edit as userena_profile_edit, profile_detail as userena_profile_detail
from userena.decorators import secure_required

from .forms import ProfileEditForm

def profile_detail(request, username):

    extra_context = {}
    user = get_object_or_404(get_user_model(),
                             username__iexact=username)

    # Get profile
    profile_model = get_profile_model()
    profile = user.get_profile()
    # Check perms
    if not profile.can_view_profile(request.user):
        return HttpResponseForbidden(_("You don't have permission to view this profile."))

    # context<commit_msg>Removed two functions 'create_profile' and 'set_guardian_permissions' that were not used, #14 related<commit_after>from django.contrib.auth.models import User
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import redirect, get_object_or_404
from django.http import HttpResponseForbidden, Http404, HttpResponseRedirect
from django.utils.translation import ugettext as _
from django.views.generic import TemplateView

from guardian.decorators import permission_required_or_403
from userena.utils import signin_redirect, get_profile_model, get_user_model
from userena import settings as userena_settings
from userena.views import ExtraContextTemplateView
from userena.views import profile_edit as userena_profile_edit, profile_detail as userena_profile_detail
from userena.decorators import secure_required

from .forms import ProfileEditForm

def profile_detail(request, username):
    """
        Add extra context and returns userena_profile_detail view
    """
    extra_context = {}
    user = get_object_or_404(get_user_model(),
                             username__iexact=username)

    # Get profile
    profile_model = get_profile_model()
    profile = user.get_profile()
    # Check perms
    if not profile.can_view_profile(request.user):
        return HttpResponseForbidden(_("You don't have permission to view this profile."))

    # context
{'fraction_non_alphanumeric': 0.05330243337195829, 'fraction_numerical': 0.010042487446890692, 'mean_word_length': 5.023255813953488, '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': '4964230', 'n_tokens_mistral': 709, 'n_tokens_neox': 684, 'n_words': 203}