<commit_before>from django.shortcuts import render, redirect
from models import Profile
from game_calendar.models import Event
from django.contrib.auth.decorators import login_required
from django.views.generic import UpdateView, ListView
from django.core.urlresolvers import reverse_lazy
from chat.models import ChatRoom
from django.contrib.auth.models import User

@login_required
def profile(request):
    profile = request.user.profile
    context = {
        'profile': profile,
        'events': Event.objects.filter(invitees=profile)
    }
    return render(request, 'profiles/profile.html', context)    

@login_required
def other_profile(request, slug):
    if Profile.objects.get(slug=slug):
        context = {}
        if request.user.username == slug:
            return redirect("/profile/")
        try:
            profile = Profile.objects.get(slug=slug)
            context['profile'] = profile
            context['friends'] = profile.get_friends()
            context['active_chats'] = ChatRoom.objects.filter(subscribers=profile)
            context['owned_chats'] = ChatRoom.objects.filter(owner=profile)
        except Profile.DoesNotExist:
            pass
        return render(request, 'profiles/other_profile.html', context)
    else:
        return redirect('/')

@login_required
def make_friends(request, pk):
    request.user.profile.requested_friends.add(Profile.objects.get(pk=pk))
    return redirect('/profile/')

@login_required
def add_friend(request, pk):
    prof = Profile.objects.get(pk=pk)
    request.user.profile.friends.add(prof)
    request.user.profile.requesting_friend.remove(prof)
    prof.requested_friends.remove(prof)
    return redirect('/profile/'+prof.user.username)

@login_required
def block_asshole(request, pk):
    request.user.profile.blocking.add(Profile.objects.get(pk=pk))
    return redirect('/profile/')

@login_required
def unblock_asshole(request, pk):
    prof = Profile.objects.get(pk=pk)
    request.user.profile.blocking.remove(prof)
    return redirect('/profile/'+prof.user.username)


def accept_invitation(request, pk):
    profile = request.user.profile
    event = Event.objects.get(pk=pk)
    event.attending.add(profile)
    event.invitees.remove(profile)<commit_msg>fix going to random profiles<commit_after>from django.shortcuts import render, redirect
from models import Profile
from game_calendar.models import Event
from django.contrib.auth.decorators import login_required
from django.views.generic import UpdateView, ListView
from django.core.urlresolvers import reverse_lazy
from chat.models import ChatRoom

@login_required
def profile(request):
    profile = request.user.profile
    context = {
        'profile': profile,
        'events': Event.objects.filter(invitees=profile)
    }
    return render(request, 'profiles/profile.html', context)    

@login_required
def other_profile(request, slug):
    context = {}
    if request.user.username == slug:
        return redirect("/profile/")
    try:
        profile = Profile.objects.get(slug=slug)
        context['profile'] = profile
        context['friends'] = profile.get_friends()
        context['active_chats'] = ChatRoom.objects.filter(subscribers=profile)
        context['owned_chats'] = ChatRoom.objects.filter(owner=profile)
    except Profile.DoesNotExist:
        return redirect('/')
    return render(request, 'profiles/other_profile.html', context)

@login_required
def make_friends(request, pk):
    request.user.profile.requested_friends.add(Profile.objects.get(pk=pk))
    return redirect('/profile/')

@login_required
def add_friend(request, pk):
    prof = Profile.objects.get(pk=pk)
    request.user.profile.friends.add(prof)
    request.user.profile.requesting_friend.remove(prof)
    prof.requested_friends.remove(prof)
    return redirect('/profile/'+prof.user.username)

@login_required
def block_asshole(request, pk):
    request.user.profile.blocking.add(Profile.objects.get(pk=pk))
    return redirect('/profile/')

@login_required
def unblock_asshole(request, pk):
    prof = Profile.objects.get(pk=pk)
    request.user.profile.blocking.remove(prof)
    return redirect('/profile/'+prof.user.username)


def accept_invitation(request, pk):
    profile = request.user.profile
    event = Event.objects.get(pk=pk)
    event.attending.add(profile)
    event.invitees.remove(profile)
{'fraction_non_alphanumeric': 0.11526980482204363, 'fraction_numerical': 0.0, 'mean_word_length': 3.9839816933638446, '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': '5771543', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1274, 'n_words': 243}