<commit_before>from django.contrib.auth import get_user_model
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import get_object_or_404
from django.views.generic import UpdateView, FormView
from django.views.generic.detail import DetailView
from django.db.models import Q

from accounts.forms import ProfileEditForm, AcceptTermsForm
from accounts.serializers import TimtecUserSerializer, TimtecUserAdminSerializer
from braces.views import LoginRequiredMixin

from rest_framework import viewsets
from rest_framework import filters
from rest_framework import generics

from core.permissions import IsAdmin


class ProfileEditView(LoginRequiredMixin, UpdateView):
    model = get_user_model()
    form_class = ProfileEditForm
    template_name = 'profile-edit.html'

    def get_success_url(self):
        return reverse_lazy('profile')

    def get_object(self):
        return self.request.user


class ProfileView(LoginRequiredMixin, DetailView):
    model = get_user_model()
    template_name = 'profile.html'
    context_object_name = 'profile_user'

    def get_object(self):
        if hasattr(self, 'kwargs') and 'username' in self.kwargs:
            try:
                return get_object_or_404(self.model, username=self.kwargs['username'])
            except:<commit_msg>profile: after edit, redirect to next url if present<commit_after>from django.contrib.auth import get_user_model
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import get_object_or_404
from django.views.generic import UpdateView, FormView
from django.views.generic.detail import DetailView
from django.db.models import Q

from accounts.forms import ProfileEditForm, AcceptTermsForm
from accounts.serializers import TimtecUserSerializer, TimtecUserAdminSerializer
from braces.views import LoginRequiredMixin

from rest_framework import viewsets
from rest_framework import filters
from rest_framework import generics

from core.permissions import IsAdmin


class ProfileEditView(LoginRequiredMixin, UpdateView):
    model = get_user_model()
    form_class = ProfileEditForm
    template_name = 'profile-edit.html'

    def get_success_url(self):
        url = self.request.REQUEST.get('next', None)
        if url:
            return url
        else:
            return reverse_lazy('profile')

    def get_object(self):
        return self.request.user


class ProfileView(LoginRequiredMixin, DetailView):
    model = get_user_model()
    template_name = 'profile.html'
    context_object_name = 'profile_user'

    def get_object(self):
        if hasattr(self, 'kwargs') and 'username' in self.kwargs:
            try:
                return get_object_or_404(self.model, username=self.kwargs['username'])
            except:
{'fraction_non_alphanumeric': 0.06583936573595311, 'fraction_numerical': 0.004136504653567736, 'mean_word_length': 4.324770642201835, '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': '1499497', 'n_tokens_mistral': 818, 'n_tokens_neox': 787, 'n_words': 217}